Guest User

Untitled

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