royhawk

导航

 

向注册表HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run中写入即可。(HKEY_CUREENT_USER\Software\Microsoft\Windows\CurrentVersion\Run也可以,不清楚这两个地方有什么区别)

void RegExe()
{
    HKEY hKey;
    TCHAR FilePath[MAX_PATH];
    GetModuleFileName(NULL,FilePath,MAX_PATH);
    RegOpenKeyEx(HKEY_LOCAL_MACHINE,L"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,KEY_SET_VALUE,&hKey );
    RegSetValueEx(hKey, L"test",0,REG_EXPAND_SZ,(const BYTE *)FilePath,sizeof(FilePath));
    RegCloseKey(hKey);
}

 

posted on 2015-11-05 19:57  royhawk  阅读(379)  评论(0)    收藏  举报