Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
FUNCTION WaitForProcess
LPARAMETERS pcCmdline
#DEFINE PROCESS_QUERY_INFORMATION 0x0400
#DEFINE STATUS_PENDING 0x0103
Declare LONG OpenProcess in Win32Api LONG dwDesiredAccess, LONG bInheritHandle LONG dwProcessId
Declare LONG GetExitCodeProcess in Win32Api LONG hProcess, LONG @lpExitCode
Declare LONG CloseHandle in win32api LONG
DECLARE LONG GetLastError in Win32API
DECLARE INTEGER CreateProcess IN win32api ;
STRING lpApplicationName,;
STRING lpCommandLine,;
INTEGER lpProcessAttributes,;
INTEGER lpThreadAttributes,;
INTEGER bInheritHandles,;
INTEGER dwCreationFlags,;
INTEGER lpEnvironment,;
STRING lpCurrentDirectory,;
STRING lpStartupInfo,;
STRING @ lpProcessInformation
* typedef struct _STARTUPINFO {
* DWORD cb;
* LPTSTR lpReserved;
* LPTSTR lpDesktop;
* LPTSTR lpTitle;
* DWORD dwX;
* DWORD dwY;
* DWORD dwXSize;
* DWORD dwYSize;
* DWORD dwXCountChars;
* DWORD dwYCountChars;
* DWORD dwFillAttribute;
* DWORD dwFlags;
* WORD wShowWindow;
* WORD cbReserved2;
* LPBYTE lpReserved2;
* HANDLE hStdInput;
* HANDLE hStdOutput;
* HANDLE hStdError;
* } STARTUPINFO, *LPSTARTUPINFO;
* typedef struct _PROCESS_INFORMATION {
* HANDLE hProcess;
* HANDLE hThread;
* DWORD dwProcessId;
* DWORD dwThreadId;
* } PROCESS_INFORMATION;
LOCAL hProcess, ProcessId, exitCode,err, lcDir, lcStartupInfo, lcProcInfo
lcDir = Set('defa')+curdir()
exitCode = 0
* typedef struct _STARTUPINFO {
* DWORD cb;
* LPTSTR lpReserved;
* LPTSTR lpDesktop;
* LPTSTR lpTitle;
* DWORD dwX;
* DWORD dwY;
* DWORD dwXSize;
* DWORD dwYSize;
* DWORD dwXCountChars;
* DWORD dwYCountChars;
* DWORD dwFillAttribute;
* DWORD dwFlags;
* WORD wShowWindow;
* WORD cbReserved2;
* LPBYTE lpReserved2;
* HANDLE hStdInput;
* HANDLE hStdOutput;
* HANDLE hStdError;
* } STARTUPINFO, *LPSTARTUPINFO;
* 54 = 4+4+4+4+4+4+4+4+4+4+2+2+4+2+2+2
lcStartupInfo = Num2Dword(54)+Num2Dword(0)+Num2Dword(0)+Num2Dword(0);
+Num2Dword(0)+Num2Dword(0);
+Num2Dword(0)+Num2Dword(0);
+Num2Dword(0)+Num2Dword(0);
+Num2word(0)+Num2word(0);
+Num2Dword(0);
+Num2word(0)+Num2word(0)+Num2word(0)
* 2,2,4,4
lcProcInfo = Num2Word(0)+Num2Word(0)+Num2DWord(0)+Num2DWord(0)
err = CreateProcess( pccmdLine,pccmdLine,0,0,0,0,0,lcDir,@lcStartupInfo,@lcProcInfo )
if Err=0
RETURN -100000-GetLastError()
endif
hProcess = Buf2Word( lcProcInfo ) && Takes first 2 chars
if hProcess=0
RETURN -200000-GetLastError()
endif
* Don't need to look up process from ID, CreateProcess gave us the hProcess
*hProcess2 = OpenProcess(PROCESS_QUERY_INFORMATION, .f., ProcessId)
do while .T.
* Returns 0 if there is an error
err=GetExitCodeProcess(hProcess, @exitCode)
if err=0
?"Handle=",hProcess
RETURN -300000-GetLastError()
endif
DoEvents
??"."
if (exitCode = STATUS_PENDING) && Still Running
LOOP
endif
EXIT
enddo
CloseHandle(hProcess)
RETURN ExitCode
ENDFUNC
* * *
* dword is compatible with LONG
FUNCTION num2dword (lnValue)
#DEFINE m0 256
#DEFINE m1 65536
#DEFINE m2 16777216
LOCAL b0, b1, b2, b3
b3 = Int(lnValue/m2)
b2 = Int((lnValue - b3*m2)/m1)
b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
b0 = Mod(lnValue, m0)
RETURN Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)
* * *
* dword is compatible with LONG
FUNCTION num2word (lnValue)
RETURN Chr(MOD(m.lnValue,256)) + CHR(INT(m.lnValue/256))
* * *
FUNCTION buf2word (lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
Asc(SUBSTR(lcBuffer, 2,1)) * 256
* * *
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
PROCEDURE Test
RunShell( "c:\windows\notepad.exe" )
RETURN
FUNCTION UnZip
PARAMETERS m.FILENAME,m.DESTDIR
LOCAL lcPathToWinzip
lcPathToWinzip = "C:\program files\winzip\winzip.exe" && or whatever... you really should specify the full path since it's not likely to be available in the DOS PATH
WaitForProcess( lcPathToWinzip+" -min -e "+m.FILENAME+" "+m.DESTDIR )
RETURN(.F.)
FUNCTION UnZip
PARAMETERS m.FILENAME,m.DESTDIR
LOCAL lcPathToWinzip, loX
lcPathToWinzip = "C:\program files\winzip\winzip.exe"
loX = NEWOBJECT( 'unzipClass','Process.vcx' )
loX.LaunchProgram( lcPathToWinzip, " -min -e "+m.FILENAME+" "+m.DESTDIR )
RETURN(.F.)