WinExec Function

Purpose

Loads and runs a program.

Syntax

% = WinExec(file, CmdShow)( function)

WinExec file, CmdShow( command)

file:sexp
CmdShow:iexp

Description

The WinExec(file, CmdShow) function invokes program file.

The file expression contains the name of the called program. The program name includes the full pathname and the command line which is inserted in the program segment prefix of the called program.

CmdShow specifies the visual aspect of the window and is one of the SW_ constants SW_NORMAL, SW_HIDE, SW_SHOW, .... See ShowW.

Example

Global a%

If Exist(WinDir + "\notepad.exe")

a% = WinExec(WinDir + "\notepad.exe", SW_NORMAL)

Message "return value: " & Format(a%)

Else

Message "Program not found"

EndIf

Do

Sleep

Until Me Is Nothing

Remarks

If you want to determine, if the called program is still active or not, you must use System instead, which returns the handle of the process and allows controlling it. Also, System allows, by using the parameter Wait, to wait until the program has finished.

See Also

Shell, ShellExec, System, WinExec

{Created by Sjouke Hamstra; Last updated: 25/10/2014 by James Gaite}