On Mon, 17 Oct 2005 02:59:53 +0000, "Lady_A" <al*****@wavesys.com>
wrote:
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 ?
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.
Gary K