This is untested (my device does not have your key / value), but it compiles for CE and gives you the gist of how you do what you need: #include
int _tmain(int argc, _TCHAR* argv[]) { HKEY key; if(!RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("System\\CurrentControlSet\\GPS Intermediate Driver\\Drivers\\SiRFStar3HW"), 0, NULL, &key)) { MessageBox(NULL, _T("Failed to open key"), _T("Error"), 0); return -1; } DWORD length; // get the size - it going to be 4 for a DWORD, but this shows how to deal with REG_SZ, etc if(!RegQueryValueEx( key, _T("Baud"), NULL, NULL, NULL, &length)) { MessageBox(NULL, _T("Failed to get buffer size"), _T("Error"), 0); goto exit; } // allocate - again, if we know it a DWORD, this could be simplified BYTE *buffer = (BYTE*)LocalAlloc(LPTR, length); // query if(!RegQueryValueEx( key, _T("Baud"), NULL, NULL, buffer, &length)) { MessageBox(NULL, _T("Failed to get value data"), _T("Error"), 0); goto exit; } // assuming "baud" is a DWORD, not a string DWORD baud = *(DWORD*)buffer; // build an output TCHAR message[MAX_PATH]; _stprintf(message, _T("The baud value is %i"), baud); MessageBox(NULL, message, _T("Success"), 0); exit: RegCloseKey(key); return 0; }
ctacke
source share