Windows 7 x64. Prevent appearing of console with GUI application
Mike Franklin
slavo5150 at yahoo.com
Tue Jul 24 08:48:54 UTC 2018
On Tuesday, 24 July 2018 at 08:09:33 UTC, ANtlord wrote:
> So... how prevent appearing of console on the startup of the
> application?
Here's my test
---
module HelloMsg;
import core.runtime;
import std.utf;
import core.sys.windows.windows;
auto toUTF16z(S)(S s)
{
return toUTFz!(const(wchar)*)(s);
}
extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int iCmdShow)
{
int result;
void exceptionHandler(Throwable e) { throw e; }
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;
}
---
dmd -L/SUBSYSTEM:WINDOWS main.d
main.obj : error LNK2019: unresolved external symbol MessageBoxW
referenced in function WinMain
dmd -L/SUBSYSTEM:WINDOWS main.d User32.lib
Success!
Executing from PowerShell: no console
Executing from Command Prompt: no console
Double-clicking in Explorer: no console
Windows 10 64-bit
Mike
More information about the Digitalmars-d-learn
mailing list