Skip to main content
GameDev.net gamedev.net
🔒 Locked

Read register

Started by gerbenvanderlubbe Jul 20, 2002 at 12:29 PM 1 replies 250+ views
LessBread
LessBread
If you mean the Windows Registry, here's some C code:

          
/////////////////////////////////////////////////////////////////////////////

//

static BOOL GetRegKeyHandle(HKEY hKey, LPCTSTR lpSubKey, HKEY *hk)
{
LONG result = ~ERROR_SUCCESS;
if ( hKey != NULL && lpSubKey != NULL )
{
result = RegOpenKeyEx(hKey, lpSubKey, 0, KEY_READ, hk);
}
return ( ERROR_SUCCESS == result );
}


/////////////////////////////////////////////////////////////////////////////

//

static BOOL GetRegKeyStringValue(HKEY hKey, LPTSTR lpValueName, LPTSTR lpValueData, DWORD cbData)
{
LONG result = ~ERROR_SUCCESS;
DWORD dwType = ~REG_SZ;
if ( hKey != NULL && lpValueName != NULL && lpValueData != NULL )
{
result = RegQueryValueEx(hKey, lpValueName, 0, &dwType, (LPBYTE)lpValueData, &cbData);
}
return ( ERROR_SUCCESS == result && dwType == REG_SZ );
}

HKEY hk = NULL;
GetRegKeyHandle(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Notepad"), &hk);
GetRegKeyStringValue(hk, _T("lfFaceName"), szBuffer, MAX_PATH*sizeof(TCHAR));



If you mean the CPU registers, it varies from compiler to compiler.


[edited by - lessbread on July 20, 2002 1:57:53 PM]
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.