Registry Problems

This is a discussion on Registry Problems within the Windows Programming forums, part of the Platform Specific Boards category; Ok, this isn't creating a key or a value =/ Code: HKEY tmpKey = NULL; const char * REG_KEY_NAME = ...

  1. #1
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002

    Registry Problems

    Ok, this isn't creating a key or a value =/

    	HKEY tmpKey = NULL;
    	const char * REG_KEY_NAME = "\\*\\shellex\\ContextMenuHandler\\SHA1-Hash";
    	const char * REG_VALUE_NAME = "command";
    	char key[512];
    	ZeroMemory(key, 512);
    	strcat(key, "\"");
    	strcat(key, GetCommandLine());
    	strcat(key, "\" \"%1\"");
    		if (RegSetValueEx(tmpKey, REG_VALUE_NAME, 0, REG_SZ, (const BYTE *)key, (DWORD)strlen(key)) != ERROR_SUCCESS)
    			MessageBox(NULL, "Can't create registry thing", "shyte", MB_OK);
    Meh, know what's wrong?
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    You need to master the art of scanning the documentation looking for parameters that don't meet the requirements.

    The subkey name specified by lpSubKey must not begin with the backslash character ('\\'). If it does, ERROR_BAD_PATHNAME is returned.

    Size of the information pointed to by the lpData parameter, in bytes. If the data is of type REG_SZ, REG_EXPAND_SZ, or REG_MULTI_SZ, cbData must include the size of the terminating null character or characters.
    Also verify that you are calling RegCloseKey when you are done.

    Of course, I should have picked these up the first time!

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. Registry Problems ( RegSetValuEx )
    By guitarist809 in forum Windows Programming
    Replies: 6
    Last Post: 05-07-2008, 09:55 PM
  3. Problems defining classes
    By esmeco in forum C++ Programming
    Replies: 47
    Last Post: 10-24-2007, 02:13 PM
  4. Having Problems with Win2k and Softice
    By XenoCodex Admin in forum A Brief History of
    Replies: 4
    Last Post: 07-01-2002, 03:14 PM
  5. Registry Access
    By ExDigit in forum Windows Programming
    Replies: 3
    Last Post: 01-04-2002, 04:02 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21