Could you, please, help me to understand, why code:

////////////////
import std.c.windows.windows;
import std.exception: ErrnoException;
import std.stdio: writefln;
import std.string: toStringz;

void main ()
{
CreateFileA(toStringz("nonexisting file name"), GENERIC_READ, FILE_SHARE_READ, null, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, null);
  auto ex = new ErrnoException("CreateFileA");
writefln("ex.errno=%d, ex.msg=%s, lasterror=%d", ex.errno, ex.msg, GetLastError());
}
////////////////

prints:
ex.errno=0, ex.msg=CreateFileA (No error), lasterror=2

I wanted it will be:
ex.errno=2, ex.msg=CreateFileA (File not found), lasterror=2

Reply via email to