Solved

user defined HRESULT

Posted on 2003-12-08
7
1,344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…
Simple Linear Regression

622 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