Custom HRESULTs 
Author Message
 Custom HRESULTs

I am a beginner at COM and ATL stuff. I want to write a test COM
server that will do some work. Each method is supposed to return a
HRESULT. Now, the question is whether I can make my own custom
HRESULTs? How can I associate appropriate message texts with my custom
HRESULTs so that FormatMessage() Win32 function returns them from
within any application? Is this at all possible? Thanks.

Mike



Thu, 13 Mar 2003 03:00:00 GMT  
 Custom HRESULTs
You cannot *just* make custom hresults and expect FormatMessage() to get the
values.
For that to work.
1. Create custom HRESULTs. To do that MAKE_HRESULT() with FACILITY_ITF..
2. Create a resource dll which maps that to a description. To do that use
MC.exe (Message compiler). I think it comes with platform SDK.
3. When you call FormatMessage, you need to pass in that dll too..

Better option might be to just use IErrorInfo.. Just use
CComCoClass::Error() and pass the description from there..

--
Girish Bharadwaj

Quote:
> I am a beginner at COM and ATL stuff. I want to write a test COM
> server that will do some work. Each method is supposed to return a
> HRESULT. Now, the question is whether I can make my own custom
> HRESULTs? How can I associate appropriate message texts with my custom
> HRESULTs so that FormatMessage() Win32 function returns them from
> within any application? Is this at all possible? Thanks.

> Mike



Sat, 15 Mar 2003 03:00:00 GMT  
 Custom HRESULTs

Quote:

>You cannot *just* make custom hresults and expect FormatMessage() to get the
>values.
>For that to work.
>1. Create custom HRESULTs. To do that MAKE_HRESULT() with FACILITY_ITF..
>2. Create a resource dll which maps that to a description. To do that use
>MC.exe (Message compiler). I think it comes with platform SDK.
>3. When you call FormatMessage, you need to pass in that dll too..

>Better option might be to just use IErrorInfo.. Just use
>CComCoClass::Error() and pass the description from there..

Thanks! That's exactly what I've been looking for. Great help.

Mike



Sat, 15 Mar 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. custom HRESULT in MSSOAP toolkit revisited.

2. custom HRESULT decoding to error message

3. Custom HRESULTs question.

4. Custom HRESULTS

5. problem with custom HRESULTS

6. Unable to add custom C# control to a form - Exception from HRESULT: 0x80131019

7. ATL and custom "static HRESULT WINAPI UpdateRegistry(BOOL bRegister)"

8. HOWTO : Design-time custom collection editing for custom control

9. Custom build commands for custom file types

10. Problem with custom template files in VC5 custom AppWizards

11. Problem with custom template files in VC5 custom AppWizards

12. Custom Appwizard how to custom Lib and Include?

 

 
Powered by phpBB® Forum Software