PageRenderTime 24ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  1. /+
  2. + Copyright (c) Charles Petzold, 1998.
  3. + Ported to the D Programming Language by Andrej Mitrovic, 2011.
  4. +/
  5. module HelloMsg;
  6. import core.runtime;
  7. import std.utf;
  8. auto toUTF16z(S)(S s)
  9. {
  10. return toUTFz!(const(wchar)*)(s);
  11. }
  12. import core.sys.windows.windef;
  13. import core.sys.windows.winuser;
  14. extern (Windows)
  15. int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
  16. {
  17. int result;
  18. try
  19. {
  20. Runtime.initialize();
  21. result = myWinMain(hInstance, hPrevInstance, lpCmdLine, iCmdShow);
  22. Runtime.terminate();
  23. }
  24. catch (Throwable o)
  25. {
  26. MessageBox(null, o.toString().toUTF16z, "Error", MB_OK | MB_ICONEXCLAMATION);
  27. result = 0;
  28. }
  29. return result;
  30. }
  31. int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
  32. {
  33. MessageBox(NULL, "Hello, Windows!", "Your Application", 0);
  34. return 0;
  35. }