/Samples/Chap01/HelloMsg/HelloMsg.d
http://github.com/AndrejMitrovic/DWinProgramming · D · 43 lines · 31 code · 8 blank · 4 comment · 0 complexity · 246e231627d7b10086c3c43f715554d1 MD5 · raw file
- /+
- + Copyright (c) Charles Petzold, 1998.
- + Ported to the D Programming Language by Andrej Mitrovic, 2011.
- +/
- module HelloMsg;
- import core.runtime;
- import std.utf;
- auto toUTF16z(S)(S s)
- {
- return toUTFz!(const(wchar)*)(s);
- }
- import core.sys.windows.windef;
- import core.sys.windows.winuser;
- extern (Windows)
- int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
- {
- int result;
- try
- {
- Runtime.initialize();
- result = myWinMain(hInstance, hPrevInstance, lpCmdLine, iCmdShow);
- Runtime.terminate();
- }
- catch (Throwable o)
- {
- MessageBox(null, o.toString().toUTF16z, "Error", MB_OK | MB_ICONEXCLAMATION);
- result = 0;
- }
- return result;
- }
- int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
- {
- MessageBox(NULL, "Hello, Windows!", "Your Application", 0);
- return 0;
- }