Reading registry

This is a discussion on Reading registry within the Windows Programming forums, part of the Platform Specific Boards category; Hey guys, I was searching alot in google but I could not find a way that worked to read the ...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    38

    Reading registry

    Hey guys, I was searching alot in google but I could not find a way that worked to read the data of a key. I used this to open the key
    Code:
    RegOpenKeyEx(HKEY_LOCAL_MACHINE , "Software\\Someapp\\Theapp" , 0 , 
                    KEY_READ , &location );
    
       RegQueryValueEx(hkey , "Path"  , NULL , &data_type ,
                       (BYTE*)&value , &size);
    But how can I read the data inside? Lets say that "Path" is the directory of the application.

  2. #2
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    308
    Shouldn't location be instead of hkey, and I think you got more than 2 erros there... read at msdn or google for more examples.
    * 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.

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    38
    Okay well I redid the code and now its working.
    Code:
    int main ()
    {
        HKEY keyHandle;
        char rgValue [1024];
        char fnlRes [1024];
        DWORD size1;
        DWORD Type;
    
            if( RegOpenKeyEx(    HKEY_LOCAL_MACHINE,
                "SOFTWARE\\somesoft\\app",0,
                KEY_QUERY_VALUE, &keyHandle) == ERROR_SUCCESS)
                 {
                    size1=1023;
                    RegQueryValueEx( keyHandle, "Path", NULL, &Type,
                        (LPBYTE)rgValue,&size1);
                    printf( "Your path is %s\n", rgValue );
                 }     
            else strcpy(fnlRes,"Somesoft is not installed on your computer!");
        
                RegCloseKey(keyHandle);
    			std::cin.get();
    
    return 0;
    }
    But now I want to go to that directory I tryed using
    Code:
    system ("cd %s"):
    And as I expected it didn't work any help?

    EDIT: fixed every thing works
    Last edited by NoFearXD; 04-14-2007 at 04:53 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 02-02-2009, 06:27 AM
  2. Replies: 2
    Last Post: 01-28-2008, 02:07 AM
  3. Reading and writing to the Registry
    By Stan100 in forum Windows Programming
    Replies: 2
    Last Post: 07-29-2004, 12:11 PM
  4. Reading Registry Values
    By phantomlord in forum Windows Programming
    Replies: 2
    Last Post: 10-09-2003, 02:09 PM
  5. Reading the registry.
    By knave in forum Windows Programming
    Replies: 2
    Last Post: 08-23-2002, 07:33 PM

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