HRESULT should be subclass of DWORD?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

HRESULT should be subclass of DWORD?

Eric Winger-4
Dolphin has HRESULT's defined as a subclass of SDWORD. I question
whether this should instead be a subclass of DWORD.

Here's an example pulled from a .tlb file in an OPC spec.

"(HRESULT)0xC0040008L"

Translating to ST you get 16rC0040008. This requires 32 bits to store
and (as far as I know) is not signed. Thus when you do a

HRESULT fromInteger: 16rC0040008

it walks back with a "can't hold 3221487624" error. But yet we believe
this a valid HRESULT.

Any recommendations?

Eric


Reply | Threaded
Open this post in threaded view
|

Re: HRESULT should be subclass of DWORD?

Blair McGlashan
Eric

"Eric Winger" <[hidden email]> wrote in message
news:[hidden email]...
> Dolphin has HRESULT's defined as a subclass of SDWORD. I question
> whether this should instead be a subclass of DWORD.

 From "winnt.h"

typedef long LONG;
...
typedef LONG HRESULT;

i.e. HRESULT is a 32-bit signed integer. I'd guess that the reason it is
signed is so that all HRESULT error codes are negative (they have the top
bit set) and all HRESULT success codes are positive. This has a certain
convenience.

>
> Here's an example pulled from a .tlb file in an OPC spec.
>
> "(HRESULT)0xC0040008L"

Well the "(HRESULT)" bit is casting the unsigned 32-bit value to a signed
long.

>
> Translating to ST you get 16rC0040008. This requires 32 bits to store
> and (as far as I know) is not signed. Thus when you do a
>
> HRESULT fromInteger: 16rC0040008
>
> it walks back with a "can't hold 3221487624" error. But yet we believe
> this a valid HRESULT.
>
> Any recommendations?

HRESULT fromUnsignedInteger: 16rC0040008

Regards

Blair