# Creating your first app

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:

```javascript
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.

```javascript
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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://windows96.gitbook.io/dev-docs/getting-started/creating-your-first-app.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
