Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Conventions for function success definitions

Posted on 2003-12-03
4
Medium Priority
?
184 Views
Last Modified: 2013-11-20
I was hoping someone would be able to fill me in on the proper way to define success codes similar to S_OK and S_FALSE. I created my own definitions as shown below in MyApp.h
 
#define DEBUG_MODE ((HRESULT)0x00000040L)
#define S_FOUND ((HRESULT)0x00000050L)
#define S_EMPTY ((HRESULT)0x00000060L)
 
I simply copied the definition for S_OK and modified the name and number which seems amateurish at best. How should I do this properly?

Many thanks,
Will
www.wjdashwood.co.uk
0
Comment
Question by:wjdashwood
  • 2
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
Dexstar earned 2000 total points
ID: 9868589
@wjdashwood:

> I simply copied the definition for S_OK and modified the name and number which
> seems amateurish at best. How should I do this properly?

You should use the macro "MAKE_HRESULT".  Here is the documentation:
     http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/cmf_m2z_67sk.asp

For your custom results, you should use the facility "FACILITY_ITF" which is reserved for custom interfaces.  Then, use "SEVERITY_SUCCESS" to indicate success.  The final parameter can be anything that you want.

     #define S_FOUND MAKE_HRESULT(SEVERITY_SUCCESS, FACILITITY_ITF, 0x50)
     #define S_EMPTY MAKE_HRESULT(SEVERITY_SUCCESS, FACILITITY_ITF, 0x60)

That's the "proper" way to do it.


Hope That Helps,
Dex*
0
 

Author Comment

by:wjdashwood
ID: 9868661
Cheers for the info, I'll have some tea and look deeper into it later.
 
Many thanks,
Will
0
 

Author Comment

by:wjdashwood
ID: 9884049
Cheers, that worked perfectly except FACILITITY_ITF should be FACILITY_ITF ;)

Thanks again,
Will
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9884132
Heh...  Spelling was never my forté.  I even spelled it right the first time I mentioned it...  Oh, well...  Glad you got it working...

Dex*
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Integration Management Part 2
Suggested Courses

927 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