afterthought
November 14, 2001, 02:59 pm
Okay, I am officially stuck. Lets see if anyone can help me with this.
I am triing to querry the registry for the processor speed. Unfortunatley, I cannot get it
to work.
I can not get 'Value_data' to print the value I want. It works if I redirect 'Value' to a string like 'Identifier' or 'VendorIdentifier'. But when I direct it to '~MHz' it returns a bunch of silly numbers. I tried changing the 'printf(" . . . %d MHz", Value_data) to '%c', '%X', '%x', and '%s' without any success.
Here is the code:
-----------------------------------------------
#include <windows.h>
#include <winreg.h>
#include <stdlib.h>
#include <stdio.h>
void main (void)
{
HKEY hKeyRoot,hKeyNew;
LPCTSTR subkey;
LPTSTR Value;
DWORD retcode;
DWORD Value_type;
BYTE *Value_data;
DWORD Value_size;
hKeyRoot = HKEY_LOCAL_MACHINE;
subkey = "Hardware\\Description\\System\\CentralProcessor\\0";
Value = "~MHz";
Value_data = new BYTE[80];
Value_type = REG_SZ;
retcode = RegOpenKeyEx
(
hKeyRoot,
subkey,
0,
KEY_QUERY_VALUE,
&hKeyNew
);
if (retcode != ERROR_SUCCESS)
printf("Unable to open key\n");
retcode = RegQueryValueEx
(
hKeyNew,
Value,
NULL,
&Value_type,
Value_data,
&Value_size
);
if (retcode != ERROR_SUCCESS)
printf("Unable to read key\n");
else
printf("\n\nValue_data is: \n%d MHz \n\n", Value_data); //This is what I want.
RegCloseKey(hKeyRoot);
system("PAUSE");
return 0;
}
------------------------------------------------
I tried looking at:
<a href="http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/regapi_3wzc.asp?fram=true" target="_blank">http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/sys info/regapi_3wzc.asp?fram=true</a>
and
<a href="http://www.codeguru.com/system/HardwareInfo.shtml" target="_blank">http://www.codeguru.com/system/HardwareInfo.shtml</a>
but I was still unable to solve my problem.
[ November 14, 2001: Message edited by: afterthought ]</p>
I am triing to querry the registry for the processor speed. Unfortunatley, I cannot get it
to work.
I can not get 'Value_data' to print the value I want. It works if I redirect 'Value' to a string like 'Identifier' or 'VendorIdentifier'. But when I direct it to '~MHz' it returns a bunch of silly numbers. I tried changing the 'printf(" . . . %d MHz", Value_data) to '%c', '%X', '%x', and '%s' without any success.
Here is the code:
-----------------------------------------------
#include <windows.h>
#include <winreg.h>
#include <stdlib.h>
#include <stdio.h>
void main (void)
{
HKEY hKeyRoot,hKeyNew;
LPCTSTR subkey;
LPTSTR Value;
DWORD retcode;
DWORD Value_type;
BYTE *Value_data;
DWORD Value_size;
hKeyRoot = HKEY_LOCAL_MACHINE;
subkey = "Hardware\\Description\\System\\CentralProcessor\\0";
Value = "~MHz";
Value_data = new BYTE[80];
Value_type = REG_SZ;
retcode = RegOpenKeyEx
(
hKeyRoot,
subkey,
0,
KEY_QUERY_VALUE,
&hKeyNew
);
if (retcode != ERROR_SUCCESS)
printf("Unable to open key\n");
retcode = RegQueryValueEx
(
hKeyNew,
Value,
NULL,
&Value_type,
Value_data,
&Value_size
);
if (retcode != ERROR_SUCCESS)
printf("Unable to read key\n");
else
printf("\n\nValue_data is: \n%d MHz \n\n", Value_data); //This is what I want.
RegCloseKey(hKeyRoot);
system("PAUSE");
return 0;
}
------------------------------------------------
I tried looking at:
<a href="http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/regapi_3wzc.asp?fram=true" target="_blank">http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/sys info/regapi_3wzc.asp?fram=true</a>
and
<a href="http://www.codeguru.com/system/HardwareInfo.shtml" target="_blank">http://www.codeguru.com/system/HardwareInfo.shtml</a>
but I was still unable to solve my problem.
[ November 14, 2001: Message edited by: afterthought ]</p>