Solved

user defined HRESULT

Posted on 2003-12-08
7
1,341 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
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

733 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