Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TCHAR szPath[MAX_PATH];
- GetModuleFileName(NULL,szPath,MAX_PATH);
- HKEY newValue;
- HKEY resKey;
- subValue = "MyProgram";
- long key = RegQueryValueExA(resKey, subValue, NULL, NULL, NULL, NULL);
- if(key == ERROR_FILE_NOT_FOUND)
- {
- return false;
- }
- else
- {
- RegOpenKey(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",&newValue);
- RegSetValueEx(newValue, subValue ,0,REG_SZ,(LPBYTE)szPath,sizeof(szPath));
- RegCloseKey(newValue);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement