Creating your first app

Learn how to create your first Windows 96 app here.

Creating a Windows 96 app is not as complicated as you may think.

There are two types of applications you can write; a preloaded application on startup, or a sysbin/userbin contained in c:/system/local/bin. Both are perfectly valid ways of writing an application, but there are some key differences you must note. The former is easier to write than the latter, so this "Getting Started" tutorial will only focus on those.

Before starting, please read all documents in the "INFORMATION" section of these Dev docs to ensure you know what to expect.

Creating the file

To create an application, you need to create a file for it in c:/system/boot/apps. Any JS files in here are loaded on boot, so any code inside will also be executed on boot.

To get started, create a file called c:/system/boot/apps/hello-world.js. You may then double-click to open it, or you can open your favorite editor and edit it there instead.

Defining a simple app

Almost all applications in Windows 96 inherit w96.WApplication, which is the base class for all app instances. The purpose of this class is to simplify resource management for applications (e.g. destroying all windows on app closure, releasing Blobs from memory, etc.).

Here is a simple application which you can put inside your JS file:

const { register } = w96.app;
const { Theme } = w96.ui;

class TestApplication extends WApplication {
    constructor() {
        super();
    }
    
    async main(argv) {
        super.main(argv);
        
        const mainwnd = this.createWindow({
            title: "My Application",
            icon: Theme.getIconUrl("exec", "small"),
            initialHeight: 400,
            initialWidth: 640,
            body: "very cool text",
            bodyClass: "very-cool-app",
            center: true,
            taskbar: true
        }, true); // true specifies that this is an app window (main window)
        
        mainwnd.show();
    }
}

register({
    command: "test-app",
    type: "gui",
    cls: TestApplication,
    meta: {
        icon: Theme.getIconUrl("exec"),
        friendlyName: "Test Application"
    }
});

Loading the app

To load the app, simply reboot your Windows 96 installation to load it.

The reason for this mechanism is because the app files are loaded on boot. If you want to avoid this, you should probably make a bin instead. Note that a bin has a different method of execution than a regular app and doesn't load anything on startup. Choose wisely for the type of application you're aiming to build.

Executing the app

To execute this app, you need to call its command. The command for this app is test-app, which was passed to the register function near the end of this example.

To execute it, open a Run prompt via the start menu and type its command. You can also use the terminal to execute this app.

By default, this app doesn't create a shortcut for itself. This is normal, shortcuts should be provided as part of the distribution method and not by the app. If you still want to create a shortcut, however, you can add this to the end of the file. Please note that this will execute every reboot, which might annoy some users and is just bad practice in general.

u96.shell.mkShortcut("c:/system/programs/Other/Test.link", "empty", "test-app")

You can also create shortcuts straight from the desktop, by right clicking and pressing New Shortcut.

Creating a start menu item

To create a start menu item, follow the steps above to create a shortcut. Then, place your shortcut anywhere in c:/system/programs to make it appear in the start menu.

Last updated