Groups | Blog | Home
all groups > dotnet faqs > october 2005 >

dotnet faqs : Using Winerror.h in C#


Lady_A
10/16/2005 12:00:00 AM
Hi,

I would like to use one of the error codes defined in WinError.h.
There is no iclude anymore.
I have put in "using System.Runtime.InteropServices" and the compiler
still doesn't recognize the error code.
There must be some way, other than defining it by myself...

Anybody ?

Gary K
10/16/2005 12:00:00 AM
On Mon, 17 Oct 2005 02:59:53 +0000, "Lady_A" <alevich@wavesys.com>
[quoted text, click to view]

Greetings & Salutations,

Sorry but you will have to define it yourself.

From my understanding, C# (and other .NET languages) are not meant to
refer to the Windows API in any 'normal' way.

This isn't too hard though (but still time consuming if you want to do
all the errors). Just write a sealed class with the error code
constants in it. Then you can refer to it in code as
WinError.ERR_CODE.

public sealed class WinError {
public const int ERR_CODE = <errnum>;
}

Although if you use the SUCCESS/FAILED macros, you will have to write
these into code. Maybe as static methods of the sealed class?

If you're lucky, someone has already done this work and posted it
somewhere on the net.

Jason Newell
10/16/2005 10:36:24 PM
Download http://www.paulyao.com/pinvoke and save yourself a ton of effort.

Jason Newell


[quoted text, click to view]
AddThis Social Bookmark Button