Windows API簡單專案演示例項
阿新 • • 發佈:2021-06-21
# WINDOWS API 專案例項 ##### 登錄檔開機項控制 ``` #include <iostream> #include <Windows.h> int main() { /* WINDOWS開機啟動登錄檔: 1.(易被殺軟檢測修改登錄檔)新增鍵值-》"HKEY_LOCAL_MACHINE\\SoftWare\\Microsoft\\Windows\\CurrentVersion\\Run" 2.(白名單修改登錄檔,不易被檢測)新增鍵值-》"" HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Windows\load HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft \WindowsNT\CurrentVersion\Winlogon\Useinit HKEY_CURRENT_USER\Software \Microsoft\Windows\CurrentVersion\Policies\Explorer\Run HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies \Explorer\Run 服務啟動: HKEY_CURRENT_USER\Software \Microsoft\Windows\CurrentVersion\RunServicesOnce HKEY_LOCAL_MACHINE \SOFTWARE\Microsoft\Windows\CurrentVersion\RunServicesOnce 詳細:登錄檔十大啟動項*/ HKEY hkey = 0; //64Bit系統 :KEY_WOW64_64KEY RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SoftWare\\Microsoft\\Windows\\CurrentVersion\\Run", NULL, KEY_WRITE | KEY_WOW64_64KEY, &hkey); RegSetKeyValueA(hkey, NULL, "FORTEST", REG_SZ, "THISTEST", strlen("THISTEST")); } ``` ##### windowsAPI之下載API ``` #include<iostream> #include <Windows.h> #include <urlmon.h> #pragma comment(lib,"urlmon.lib") //從Internet下載位並將其儲存到檔案中。 int main(int argv,char* argc[]) { char szurl[] = "https://youimg1.c-ctrip.com/target/1009050000000s4w4D190.jpg"; char szpath[] = "c:\\Download.jpg"; URLDownloadToFileA(NULL, argc[1], argc[2], 0, 0); return 0; } ``` ##### PS:python下載檔案指令碼 ``` response_data_file = requests.get(url, stream=True) with open(file_pname, 'wb') as f: for chunk in response_data_file.iter_content(chunk_size=chunk_size): if chunk: f.write(chunk) ```