Daniel Bass
2003-08-07 07:51:46 UTC
I've got a integer height for a window stored in the registry, but as a
string (REG_SZ)... I want to retrieve this unicode string value, and convert
it into an int, which is then in the form i can use...
below is the code, your help would be deeply appreciated!!!
//
// access the height from the registry
//
int nWindowHeight = 160; // in pixels
HKEY hKey;
TCHAR* regKey = _T("SOFTWARE\\KHI-RO");
LONG result = RegOpenKeyEx( HKEY_CURRENT_USER, regKey, 0, KEY_READ,
&hKey );
if ( result == ERROR_SUCCESS )
{
//
// the reg open succeeded
//
DWORD dwDataSize = 256;
DWORD dwDataType = REG_SZ;
BYTE szData[256];
TCHAR* subKey = _T("KbdHeight");
result = RegQueryValueEx( hKey,
subKey,
0,
&dwDataType,
szData,
&dwDataSize );
if ( result == ERROR_SUCCESS )
{
//
// the reg value retrieval was a success
//
BYTE szData[256];
MessageBox( hwndSip, (TCHAR*)szData, _T("RESULT value"),
MB_OK );
/*** according to the message box szData contains 250, which is
correct... ***/
LONG nRegValue = atol((char*)szData); /*** <<-- I think the
problem's here ***/
//
// some value range checking
//
if ( nRegValue > 20 && nRegValue <= 320 )
{
nWindowHeight = nRegValue;
// doesn't get hit..., so loop doesn't get entered,
therefore atol is the problem...
MessageBox( hwndSip, _T("We got within the required
range..."), _T("DID IT"), MB_OK );
}
}
}
RegCloseKey( hKey );
string (REG_SZ)... I want to retrieve this unicode string value, and convert
it into an int, which is then in the form i can use...
below is the code, your help would be deeply appreciated!!!
//
// access the height from the registry
//
int nWindowHeight = 160; // in pixels
HKEY hKey;
TCHAR* regKey = _T("SOFTWARE\\KHI-RO");
LONG result = RegOpenKeyEx( HKEY_CURRENT_USER, regKey, 0, KEY_READ,
&hKey );
if ( result == ERROR_SUCCESS )
{
//
// the reg open succeeded
//
DWORD dwDataSize = 256;
DWORD dwDataType = REG_SZ;
BYTE szData[256];
TCHAR* subKey = _T("KbdHeight");
result = RegQueryValueEx( hKey,
subKey,
0,
&dwDataType,
szData,
&dwDataSize );
if ( result == ERROR_SUCCESS )
{
//
// the reg value retrieval was a success
//
BYTE szData[256];
MessageBox( hwndSip, (TCHAR*)szData, _T("RESULT value"),
MB_OK );
/*** according to the message box szData contains 250, which is
correct... ***/
LONG nRegValue = atol((char*)szData); /*** <<-- I think the
problem's here ***/
//
// some value range checking
//
if ( nRegValue > 20 && nRegValue <= 320 )
{
nWindowHeight = nRegValue;
// doesn't get hit..., so loop doesn't get entered,
therefore atol is the problem...
MessageBox( hwndSip, _T("We got within the required
range..."), _T("DID IT"), MB_OK );
}
}
}
RegCloseKey( hKey );