On Sunday, 1 March 2015 at 16:39:29 UTC, novice2 wrote:
I wanted it will be:
ex.errno=2, ex.msg=CreateFileA (File not found), lasterror=2

Here's the right way to do this:

////////////////////////// test.d //////////////////////////
import std.c.windows.windows;
import std.string : toStringz;
import std.windows.syserror : wenforce;

void main ()
{
    auto handle = CreateFileA(toStringz("nonexisting"),
        GENERIC_READ, FILE_SHARE_READ, null, OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL,
        null);
    wenforce(handle != INVALID_HANDLE_VALUE, "CreateFileA");
}
////////////////////////////////////////////////////////////

See std.windows.syserror for more information.

Reply via email to