********************************************************************* * * * Program ID . . : ShellExe.VPG * * * * Description . : Demonstrates using Win32API to run local *.EXE's * * * * Function . . . : * * * * Messages . . . : * * * * Files . . . . : * * * * Input . . . . : * * * * Output . . . . : * * * ********************************************************************* H*EXE H*NOMAIN * ------------------------------------------------------------------- * Windows DLL for executing commands on the PC * ------------------------------------------------------------------- DShellExecuteA PR 10u 0 ExtProc('ShellExecuteA') D DLL('SHELL32.dll') D Linkage(*StdCall) D 10U 0 Value Window Handle D * Value Operation D * Value File/Cmd/Path D * Value Parameters D * Value Directory D 10U 0 Value Show command *-------------------------------------------------------------------- * Work Variables for API *-------------------------------------------------------------------- D hWnd S 10U 0 Window handle D ulRc S 10U 0 Return Code D cParms S 2000a D cDir S 1000a D Operation S 7a Inz('open ') D lpOperation S * Inz(%Addr(Operation)) Operation Address D lpCmdStg S * Inz(%Addr(CommandString)) file name Address D lpcParms S * Inz(%Addr(cParms)) Parms Address D lpcDir S * Inz(%Addr(cDir)) Directory Name Address *------------------------------------------------------------------ * Local Work Variables *------------------------------------------------------------------ DCommandString S 2000a Inz('C:\WINNT\Notepad.exe') *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * * ShellCmd - Execute Windows Command * *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ C ShellCmd Begsr * C Eval hWnd = %getatr('WIN1':'WIN1': C 'Handle') C Eval CommandString = %trim(CommandString) + x'00' C Eval Operation = %trim(Operation) + x'00' C Eval cParms = %trim(cParms) + x'00' C Eval ulRc = ShellExecutea(hWnd:lpOperation: C lpCmdStg:lpcParms:lpcDir:1) C Endsr ********************************************************************* * * Window . . : WIN1 * * Part . . . : PSBRUN * * Event . . : PRESS * * Description: User clicks on the Notepad.exe application * ********************************************************************* * C PSBRUN BEGACT PRESS WIN1 * C Exsr ShellCmd * C ENDACT