Advertisement
Guest User

Untitled

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