Custom HRESULTS 
Author Message
 Custom HRESULTS

I am thinking about defining my own custom HRESULTS using the range 0x1ff to
0xffff.  Has anyone else done this before, and do you know if it is "safe"
to do this.  I don't want to define error codes that could possibly by
overridden by Microsoft error codes.  Is there a range analagous to the
WM_USER block of message codes for HRESULTS that I can safely use for my own
error codes?
(I have seen books that recommend this and some that don't.)

Thanks.
Brian



Tue, 17 Sep 2002 03:00:00 GMT  
 Custom HRESULTS
0x200 to 0xFFFF and FACILITY_TF (4). These are the official ones and
they work (I've used them). However, beware that MS have erroneously
put the error codes for IAccessControl (which are themselves custom
HRESULTs) into winerror.h. Therefore the error reporting tools will give
misleading indication for the first several user codes. Just a nuisance,
your code will work ok, but people can get mislead... If you want to
avoid this confusion, start from 0x300 for example.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> I am thinking about defining my own custom HRESULTS using the range 0x1ff
to
> 0xffff.  Has anyone else done this before, and do you know if it is "safe"
> to do this.  I don't want to define error codes that could possibly by
> overridden by Microsoft error codes.  Is there a range analagous to the
> WM_USER block of message codes for HRESULTS that I can safely use for my
own
> error codes?
> (I have seen books that recommend this and some that don't.)

> Thanks.
> Brian



Tue, 17 Sep 2002 03:00:00 GMT  
 Custom HRESULTS
Note that the HRESULTs for connection points are also FACILITY_ITF errors
with codes in the 0x200 range...yet another reason to avoid the 0x200-0x2ff
range.

Peter Partch


Quote:
> 0x200 to 0xFFFF and FACILITY_TF (4). These are the official ones and
> they work (I've used them). However, beware that MS have erroneously
> put the error codes for IAccessControl (which are themselves custom
> HRESULTs) into winerror.h. Therefore the error reporting tools will give
> misleading indication for the first several user codes. Just a nuisance,
> your code will work ok, but people can get mislead... If you want to
> avoid this confusion, start from 0x300 for example.

> --
> =====================================
> Alexander Nickolov
> Microsoft MVP [VC], MCSD

> MVP VC FAQ: http://www.mvps.org/vcfaq
> =====================================



> > I am thinking about defining my own custom HRESULTS using the range
0x1ff
> to
> > 0xffff.  Has anyone else done this before, and do you know if it is
"safe"
> > to do this.  I don't want to define error codes that could possibly by
> > overridden by Microsoft error codes.  Is there a range analagous to the
> > WM_USER block of message codes for HRESULTS that I can safely use for my
> own
> > error codes?
> > (I have seen books that recommend this and some that don't.)

> > Thanks.
> > Brian



Tue, 17 Sep 2002 03:00:00 GMT  
 Custom HRESULTS
What's with the custom flag?
I think it means that just set this flag and you'll be able to use the hole
HRESULT range. So, you can define your own facility and error codes.

I am wrong?

Patrick


Quote:
> 0x200 to 0xFFFF and FACILITY_TF (4). These are the official ones and
> they work (I've used them). However, beware that MS have erroneously
> put the error codes for IAccessControl (which are themselves custom
> HRESULTs) into winerror.h. Therefore the error reporting tools will give
> misleading indication for the first several user codes. Just a nuisance,
> your code will work ok, but people can get mislead... If you want to
> avoid this confusion, start from 0x300 for example.

> --
> =====================================
> Alexander Nickolov
> Microsoft MVP [VC], MCSD

> MVP VC FAQ: http://www.mvps.org/vcfaq
> =====================================



> > I am thinking about defining my own custom HRESULTS using the range
0x1ff
> to
> > 0xffff.  Has anyone else done this before, and do you know if it is
"safe"
> > to do this.  I don't want to define error codes that could possibly by
> > overridden by Microsoft error codes.  Is there a range analagous to the
> > WM_USER block of message codes for HRESULTS that I can safely use for my
> own
> > error codes?
> > (I have seen books that recommend this and some that don't.)

> > Thanks.
> > Brian



Fri, 20 Sep 2002 03:00:00 GMT  
 Custom HRESULTS

Quote:
> What's with the custom flag?
> I think it means that just set this flag and you'll be able to use the
hole
> HRESULT range. So, you can define your own facility and error codes.

> I am wrong?

> Patrick

No Patrick that is the correct usage.

When I create result codes I create a .mc file (that is compiled by the
Message Compiler, mc.exe) that also contains the error text. When
compiled this outputs a header that is in the same format as
WinError.h and a .bin file that contains a binary resource that can be
linked in with your .exe or .dll.

I use the following custom build tool settings to compile the .mc file:

    mc.exe -v -c -h $(ProjDir) -e mh -r $(ProjDir) $(InputPath)

The -c switch sets the Customer bit (this is what we're looking for).

If anyone wants more info on mc.exe usage or .mc files drop me a
line.

--
Regards,

John Bates

Software Engineer
Jupiters Technology

  --------------------------------------------------------------------------
    This Message is the private opinion, suggestion or question of the
     sender and does not represent the views of Jupiters Technology.
  --------------------------------------------------------------------------



Sun, 22 Sep 2002 03:00:00 GMT  
 Custom HRESULTS
Hy John

Quote:
> If anyone wants more info on mc.exe usage or .mc files drop me a
> line.

Oh, yes please. That sounds interresting.

Patrick



Sun, 22 Sep 2002 03:00:00 GMT  
 Custom HRESULTS
John -
Can I find this somewhere in MSDN?

Quote:

>> What's with the custom flag?
>> I think it means that just set this flag and you'll be able to use the
>hole
>> HRESULT range. So, you can define your own facility and error codes.

>> I am wrong?

>> Patrick

>No Patrick that is the correct usage.

>When I create result codes I create a .mc file (that is compiled by the
>Message Compiler, mc.exe) that also contains the error text. When
>compiled this outputs a header that is in the same format as
>WinError.h and a .bin file that contains a binary resource that can be
>linked in with your .exe or .dll.

>I use the following custom build tool settings to compile the .mc file:

>    mc.exe -v -c -h $(ProjDir) -e mh -r $(ProjDir) $(InputPath)

>The -c switch sets the Customer bit (this is what we're looking for).

>If anyone wants more info on mc.exe usage or .mc files drop me a
>line.

>--
>Regards,

>John Bates

>Software Engineer
>Jupiters Technology

>  -------------------------------------------------------------------------
-
>    This Message is the private opinion, suggestion or question of the
>     sender and does not represent the views of Jupiters Technology.
>  -------------------------------------------------------------------------

-


Sun, 22 Sep 2002 03:00:00 GMT  
 Custom HRESULTS

Quote:
> John -
> Can I find this somewhere in MSDN?

Yep, search in the index for "Message Compiler" or go to:

Platform SDK
    User Interface Services
        Windows User Interface
            Resources
                MessageCompiler

These docs contain the command line usage, etc. There is a
"Sample Message Text File" topic there shows a sample file
that is very similar to what I use except that the line:

    MessageIdTypedef=DWORD

becomes

    MessageIdTypedef=HRESULT

One thing to be aware of though: if you're creating a message
table resource for use by the Windows NT Event Log and you're
also defining event categories, the category code is only a
WORD so a message with the customer bit turned on will never
be matched. In this case I recommend creating a separate
resource-only DLL that has just the category messages in it.

Again, if you need more specific info, let me know.

--
Regards,

John Bates

Software Engineer

  --------------------------------------------------------------------------
    This Message is the private opinion, suggestion or question of the
     sender and does not represent the views of Jupiters Technology.
  --------------------------------------------------------------------------



Mon, 23 Sep 2002 03:00:00 GMT  
 
 [ 8 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