user defined HRESULT

i would like to return a custom user-defined hresult from a COM interface method.  how could i define one so that it doesn't conflict with any existing predifined hresult values?

_ryan
tetsuoAsked:
Who is Participating?
 
cookreCommented:
The L is used to say it's a long.

Since everybody uses 0 to indicate success, I don't see why you couldn't use that, too.

If, however, you awnt an unused non-zero value, you can look in winerror.h - there are lots of holes all throughout.  To restrict yourself to one whose high-order word is zero, everything from 0x00006009L through 0x0000ffffL is available.

To avoid one that may come into use in the future, I'd pick something like 0x00007e2bL.


0
 
cookreCommented:
Considering it unsigned, the highest ones have a high-order byte of 0x80, so if any you produce start with 0x81 there shouldn't be any conflict.

E.g.:
0x81000001L
0
 
tetsuoAuthor Commented:
what's with the L at the end?

_ryan
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
tetsuoAuthor Commented:
the value i intend to use will indicate success, so the high order byte will be 0x00 not 0x80.

_ryan
0
 
tetsuoAuthor Commented:
cookre,
    wow those lists are great!  i have looked into winerror.h and decided to create my own unique FACILITY code, that way i can use whatever value i want for the CODE field of the HRESULT.  your information has been helpful and i thank your for your quick responses!  i'm glad i can still ask questions without having to subscribe to premium services...

_ryan
0
 
cookreCommented:
If you can get 3,000 points per month, Premium Service is free, otherwise those 5 points a day (or whatever it is) can get burned up quck.  If you have unlimited points, shhh,, don't tell anybody.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.