Because, as already noted by Jochen Arndt, RegQueryValueEx does NOT work that way: you misunderstood the function documentation. Change, for instance
windyl3ig wrote:
dwRet = RegQueryValueEx( HKEY_LOCAL_MACHINE,
TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\\~MHz"),
NULL,
NULL,
(LPBYTE) PerfData,
&cbData );
to
DWORD dwMHz;
cbData = sizeof(dwMHz);
dwRet = RegQueryValueEx( result,
TEXT("~MHz"),
NULL,
NULL,
(LPBYTE) &dwMHz,
&cbData );