I'll try to read com port value from the register with following code.
I don't get a value , could somebody help?
--------------------------
Code:
HKEY myKey;
BYTE* valData;
DWORD valDataSize;
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\SERIALCOMM\0", 0, KEY_QUERY_VALUE, &myKey)
!= ERROR_SUCCESS)
{
printf ("\nCould not open key.");
}
valData = (BYTE*)malloc (4);
valDataSize = 1024;
if (RegQueryValueEx (myKey, "Device\\Serial0\0", NULL, NULL, valData, &valDataSize)
!= ERROR_SUCCESS)
{
printf ("\nCould not query integer value.");
}
printf("\nHistoryListLength: %d", *valData);
if (RegQueryValueEx (myKey, "Device\\Serial0\0", NULL, NULL, NULL, &valDataSize)
!= ERROR_SUCCESS)
{
printf ("\nCould not query string size.");
}
valData = (BYTE*)realloc (valData, valDataSize);
if (RegQueryValueEx (myKey, "Device\\Serial0\0", NULL, NULL, valData, &valDataSize)
!= ERROR_SUCCESS)
{
printf ("\nCould not query string value.");
}
printf ("\nUserName: %s", valData);
free (valData);
RegCloseKey (myKey);