Question

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)?

Was it helpful?

Solution

DWORD value = strtoul(searchHandleId, NULL, 16);

OTHER TIPS

sscanf(searchHandleId, "%x", &value);

may help you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top