I have a need to pass in an HRESULT value to a program as a command line argument. I had intended to do so by passing the hex value, e.g.:
>receiver.exe 0x80048836
I'm trying to convert this string representation back into an HRESULT using wcstol
, eg:
HRESULT hr = wcstol(argv[2], NULL, 16);
However, the value of the original HRESULT is usually greater than LONG_MAX
, so in the line above hr
ends up as 0x7fffffff
.
So, two questions:
I thought HRESULTS were just 32-bit integers? So I'm not sure how I'm getting back an HRESULT greater than
LONG_MAX
. It seems to work fine in the originating program, though (i.e. the HRESULT doesn't overflow).Is there a way to get around the
LONG_MAX
restriction ofwcstol
? Maybe another version of the function that matches up with whatever size integer the HRESULT actually is?
Thanks!