On Monday, 18 May 2020 at 17:51:54 UTC, BoQsc wrote:
On Monday, 18 May 2020 at 17:20:17 UTC, BoQsc wrote:
It would be great if we could change/customise the icon of the Command line application that run the HelloWorld application. But I have a bad feeling that it is probably not possible without a GUI library.

Forever thankful to Adam D. Ruppe
It is possible to embed icon into the Windows executable.
The Original Adam's thread: https://forum.dlang.org/post/enrmidvsfdugqmudo...@forum.dlang.org

The instructions:
Download a valid Windows 3.0 icon resource
Examples: http://files.alexmeub.com.s3.amazonaws.com/other/win98_icons.zip

Download the tools to embed the Icon for the .exe executable.
http://ftp.digitalmars.com/bup.zip

Create a new text file named whatever.rc with the content similar to this:

IDI_ICON1       ICON    DISCARDABLE     "iconfil.ico"

Use rcc.exe tool and whatever.rc file to generate whatever.res file.
rcc.exe whatever.rc

Use dmd.exe compiler to embed newly created whatever.res file into your .exe file while compiling:
dmd.exe whatever.res

You should see that the newly compiled .exe file is now with an Icon.
And when launched the icon will be used by the Command Prompt.

Also, if you want some kind of Fancy ASCII art in your application:

Look at the Google for any ASCII Art generator: http://patorjk.com/software/taag/#p=display&f=Elite&t=Hello%20World

Add this line and insert your ASCII art in a writeln function.
executeShell("chcp 65001");
to your D language program source code

More about chcp can be found here: https://ss64.com/nt/chcp.html
Or here: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/chcp


import std.stdio   : write, writeln, readln;
import std.process : executeShell;
void main() {
        executeShell("title HelloWorld");
        executeShell("chcp 65001");
        writeln("Hello, World!");
        writeln("
 ▄ .▄▄▄▄ .▄▄▌  ▄▄▌            ▄▄▌ ▐ ▄▌      ▄▄▄  ▄▄▌  ·▄▄▄▄
██▪▐█▀▄.▀·██•  ██•  ▪         ██· █▌▐█▪     ▀▄ █·██•  ██▪ ██
██▀▐█▐▀▀▪▄██▪  ██▪   ▄█▀▄     ██▪▐█▐▐▌ ▄█▀▄ ▐▀▀▄ ██▪  ▐█· ▐█▌
██▌▐▀▐█▄▄▌▐█▌▐▌▐█▌▐▌▐█▌.▐▌    ▐█▌██▐█▌▐█▌.▐▌▐█•█▌▐█▌▐▌██. ██
▀▀▀ · ▀▀▀ .▀▀▀ .▀▀▀  ▀█▄▀▪     ▀▀▀▀ ▀▪ ▀█▄▀▪.▀  ▀.▀▀▀ ▀▀▀▀▀•

");


        string line;
        while ((line = readln()) !is null)
                write(line);
}

Reply via email to