Solved

Conventions for function success definitions

Posted on 2003-12-03
4
176 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 500 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

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

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 168
if loop in java 3 160
isEverywhere  challenge 19 85
Making an alias 7 110
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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

685 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