Table of Contents
This is part of Win16 API which allow to create versions of program from one source code to run under OS/2 and Win16. Under OS/2 program can be running under Win-OS/2 if program is Windows NE executable, and with help on Windows Libraries for OS/2, if it is OS/2 NE executable. Here is a WLO to OS/2 API mapping draft
InitApp
Brief
The InitApp function creates the application message queue and installs essential application-support routines. These include a signal procedure, version-specific resource loaders, and a divide-by-zero interrupt handler.
Syntax
BOOL WINAPI InitApp(HANDLE hInstance);
Parameters
- hInstance — Handle to the task to be initialized. This value must be the instance handle returned in the `DI` register by the preceding `InitTask` call.
Return Code
Returns nonzero in the `AX` register if successful. If the function fails, it returns zero, and the application must exit immediately.
Notes
- Because this function creates the message queue, failure to call it (or calling out of sequence) will result in an application that cannot receive messages.
Example Code
C Binding
/* Declaration of InitApp (often not included in windows.h) */ extern WINAPI InitApp(HANDLE hInstance); int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { /* InitApp is typically called in the startup code before WinMain. If you are writing custom startup code, call it as shown: */ if (!InitApp(hInstance)) { /* Critical error: message queue could not be created */ return 1; } /* ... application code ... */ return 0; }
MASM Binding
; Standard startup fragment (after InitTask and WaitEvent) externFP InitApp ; declare far external push di ; hInstance from InitTask (DI register) call far InitApp ; create message queue & install handlers or ax, ax ; test return value jz noinit ; jump if initialization failed ; ... proceed to call WinMain ... noinit: mov al, 0FFh ; return error code mov ah, 4Ch int 21h




