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)
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.
lcStartDirectory
Optional - The directory that the application runs out of. Don't pass to use the current directory.
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.
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
*** Use CreateProcessEx if wwIPStuff is available
*** so we don't get flashing DOS Windows
LOCAL oAPI
oAPI = CREATEOBJECT("wwAPI")
CreateProcessEx( oAPI.GetSystemDir() + "cacls.exe",ALLTRIM(lcParms),,0,.t.)
ELSE
lcCommand = "RUN Cacls.exe "
lcCommand = lcCommand + " " + lcParms + " > cacls.txt"
&lcCommand
ENDIF
See also:
Class wwAPI© West Wind Technologies, 2004-2017 • Updated: 08/05/07
Comment or report problem with topic