CreateProcess

Runs an external process using the CreateProcess API. CreateProcess has a number of advantages over using the RUN command including a much longer command line limit and the ability to understand long filenames correctly.

This function is a standalone function and not a member of the wwAPI class.

Note this method does not support re-routing StdOut to a file. For that purpose use CreateProcessEx.

CreateProcess(lcExe,lcCommandLine,
              lnShowWindow,llWaitForCompletion,
              lnTimeoutMs)

Return Value

.t. or .f.

Parameters

lcExe
Full path to the EXE file. You need a full path even if the file lives in the SYSTEM directory.

lcCommandLine
Optional - Command line arguments for the application.

lnShowWindow
Optional - The display mode/sizing of how the window is displayed. Uses a numeric value that comes from standard Windows API values:

SW_HIDE             0
SW_SHOWNORMAL       1
SW_NORMAL           1
SW_SHOWMINIMIZED    2
SW_SHOWMAXIMIZED    3
SW_MAXIMIZE         3
SW_SHOWNOACTIVATE   4
SW_SHOW             5
SW_MINIMIZE         6
SW_SHOWMINNOACTIVE  7
SW_SHOWNA           8
SW_RESTORE          9
SW_SHOWDEFAULT      10
SW_FORCEMINIMIZE    11
SW_MAX              11

llWaitForCompletion
If .T. waits for the process to complete before control returns back to FoxPro. Useful for applications where you need to wait for a result before continuing.

lnTimeoutMs
Optional - milliseconds before this operation is considered timed out when waiting for completion.

Example

FUNCTION SetACL(lcPath,lcUser,lcAccess,llInherit,llReplace)
LOCAL lcCommand, lcFile, lcParms

*** Strip off any trailing backslashes
IF RIGHT(lcPath,1)="\" AND LEN(lcPath) > 1
   lcPath = SUBSTR(lcPath,1,LEN(lcPath)-1)
ENDIF

lcParms = ShortPath( lcPath) 
IF llInherit
   lcParms = lcParms + " /T "
ENDIF
IF !llReplace 
   lcParms = lcParms + " /E " 
ENDIF
lcParms = lcParms + " /P " + lcUser + ":" + lcAccess



LOCAL loAPI
loAPI = CREATEOBJECT("wwAPI")
CreateProcess( loAPI.GetSystemDir() + "cacls.exe",ALLTRIM(lcParms),0,.T.,5000)


See also:

Class wwAPI

© West Wind Technologies, 1996-2024 • Updated: 04/21/19
Comment or report problem with topic