Solved

user defined HRESULT

Posted on 2003-12-08
7
1,339 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:tetsuo
  • 4
  • 3
7 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 9898343
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
 

Author Comment

by:tetsuo
ID: 9898690
what's with the L at the end?

_ryan
0
 

Author Comment

by:tetsuo
ID: 9898714
the value i intend to use will indicate success, so the high order byte will be 0x00 not 0x80.

_ryan
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 22

Accepted Solution

by:
cookre earned 250 total points
ID: 9898831
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
 
LVL 22

Expert Comment

by:cookre
ID: 9898894
0
 

Author Comment

by:tetsuo
ID: 9899173
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
 
LVL 22

Expert Comment

by:cookre
ID: 9899374
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

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question