1.设置随机启动
HKEY hKey;
LPCTSTR lpSubKey=_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\");
TCHAR AppPathName[MAX_PATH];
GetModuleFileName(NULL, AppPathName, MAX_PATH);
LPCTSTR lpValue = AppPathName;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,lpSubKey,0,KEY_ALL_ACCESS,&hKey)!=ERROR_SUCCESS)
{
cout<<"RegOpenKeyEx HKEY_LOCAL_MACHINE SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\ Error!"<< endl;
return 0;
}
else
{
if(RegSetValueEx(hKey,_T("RecoverDB_Messer"),0,REG_SZ,(const BYTE*)lpValue,lstrlen(lpValue)*sizeof(lpValue))!=ERROR_SUCCESS)
{
cout<<"RegSetValueEx "<<endl;
return 0;
}
}
RegCloseKey(hKey);