zondag 23 april 2023

Small .exe for Hello World example in C

#include <windows.h>
#include <string.h>

int mainCRTStartup(void) {

    char str[] = "Hello World!";

    DWORD dummy;
    WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), (const void*)str, strlen(str), &dummy, NULL);

    ExitProcess(0);
}


In Visual Studio 2022:
> Go to Release Mode.
> Go to the properties of the project
> Go to C/C++ / Code Generation / Security Check : Disable Security Check (GS-)
> Go to C/C++ / Ouput Files / Assembler Output : Assembly; Machine Code and Source
> Go to Linker / Input / Ignore All Default Libraries : Yes (/NODEFAULTLIB)

The resulting .exe will be 3584 bytes.

maandag 17 april 2023

Lightweight Java installation on Windows

 Go to https://www.oracle.com/nl/java/technologies/downloads/ to download the JDK 2.0 x64 Compressed Archive

Unzip it in c:\prg\java\jdk20

Go to "This PC" and click "Advanced System Settings". Go to "Environment Variables..."

In System variables, create a variable JAVA_HOME with content C:\prg\java\jdk-20

In System variables, create a variable CLASSPATH with content C:\prg\java\antlr\antlr-4.12.0-complete.jar;%CLASSPATH%

In System variables edit the Path variable and add C:\prg\java\jdk-20\bin