CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2004
    Posts
    244

    please help registry

    i made this code, but did not work. I want to put some data to registry, more exactly a path. Tho code make a key, but did not set the value. Please help

    HKEY hkey;
    DWORD dwDisposition;
    unsigned char boum[7] = "chaine";
    int dwSize = sizeof (DWORD);


    RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\My Company\\My Application"), 0, NULL, 0, 0, NULL, &hkey, &dwDisposition);
    RegSetValueExA(hkey, "La Chaine", NULL, REG_SZ, (LPBYTE)&boum, dwSize);

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: please help registry

    http://msdn2.microsoft.com/en-us/library/aa911940.aspx

    And, what is the return value of "RegCreateKeyEx"? Did it succeed?

    Viggy

  3. #3
    Join Date
    Apr 2007
    Location
    India
    Posts
    21

    Resolved Re: please help registry

    Did you read the documentation? The first very parameter that you should supply RegSetValueEx should be a handle to an open registry key. I don't see you opening a key, but you are right out trying to set a value. Neither do you check if the call to RegSetValueEx succeeded. May be you should see a sample in MSDN which explains the usage of this call.
    Nobody can give you wiser advice than yourself. - Cicero

    Rajesh Subramanian.
    Codeproject.com: Visual C++ MVP

  4. #4
    Join Date
    Feb 2008
    Location
    Seattle, WA - USA
    Posts
    39

    Re: please help registry

    The 6th parameter of RegCreateKeyEx is the desired access mode. You are passing 0. Try using KEY_SET_VALUE.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured