Advertisement
Guest User

Untitled

a guest
Apr 9th, 2013
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. TCHAR szPath[MAX_PATH];
  2. GetModuleFileName(NULL,szPath,MAX_PATH);
  3. HKEY newValue;
  4. HKEY resKey;
  5. subValue = "MyProgram";
  6. long key = RegQueryValueExA(resKey, subValue, NULL, NULL, NULL, NULL);
  7. if(key == ERROR_FILE_NOT_FOUND)
  8. {
  9. return false;
  10. }
  11. else
  12. {
  13. RegOpenKey(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",&newValue);
  14. RegSetValueEx(newValue, subValue ,0,REG_SZ,(LPBYTE)szPath,sizeof(szPath));
  15. RegCloseKey(newValue);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement