# Character mode applications

Compiling console-mode Win32 programs:

>> Sample Code: \rsxnt\sample\console\excpt

RSXIDE

Console programs can use the whole Win32 API. This application cannot run under DOS or Win3.1 with Win32s (but RSXIDE can run RSXNT console apps).

The -Zwin32 switch links the default libraries KERNEL32, USER32 and GDI32 to the application.

Compile command:

        gcc -Zwin32 argvenv.c

Compiling dual-mode Win32 programs:

>> Sample Code: \rsxnt\sample\console\argvenv

RSXIDE

Dual-mode programs should only use the C-library. This Win32 console application can also run under 32-bit DOS (DPMI) and RSXWIN. You can only use the Win32 API, if you check that the program runs under the Win32 environment.

Try to run the three environments (example findfirst):

a) `argvenv`

b) RSX `argvenv`

c) RSXWIN `argvenv`

Compile command (without win32 kernel functions):

`gcc -Zrsx32 argvenv.c`

Compile command (with win32 kernel functions):

`gcc -Zrsx32 argvenv.c -lkernel32`

Example to examine runtime system:

    #define BIT_RSX     0x1000L

    static void print_version(void)
    {
      if (_emx_env & BIT_RSX) { // RSX** found
        int rsx_exe = _emx_rev >> 16;
        int rsx_ver = _emx_rev & 0xFFFF;
        char *system;

        if (rsx_exe == 0)
          system = "RSX";
        else if (rsx_exe == 1)
          system = "RSXWIN";
        else if (rsx_exe == 2) {
          system = "RSXNT";   // WIN32 API calls allowed
    printf("winver = %lX\n", GetVersion()&0xffff);
    }
        else
          system = "Unknown";

        printf("%s version: %X.%02X\n",
            system, rsx_ver>>8, rsx_ver&0xFF);

    } else
        printf("EMX , revision %X\n", emx_rev);
    }