Solved

Conventions for function success definitions

Posted on 2003-12-03
4
179 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
[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
  • 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tab names are off by one 5 54
post4 challenge 28 122
EvenOdd challenge 10 160
matchUp  challenge 9 134
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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