Solved

user defined HRESULT

Posted on 2003-12-08
7
1,332 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now