PBMAIN function

Purpose

PBMAIN is a user-defined function called by Windows to begin running an executable application.  Every PowerBASIC executable (EXE) must contain either a PBMAIN or a WINMAIN function.

Syntax

FUNCTION PBMAIN [()] [AS LONG]

Remarks

Either a PBMAIN or WINMAIN function is required in every PowerBASIC application (.EXE).  If you use PBMAIN, no parameters are passed, and you cannot directly obtain the instance handle of your application or the pointer  to any command-line parameters.

However, you can use COMMAND$ to get the command-line passed to your program, and the GetModuleHandle API function to get the application instance handle.

Return

The return value of PBMAIN has an effective range of 0 to 255. Batch files may act on the result through the IF [NOT] ERRORLEVEL batch command.

See also

COMMAND$, WINMAIN

Example

#COMPILE EXE

FUNCTION PBMAIN

  PRINT "This is my program!"

  'Return an error level of 15

  FUNCTION = 15  ' or you can use PBMAIN = 15

END FUNCTION