module first;
import core.runtime;
import win32.windef;
import win32.winnt;
import win32.winbase;
import win32.winuser;
import win32.wingdi;
extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
int result;
void exceptionHandler(Throwable e)
{
throw e;
}
try
{
Runtime.initialize(&exceptionHandler);
result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
Runtime.terminate(&exceptionHandler);
}
catch (Throwable o) // catch any uncaught exceptions
{
MessageBox(null, cast(char *)o.toString(), "Error",
MB_OK | MB_ICONEXCLAMATION);
result = 0; // failed
}
auto res = MessageBox(NULL, "Hello!", "HelloMsg", MB_YESNOCANCEL | MB_DEFBUTTON2 | MB_ICONINFORMATION);
assert(res == IDYES); // throws if user doesn't click yes
return result;
}
int myWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
return 1;
/* ... insert user code here ... */
}