DWORD value = strtoul(searchHandleId, NULL, 16);
How to convert char that represents hex value to DWORD?
سؤال
I have a method WriteValue
that writes a DWORD
value to the registry:
const char *WriteValue(char* searchHandleId)
{
//...
DWORD value = atoi(searchHandleId); // wrong!!!
LONG result_write = RegSetValueEx(
hkey,
"hwnd_to_track",
0,
REG_DWORD,
(const BYTE*)&value,
sizeof(value)
);
//..
}
The problem is that searchHandleId
represents a hexadecimal number:
printf( "Found .... hWnd: (%s)\n", searchHandleId);
Output: Found .... hWnd: (002F1CE0)
How to convert searchHandleId
to value
(DWORD value, in my case)?
المحلول
نصائح أخرى
sscanf(searchHandleId, "%x", &value);
may help you.
لا تنتمي إلى StackOverflow