Prueba con esto, haber si te funciona:
Function LaunchAppAndWait
Lparameters tcCommandLine, tuFromDir, tcWindowMode
* tcCommandLine (R) - command line to launch
* tuFromDir (O) - Run from directory (default - CWD)
* tcWindowMode (O) - Start Application Window mode, one of (HIDE, MIN, MAX, NOR)
* (default - default setting of application)
* Returns:
* 0 = CreateProcess didn't start what was asked
* 1 = Process ran to completion
* -1= Process started but user aborted wait. Danger - app is still running AFAIK
#Define cnINFINITE 0xFFFFFFFF
#Define cnHalfASecond 500 && milliseconds
#Define cnTimedOut 0x0102
* We need some API calls, declare here
* GetCurrentProcess() returns the pseudohandle of the current process
Declare INTEGER GetCurrentProcess IN WIN32API AS GetCurrProc
* WaitForIdleInput() waits until the target process is idle for input
Declare INTEGER WaitForInputIdle IN WIN32API AS WaitInpIdle ;
INTEGER nProcessHandle, ;
INTEGER nWaitForDuration
* WaitForSingleObject() waits until the handle in parm 1 is signalled
* or the timeout period expires
Declare INTEGER WaitForSingleObject IN WIN32API AS WaitOnAppExit ;
INTEGER hProcessHandle, ;
INTEGER dwTimeOut
* This API call does the work. The parameters are as follows:
* lpszModuleName - ptr-> file name of module to execute. Since we aren't launching .CPLs, do not use
* lpszCommandLine - ptr-> command to execute, as passed to us
* lpSecurityAttributesProcess - ptr-> SECURITY_ATTRIBUTES structure for Process. Pass a null pointer
* lpSecurityAttributesThread - ptr-> SECURITY_ATTRIBUTES structure for first thread. Pass a null pointer
* bInheritHandles - whether or not chlid inherits parent handles. Since no SECURITY_ATTRIBUTES passed, default to FALSE
* dwCreateFlags - Process Creation Mode flag set. We use the default mode at normal priority, ie 0
* lpvEnvironment - ptr-> a set of environment strings as if a MULTI_SZ. We don't set, so pass a null pointer
* lpszStartupDir - ptr-> the starting directory. If none provided to us, pass a null pointer
* lpStartInfo - ptr-> a STARTUPINFO structure. We use one structure member at times.
* lpProcessInfo - ptr-> a PROCESS_INFORMATION structure, used to return PID/PHANDLE detail.
* We use one member on return
Declare SHORT CreateProcess IN WIN32API AS CrPr ;
STRING lpszModuleName, ;
STRING @lpszCommandLine, ;
STRING lpSecurityAttributesProcess, ;
STRING lpSecurityAttributesThread, ;
SHORT bInheritHandles, ;
INTEGER dwCreateFlags, ;
STRING lpvEnvironment, ;
STRING lpszStartupDir, ;
STRING @lpStartInfo, ;
STRING @lpProcessInfo
If TYPE('tcCommandLine') # 'C'
* Command line must be a character string
Return 0
Endif
If TYPE('tuFromDir') # 'C'
* If not a character string, pass a null pointer, defaulting to Current Working Dir
tuFromDir = 0
Else
* Otherwise, null pad the string
tuFromDir = tuFromDir + CHR(0)
Endif
If TYPE('tcWindowMode') # 'C'
* If not passed, set to null string
tcWindowMode = ''
Else
* Translate the passed window mode to uppercase
tcWindowMode = UPPER(tcWindowMode)
Endif
Local nStartedProcessHandle, uResult, cProcessInfo, cStartUpInfo
* Make default Structures for the CreateProcess call
*
* ProcessInfo - 4 bytes, a Process handle, a Thread Handle, a (DWORD) ProcessId and a (DWORD) ThreadID
* we save the Process handle and return it to caller in tnReturnProcessHandle
cProcessInfo = REPL(CHR(0),16)
* StartUpInfo is a 68 byte long complex structure; we either have 68 bytes with a cb member (byte 1) 68
* or with cb of 68, dwFlag low order byte (byte 45) of 1, and low order byte wShowWindow (byte 49) set to
* the SW_ value appropriate for the Window Mode desired.
Do CASE
Case tcWindowMode = 'HIDE'
* Hide - use STARTF_USESHOWFLAG and value of 0
cStartUpInfo = CHR(68) + ;
REPL(CHR(0),43) + ;
CHR(1) + ;
REPL(CHR(0),23)
Case tcWindowMode = 'NOR'
* Normal - use STARTF_USESHOWFLAG and value of 1
cStartUpInfo = CHR(68) + ;
REPL(CHR(0),43) + ;
CHR(1) + ;
REPL(CHR(0),3) + ;
CHR(1) + ;
REPL(CHR(0),19)
Case tcWindowMode = 'MIN'
* Minimize - use STARTF_USESHOWFLAG and value of 2
cStartUpInfo = CHR(68) + ;
REPL(CHR(0),43) + ;
CHR(1) + ;
REPL(CHR(0),3) + ;
CHR(2) + ;
REPL(CHR(0),19)
Case tcWindowMode = 'MAX'
* Maximize - use STARTF_USESHOWFLAG and value of 3
cStartUpInfo = CHR(68) + ;
REPL(CHR(0),43) + ;
CHR(1) + ;
REPL(CHR(0),3) + ;
CHR(3) + ;
REPL(CHR(0),19)
* Other options exist - see WINBASE.H for values
Otherwise
* Use default of application
cStartUpInfo = CHR(68) + REPL(CHR(0),67)
Endcase
* Do it now!
uResult = CrPr( 0, ;
tcCommandLine, ;
0, 0, 0, 0, 0, ;
tuFromDir, ;
@cStartUpInfo, ;
@cProcessInfo)
If uResult = 1
* CreateProcess() started our app, but we have to wait until it finishes loading
* Strip the process handle from the PROCESS_INFORMATION structure
nStartedProcessHandle = (((ASC(SUBST(cProcessInfo,4,1))*256) + ;
ASC(SUBST(cProcessInfo,3,1)))*256 + ;
ASC(SUBST(cProcessInfo,2,1)))*256 + ;
ASC(LEFT(cProcessInfo,1))
* It's been launched; wait until we're idling along
=WaitInpIdle(GetCurrProc(),cnINFINITE)
* As long as the other process exists, wait for it
Do WHILE WaitOnAppExit(nStartedProcessHandle, cnHalfASecond) = cnTimedOut
* Give us an out in case the other app hangs - lets the user quit via
If INKEY() = 27
* Still running but we aren't waiting - return a -1 as a warning
uResult = -1
Exit
Endif
Enddo
Else
* Return 0 to indicate failure
uResult = 0
Endif
Return uResult
*****************************************+
Suerte
______________________________________________
Carlos Omar Figueroa López
Servidores Dedicados Windows desde $ 4 USD / dia
oTestRun = NEWOBJECT("api_apprun", "Process.vcx")
oTestRun.icCommandLine = "NotePad.EXE"
* oTestRun.icLaunchDir = "c:\test\"
* oTestRun.icWindowMode = "MAX"
oTestRun.LaunchAppAndWait()
** or oTestRun.LaunchApp()
Saludos,
Pancho
Córdoba
Argentina
|
CLEAR sCmd = "7za a test1 *.prg" ? sCmd, RunModal(sCmd) && > 0 sCmd = "7za a test1 nonexistentfile.xxx" ? sCmd, RunModal(sCmd) && > 1 RETURN * Ejecuta un comando externo de forma modal y opcionalmente en un directorio distinto * sCmd : Pathname completo del archivo a ejecutar seguido de sus parámetros (ej: E:\UTILES\PKZIP.EXE -ex& Prueba.zip) * sDir (opcional) : directorio desde el que se ejecuta el comando * nShow : 0=No muestra, 1=Muestra ejecución, cierra automáticamente FUNCTION RunModal (sCmd, sDir, nShow) LOCAL sStartProcBuf, sProcInfoBuf, nFlags, nRet, nhProc IF EMPTY(nShow) nShow = 1 ENDIF #DEFINE NORMAL_PRIORITY_CLASS 32 #DEFINE IDLE_PRIORITY_CLASS 64 #DEFINE HIGH_PRIORITY_CLASS 128 #DEFINE REALTIME_PRIORITY_CLASS 1600 * Return code from WaitForSingleObject() if * it timed out. #DEFINE WAIT_TIMEOUT 0x00000102 * This controls how long, in milli secconds, WaitForSingleObject() * waits before it times out. Change this to suit your preferences. #DEFINE WAIT_INTERVAL 200 DECLARE INTEGER CreateProcess IN kernel32.DLL ; INTEGER lpApplicationName, ; STRING lpCommandLine, ; INTEGER lpProcessAttributes, ; INTEGER lpThreadAttributes, ; INTEGER bInheritHandles, ; INTEGER dwCreationFlags, ; INTEGER lpEnvironment, ; STRING @lpCurrentDirectory, ; STRING @lpStartupInfo, ; STRING @lpProcessInformation DECLARE INTEGER WaitForSingleObject IN kernel32.DLL ; INTEGER hHandle, INTEGER dwMilliseconds DECLARE INTEGER CloseHandle IN kernel32.DLL ; INTEGER hObject DECLARE INTEGER GetLastError IN kernel32.DLL DECLARE INTEGER GetExitCodeProcess IN kernel32.DLL ; INTEGER hHandle, LONG @nExitCode IF EMPTY(sDir) sDir = CURDIR() ENDIF * sCmd = sCmd + IIF(!EMPTY(sParm), " " + sParm, "")+ CHR(0) sCmd = sCmd + CHR(0) sDir = sDir + CHR(0) nShow = IIF(VARTYPE(nShow) <> "N", SW_NORMAL, nShow) * STARTUPINFO is 68 bytes, of which we need to * initially populate the 'cb' or Count of Bytes member * with the overall length of the structure. * The remainder should be 0-filled * typedef struct _STARTUPINFO { * DWORD cb; 1 * LPTSTR lpReserved; 5 * LPTSTR lpDesktop; 9 * LPTSTR lpTitle; 13 * DWORD dwX; 17 * DWORD dwY; 21 * DWORD dwXSize; 25 * DWORD dwYSize; 29 * DWORD dwXCountChars; 33 * DWORD dwYCountChars; 37 * DWORD dwFillAttribute;41 * DWORD dwFlags; 45 * WORD wShowWindow; 49 * WORD cbReserved2; 51 * LPBYTE lpReserved2; 53 * HANDLE hStdInput; 57 * HANDLE hStdOutput; 61 * HANDLE hStdError; 65 * } STARTUPINFO, *LPSTARTUPINFO; #define STARTF_USESHOWWINDOW 0x00000001 #define STARTF_USESIZE 0x00000002 #define STARTF_USEPOSITION 0x00000004 #define STARTF_USECOUNTCHARS 0x00000008 #define STARTF_USEFILLATTRIBUTE 0x00000010 #define STARTF_RUNFULLSCREEN 0x00000020 && ignored for non-x86 platforms #define STARTF_FORCEONFEEDBACK 0x00000040 #define STARTF_FORCEOFFFEEDBACK 0x00000080 #define STARTF_USESTDHANDLES 0x00000100 nFlags = STARTF_USESHOWWINDOW sStartProcBuf = REPLICATE(CHR(0), 68) sStartProcBuf = STUFF(sStartProcBuf, 1, 4, long2str (LEN(sStartProcBuf))) sStartProcBuf = STUFF(sStartProcBuf, 45, 4, long2str (nFlags)) sStartProcBuf = STUFF(sStartProcBuf, 49, 2, CHR (nShow) + CHR(0)) * PROCESS_INFORMATION structure is 4 longs, * or 4*4 bytes = 16 bytes, which we'll fill with nulls. sProcInfoBuf = REPLICATE(CHR(0), 16) * Call CreateProcess, obtain a process handle. Treat the * application to run as the 'command line' argument, accept * all other defaults. Important to pass the sStartProcBuf and * sProcInfoBuf by reference. * nRet = CreateProcess(0, File2Run, 0, 0, 1, ; * NORMAL_PRIORITY_CLASS, 0, 0, @sStartProcBuf, @sProcInfoBuf) nRet = CreateProcess (0, sCmd, 0, 0, 1, ; NORMAL_PRIORITY_CLASS, 0, @sDir, @sStartProcBuf, @sProcInfoBuf) * Unable to run, exit now. IF nRet = 0 * =MESSAGEBOX("Error occurred. Error code: ", GetLastError()) CLEAR DLLS CreateProcess, WaitForSingleObject, CloseHandle, GetLastError, GetExitCodeProcess RETURN -1 ENDIF * Extract the process handle from the * PROCESS_INFORMATION structure. nhProc = str2long (SUBSTR(sProcInfoBuf, 1, 4)) DO WHILE .T. * Use timeout of TIMEOUT_INTERVAL msec so the display * will be updated. Otherwise, the VFP window never repaints until * the loop is exited. IF WaitForSingleObject(nhProc, WAIT_INTERVAL) != WAIT_TIMEOUT EXIT ENDIF ENDDO * Show a message box when we're done. * =MESSAGEBOX ("Process completed") * Close the process handle afterwards. * nRet = CloseHandle (nhProc) GetExitCodeProcess (nhProc, @nRet) CloseHandle (nhProc) CLEAR DLLS CreateProcess, WaitForSingleObject, CloseHandle, GetLastError, GetExitCodeProcess RETURN nRet ******************** FUNCTION long2str ******************** * Passed : 32-bit non-negative numeric value (m.longval) * Returns : ASCII character representation of passed * value in low-high format (m.retstr) * Example : * m.long = 999999 * m.longstr = long2str(m.long) PARAMETERS m.longval PRIVATE i, m.retstr m.retstr = "" FOR i = 24 TO 0 STEP -8 m.retstr = CHR(INT(m.longval/(2^i))) + m.retstr m.longval = MOD(m.longval, (2^i)) NEXT RETURN m.retstr ******************* FUNCTION str2long ******************* * Passed: 4-byte character string (m.longstr) * in low-high ASCII format * returns: long integer value * example: * m.longstr = "1111" * m.longval = str2long(m.longstr) PARAMETERS m.longstr PRIVATE i, m.retval m.retval = 0 FOR i = 0 TO 24 STEP 8 m.retval = m.retval + (ASC(m.longstr) * (2^i)) m.longstr = RIGHT(m.longstr, LEN(m.longstr) - 1) NEXT RETURN m.retval *** |
...
Hola Mario, me parece que es lo que estaba buscando.
En cuanto pueda probarlo te aviso.
Muchas gracias!
Hola Jean:
El problema es que en algunas empresas los responsables de seguridad informática deshabilitan el acceso a ciertos objetos del sistema, por eso la búsqueda de un sustituto que no puede deshabilitarse.
Saludos
Disculpa Fernando trate de bajar la función WScriptShell_Run pero me dice acceso denagado.
Fernando y como lo ejecutas de manera síncrona, por ejemplo para esperar a que termine un proceso largo, por ejemplo:
Resp= WScriptShell_Run("c:\windows\system32\cmd.exe /c dir c:\*.* /s > \temp\dir.txt")
Ya que el valor de retorno 0 o -1, sólo me denota si es un comando válido y lo retorna en cuanto regresa el control al VFP, aunque el proceso demorara dos minutos en concluirse.
De: publice...@googlegroups.com [mailto:publice...@googlegroups.com] En nombre de Fernando D. Bozzo
Enviado el: lunes, 14 de septiembre de 2015 05:58 a.m.
Para: Comunidad de Visual Foxpro en Español
______________________________________________
Carlos Omar Figueroa López
Servidores Dedicados Windows desde $ 4 USD / dia
De: publice...@googlegroups.com [mailto:publice...@googlegroups.com] En nombre de Jorge Galván Pérez
Enviado el: lunes, 14 de septiembre de 2015 11:02 a.m.
Para: Comunidad de Visual Foxpro en Español
Asunto: [vfp] Re: Reemplazo de WScript.Shell => run con Win32?
Gracias Fernando por responder pero cuando le doy a link para poder copiar el texto de la función me sale
Listo Fernando an bloquedao la dirección ip pero es la gente del gobierno de mi país que da el servicio de internet.
Hola:
Como es compatible a nivel parámetros con la que sustituye, en la cabecera está el link que documenta los parámetros, donde uno de ellos indica si debe esperar a que finalice la ejecución (sincrónico) o no (asincrónico)
Si, ya lei bien
WScriptShell_Run("c:\windows\system32\cmd.exe /c dir c:\*.* /s > \temp\dir.txt",0,.T.)
WScriptShell_Run("c:\windows\system32\cmd.exe /c dir c:\*.* /s > \temp\dir.txt",0,.F.)
Sorry y Gracias
Hola Carton.
Tu prueba de compilarlo en 32 no es lo q necesita Fernando, de hecho ya lo hizo, lo q necesita es vos q tenes la librería de Chen la verdadera prueba sería q lo compilaras en 64 x supuesto q usando un Win64 y ver si la librería funciona…
Saludos.
Esteban.
De: publice...@googlegroups.com [mailto:publice...@googlegroups.com] En nombre de Carton Jeston (9.0.0.7423)
Enviado el: lunes, 21 de septiembre de 2015 04:50 p.m.
Para: Comunidad de Visual Foxpro en Español
Asunto: [vfp] Re: Reemplazo de WScript.Shell => run con Win32?
Ahora mismo tengo el w7-32 para programar y el w10-64 para trastear y en este ultimo no tengo aun instalado el compilador a 64.
*!* ["c:\westwind\wconnect\wcscripts\test.wcs"],1,.T.)
*/? CreateProcess1("c:\windows\Notepad.exe","",1,.T.)
lcCommand = [tasklist | find "notepad" > "Notepadproces.txt"]
? CreateProcess1("c:\windows\System32\cmd.exe", lcCommand, 1, .T.)
RETURN
************************************************************************
* wwAPI :: Createprocess
****************************************
*** Function: Calls the CreateProcess API to run a Windows application
*** Assume: Gets around RUN limitations which has command line
*** length limits and problems with long filenames.
*** Can do everything EXCEPT REDIRECTION TO FILE!
*** Pass: lcExe - Name of the Exe
*** lcCommandLine - Any command line arguments
*** Return: .t. or .f.
************************************************************************
FUNCTION Createprocess1(lcExe,lcCommandLine,lnShowWindow,llWaitForCompletion)
LOCAL hProcess, cProcessInfo, cStartupInfo
DECLARE INTEGER CreateProcess IN kernel32 as ApiCreateProcess;
STRING lpApplicationName,;
STRING lpCommandLine,;
INTEGER lpProcessAttributes,;
INTEGER lpThreadAttributes,;
INTEGER bInheritHandles,;
INTEGER dwCreationFlags,;
INTEGER lpEnvironment,;
STRING lpCurrentDirectory,;
STRING lpStartupInfo,;
STRING @lpProcessInformation
cProcessinfo = REPLICATE(CHR(0),128)
cStartupInfo = GetStartupInfo(lnShowWindow)
IF !EMPTY(lcCommandLine)
lcCommandLine = ["] + lcExe + [" ]+ lcCommandLine
ELSE
lcCommandLine = ""
ENDIF
*!* #DEFINE CREATE_NEW_CONSOLE 16
*!* #DEFINE NORMAL_PRIORITY_CLASS 32
#DEFINE CREATE_NEW_CONSOLE 0x00000010
#DEFINE NORMAL_PRIORITY_CLASS 0x00000020
lngdwCreationFlags = CREATE_NEW_CONSOLE + NORMAL_PRIORITY_CLASS
lnResult = ApiCreateProcess(lcExe, lcCommandLine, 0, 0, 1, lngdwCreationFlags, 0, 0, cStartupInfo, @cProcessInfo)
IF lnResult = 0
RETURN .F.
ENDIF
*lnResult = ApiCreateProcess(lcExe,lcCommandLine,0,0,1,0,0,;
SYS(5)+CURDIR(),cStartupInfo, @cProcessInfo)
lhProcess = CHARTOBIN( SUBSTR(cProcessInfo,1,4) )
*/lhProcess = Buf2dword(LEFT(cProcessInfo, 4))
*/lhProcess = str2long (SUBSTR(cProcessInfo, 1, 4))
IF llWaitForCompletion
#DEFINE WAIT_TIMEOUT 0x00000102
DECLARE INTEGER WaitForSingleObject IN kernel32.DLL ;
INTEGER hHandle, INTEGER dwMilliseconds
lngdwMilliseconds = 200
*!* DO WHILE WaitForSingleObject(lhProcess, lngdwMilliseconds) = WAIT_TIMEOUT
*!* DOEVENTS
DO WHILE .T.
*** Update every 100 milliseconds
*!* IF WaitForSingleObject(lhProcess, lngdwMilliseconds) != WAIT_TIMEOUT
lnRet = WaitForSingleObject(lhProcess, lngdwMilliseconds)
IF lnRet != WAIT_TIMEOUT
EXIT
ELSE
DOEVENTS
ENDIF
ENDDO
ENDIF
DECLARE INTEGER CloseHandle IN kernel32.DLL ;
INTEGER hObject
CloseHandle(lhProcess)
RETURN IIF(lnResult=1,.t.,.f.)
*/
FUNCTION getStartupInfo(lnShowWindow)
LOCAL lnFlags
* creates the STARTUP structure to specify main window
* properties if a new window is created for a new process
IF EMPTY(lnShowWindow)
lnShowWindow = 1
ENDIF
*| typedef struct _STARTUPINFO {
*| DWORD cb; 4
*| LPTSTR lpReserved; 4
*| LPTSTR lpDesktop; 4
*| LPTSTR lpTitle; 4
*| DWORD dwX; 4
*| DWORD dwY; 4
*| DWORD dwXSize; 4
*| DWORD dwYSize; 4
*| DWORD dwXCountChars; 4
*| DWORD dwYCountChars; 4
*| DWORD dwFillAttribute; 4
*| DWORD dwFlags; 4
*| WORD wShowWindow; 2
*| WORD cbReserved2; 2
*| LPBYTE lpReserved2; 4
*| HANDLE hStdInput; 4
*| HANDLE hStdOutput; 4
*| HANDLE hStdError; 4
*| } STARTUPINFO, *LPSTARTUPINFO; total: 68 bytes
#DEFINE STARTF_USESTDHANDLES 0x0100
#DEFINE STARTF_USESHOWWINDOW 1
#DEFINE SW_HIDE 0
#DEFINE SW_SHOWMAXIMIZED 3
#DEFINE SW_SHOWNORMAL 1
lnFlags = STARTF_USESHOWWINDOW
RETURN binToChar(80) +;
binToChar(0) + binToChar(0) + binToChar(0) +;
binToChar(0) + binToChar(0) + binToChar(0) + binToChar(0) +;
binToChar(0) + binToChar(0) + binToChar(0) +;
binToChar(lnFlags) +;
binToWordChar(lnShowWindow) +;
binToWordChar(0) + binToChar(0) +;
binToChar(0) + binToChar(0) + binToChar(0) + REPLICATE(CHR(0),30)
************************************************************************
FUNCTION CharToBin(lcBinString,llSigned)
****************************************
*** Function: Binary Numeric conversion routine.
*** Converts DWORD or Unsigned Integer string
*** to Fox numeric integer value.
*** Pass: lcBinString - String that contains the binary data
*** llSigned - if .T. uses signed conversion
*** otherwise value is unsigned (DWORD)
*** Return: Fox number
************************************************************************
LOCAL m.i, lnWord
lnWord = 0
FOR m.i = 1 TO LEN(lcBinString)
lnWord = lnWord + (ASC(SUBSTR(lcBinString, m.i, 1)) * (2 ^ (8 * (m.i - 1))))
ENDFOR
IF llSigned AND lnWord > 0x80000000
lnWord = lnWord - 1 - 0xFFFFFFFF
ENDIF
RETURN lnWord
* wwAPI :: CharToBin
***********************************************************************
FUNCTION BinToChar(lnValue)
****************************************
*** Function: Creates a DWORD value from a number
*** Pass: lnValue - VFP numeric integer (unsigned)
*** Return: binary string
************************************************************************
Local byte(4)
If lnValue < 0
lnValue = lnValue + 4294967296
EndIf
byte(1) = lnValue % 256
byte(2) = BitRShift(lnValue, 8) % 256
byte(3) = BitRShift(lnValue, 16) % 256
byte(4) = BitRShift(lnValue, 24) % 256
RETURN Chr(byte(1))+Chr(byte(2))+Chr(byte(3))+Chr(byte(4))
* wwAPI :: BinToChar
************************************************************************
FUNCTION BinToWordChar(lnValue)
****************************************
*** Function: Creates a DWORD value from a number
*** Pass: lnValue - VFP numeric integer (unsigned)
*** Return: binary string
************************************************************************
RETURN Chr(MOD(m.lnValue,256)) + CHR(INT(m.lnValue/256))
*Some of that code originated from Christof Wollenhaupt with a number of modifications made to support wait operations and easier access to the command line parameters.
*To support piping etc. wwIPStuff.dll (part of West Wind Internet Protocols or West Wind Client Tools) includes a wrapper that does something like this:
************************************************************************
* wwAPI :: CreateprocessEx
****************************************
*** Function: Calls the CreateProcess API to run a Windows application
*** Assume: Gets around RUN limitations which has command line
*** length limits and problems with long filenames.
*** Can do Redirection
*** Requires wwIPStuff.dll to run!
*** Pass: lcExe - Name of the Exe
*** lcCommandLine - Any command line arguments
*** Return: .t. or .f.
************************************************************************
FUNCTION CreateProcessEx(lcExe,lcCommandLine,lcStartDirectory,;
lnShowWindow,llWaitForCompletion,lcStdOutputFilename)
DECLARE INTEGER wwCreateProcess IN wwIPStuff.DLL AS _wwCreateProcess ;
String lcExe, String lcCommandLine, INTEGER lnShowWindow,;
INTEGER llWaitForCompletion, STRING lcStartupDirectory, STRING StdOutFile
IF EMPTY(lcStdOutputFileName)
lcStdOutputFileName = NULL
ENDIF
IF EMPTY(lcStartDirectory)
lcStartDirectory = CHR(0)
ENDIF
IF !EMPTY(lcCommandLine)
lcCommandLine = ["] + lcExe + [" ]+ lcCommandLine
ELSE
lcCommandLine = ""
ENDIF
IF llWaitForCompletion
lnWait = 1
ELSE
lnWait = 0
ENDIF
IF EMPTY(lnShowWindow)
lnShowWindow = 4
ENDIF
lnResult = _wwCreateProcess(lcExe,lcCommandLine,lnShowWindow,lnWait,;
lcStartDirectory,lcStdOutputFileName)
RETURN IIF(lnResult == 1, .t. , .f.)
ENDFUNC
*/
FUNCTION buf2dword (lcBuffer)
RETURN;
Asc(SUBSTR(lcBuffer, 1,1)) + ;
Asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
Asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
Asc(SUBSTR(lcBuffer, 4,1)) * 16777216
ENDFUNC
*/
*******************
RETURN Chr(byte(1))+<font color="#00
byte(4) = BitRShift(lnValue, 24) % 256</f