Solved

Conventions for function success definitions

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

705 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

12 Experts available now in Live!

Get 1:1 Help Now