Вопрос

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

Это было полезно?

Решение

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

Другие советы

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

may help you.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top