Solved

Conventions for function success definitions

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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

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 …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

635 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