Thread: RegOpenKeyEx question

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    6

    RegOpenKeyEx question

    im having a little problem that i cant figure out, this piece of code
    add's the exe (that is being executed) to bootup (dont know how
    to call it in english) could somebody please show me how i can set a path to the exe that should be added to bootup instead of
    the curent exe that is being executed (since my "instaler" puts
    the files in another directory).
    help very apreciated !


    HKEY hkey;
    char *szBuf;
    TCHAR buff[255];
    DWORD bufflLen = 255;
    LPTSTR dirBuff = buff;

    GetCurrentDirectory(buffLen, dirBuff);
    buffLen = strlen(dirBuff);
    if(buffLen > 3)
    szBuf = strcat(dirBuff, "\\myprogram.exe");
    else
    szBuf = strcat(dirBuff, "myprogram.exe");

    RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\Currentversion\\Run ", 0, KEY_SET_VALUE, &hkey);
    RegSetValueEx (hkey, "myprogram", 0, REG_SZ (LPBYTE) szBuf, strlen(szBuf) + 1);
    RegCloseKey(hkey);

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Please use code tags. That's all I'm gonna say and I think I've already told you before.

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    6
    what are code tags ?

  4. #4
    Registered User
    Join Date
    Jul 2004
    Posts
    6
    arogant mofo

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    >>arogant mofo

    Closed as we dont like insults.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM