Thread: Writting to registry failling

  1. #1
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310

    Angry Writting to registry failling

    Code:
    bool WriteRegStr(HKEY hKey, const char *lpszSubKey, const char *lpszValueName, const char *lpData)
    {
        HKEY hkey;
    	if (RegOpenKeyEx(hKey, lpszSubKey, 0, KEY_ALL_ACCESS, &hkey) != ERROR_SUCCESS) return false;
    	{
    		if (RegSetValueEx(hKey, lpszValueName, 0, REG_SZ, LPBYTE(lpData), lstrlen(lpData)+1) != ERROR_SUCCESS) return false;
    		RegCloseKey(hkey);
    		return true;
    	}
    	return false;
    }
    WriteRegStr(HKEY_CURRENT_USER, "Software\\Joel", "temp", "boom");

    I'm attempting to update temp but it doesn't do the job, any ideas?
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Code:
    bool WriteRegStr(HKEY hKey, const char *lpszSubKey, const char *lpszValueName, const char *lpData)
    {
        HKEY hkey;
    	if (RegOpenKeyEx(hKey, lpszSubKey, 0, KEY_ALL_ACCESS, &hkey) != ERROR_SUCCESS) return false;
    Wakka wakka. Your local HKEY variable is used instead of the argument you passed. Probably unintended.

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    29
    HKEY hKey
    HKEY hkey;
    RegOpenKeyEx(hKey,

    good one is used.the argument has a uppercase, same for the parameter passed in RegOpenKeyEx.Very confusing when having two such variables.
    Dev-C++ 4.9.9.2
    Code::Blocks
    Win XP

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    good one is used
    but not on the next line...

  5. #5
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310


    Yeah...I was using the wrong one

    Thanks!
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Registry, Regedit
    By franse in forum C++ Programming
    Replies: 21
    Last Post: 01-29-2009, 09:57 AM
  2. [C] error while writting in the registry (DWORD)
    By BianConiglio in forum Windows Programming
    Replies: 2
    Last Post: 09-19-2004, 05:34 PM
  3. Registry
    By gvector1 in forum C# Programming
    Replies: 0
    Last Post: 07-30-2003, 04:02 PM
  4. how to edit the registry
    By jverkoey in forum Windows Programming
    Replies: 3
    Last Post: 03-28-2003, 04:20 AM
  5. Registry Access
    By ExDigit in forum Windows Programming
    Replies: 3
    Last Post: 01-04-2002, 04:02 AM