Jump to content
  • Advertisement
Sign in to follow this  
bikola_p

Registry Reading

This topic is 4594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, after searching and looking through some tutorials, i cant seem to find a simple example of reading from an existing registry key, or writing a creating a new registry key. This is one of those things, I would expect is well documented and easy to pick up, but im finding it pretty difficult.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Is it not CreateRegisteryKey()?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
RegCreateKeyEx
RegQueryValueEx

Share this post


Link to post
Share on other sites

/***********************************************************************************************
Get keys function
written by Aaron Holland 14 Mar 2000

This function returns a key value

KeyName: A sub key. (can contain \'s)
AttribName: The attribute name.

returns: A string value of the Data

***********************************************************************************************/

char* GetRegSetting(HKEY TopLevel, LPCSTR KeyName, LPSTR AttribName)
{
//declare variables
long KeySize = 255;
HKEY KeyPointer;

if(DEBUG){
printf("KeyName: %s\n", KeyName);
printf("AttribName: %s\n", AttribName);
}

RegOpenKeyEx(TopLevel, KeyName, NULL, KEY_READ, &KeyPointer);
RegQueryValueEx(KeyPointer, AttribName, NULL, NULL, (LPBYTE)output, (LPDWORD)&KeySize);
RegCloseKey(KeyPointer);

if(DEBUG){
printf("Read registry value: %s\n", output);
}

return output;
}



/***********************************************************************************************
Set keys function
written by Aaron Holland 1 Nov 2000

This function sets a key value

KeyName: A sub key. (can contain \'s)
AttribName: The attribute name.
Value: A value for the attribute

***********************************************************************************************/

void SetRegSetting(HKEY TopLevel, LPCSTR KeyName, LPSTR AttribName, const BYTE* Value, int Size)
{
//declare variables
DWORD KeySize = (DWORD)Size;
HKEY KeyPointer;

if(DEBUG){
printf("KeyName: %s\n", KeyName);
printf("AttribName: %s\n", AttribName);
}

RegOpenKeyEx(TopLevel, KeyName, NULL, KEY_WRITE, &KeyPointer);
RegSetValueEx(KeyPointer, AttribName, NULL, REG_SZ, Value, KeySize);
RegCloseKey(KeyPointer);

if(DEBUG){
printf("Wrote registry value: \n%s\n", Value);
}
}



No keys actually being created here, but should get you started. MSDN for RegOpenKeyEx and there will probably be links to CreateKey etc...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!