Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #define _WIN32_WINNT 0x0501
  2. #define SUBKEY "Software\\Microsoft\\Windows\\CurrentVersion\\Run"
  3. #define VALUENAME "Mawdioh"
  4. #include <windows.h>
  5.  
  6. int main(int argc, char* args[])
  7. {
  8.     HKEY subkey;
  9.     HWND hWnd;
  10.     char szFullName[MAX_PATH];
  11.     int l;
  12.     if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, SUBKEY, 0, KEY_SET_VALUE, &subkey) != ERROR_SUCCESS)
  13.     {
  14.         return 1;
  15.     }
  16.     if(GetModuleFileName(0, szFullName, MAX_PATH) == 0)
  17.     {
  18.         return 2;
  19.     }
  20.     l = strlen(szFullName) + 1;
  21.     if(RegSetValueEx(subkey, VALUENAME, 0, REG_SZ, szFullName, l) != ERROR_SUCCESS)
  22.     {
  23.         return 3;
  24.     }
  25.     if(RegCloseKey(subkey) != ERROR_SUCCESS)
  26.     {
  27.         return 4;
  28.     }
  29.     return 0;
  30.     /*
  31.     for(;;)
  32.     {
  33.         hWnd = GetConsoleWindow();
  34.         SendMessage(hWnd, 0x0122, 0x0F170, 2);
  35.     }
  36.     */
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement