I have a string with a hexadecimal number (for example, 0xb0844):

String h; 

And a variable of type HWND:

 HWND h1; 

Question: How can I convert the string to the HWND handle?

Further I use

 SetForegroundWindow(h1); 

    1 answer 1

    So for example:

     if(1 != ::std::sscanf(text.c_str(), "0x%zx", ::std::addressof(handle))) { throw ::std::runtime_error{"bad value"}; }