robsuttonjr
MIS
Windows Function Wrapper (starting point for those not using this great option and to spark ideas.)
Copy the code below into a .prg then save as 'WindowsFunctions.prg'. Then execute the following:
FROM COMMAND LINE DO THESE:
SET PROCEDURE TO WindowsFunctions ADDITIVE
loWF = CREATEOBJECT('WindowsFunctions')
loWF.Notepad()
loWF.Cmd()
COPY BELOW TO .PRG CALLED 'WindowsFunctions.prg':
Define Class WindowsFunctions As Custom
FUNCTION Notepad
LPARAMETERS lcPath
This.ShellExec(0,"open","notepad","",lcPath,1)
ENDFUNC
FUNCTION Cmd
LPARAMETERS lcPath
IF EMPTY(lcPath)
lcPath = ALLTRIM(SYS(5))+"\"
ENDIF
This.ShellExec(0,"open","cmd","",lcPath,1)
ENDFUNC
Function ShellExec
Lparameters hndWin, cAction, cFileName, cParams, cDir, nShowWindow
*!* hndWin - Parent window handle (typical 0)
*!* cAction - Action to be performed on cFileName.
*!* cFileName - File which cAction is to be performed on.
*!* cParams - Parameters to pass if file type is executable.
*!* cDir - Executable program's default or start-up directory.
*!* nShowWindow - Initial window state (1 = normal, 2 = minimized, 3 = maximised).
If Empty(hndWin)
hndWin = 0
Endif
If Empty(cAction)
cAction = "open"
Endif
If Empty(cFileName)
cFileName = "notepad"
Endif
If Empty(cParams)
cParams = ""
Endif
If Empty(cDir)
cDir = ""
Endif
If Empty(nShowWindow)
nShowWindow = 1
Endif
Declare Integer ShellExecute In shell32.Dll ;
INTEGER hndWin, ;
STRING cAction, ;
STRING cFileName, ;
STRING cParams, ;
STRING cDir, ;
INTEGER nShowWin
lnStatus = ShellExecute(hndWin,cAction,cFileName,cParams,cDir,nShowWindow)
If lnStatus <=32
Messagebox("ShellExecute failed: "+Message(),0,"Error")
Endif
Return
ENDFUNC
Enddefine
Regards,
Rob
Copy the code below into a .prg then save as 'WindowsFunctions.prg'. Then execute the following:
FROM COMMAND LINE DO THESE:
SET PROCEDURE TO WindowsFunctions ADDITIVE
loWF = CREATEOBJECT('WindowsFunctions')
loWF.Notepad()
loWF.Cmd()
COPY BELOW TO .PRG CALLED 'WindowsFunctions.prg':
Define Class WindowsFunctions As Custom
FUNCTION Notepad
LPARAMETERS lcPath
This.ShellExec(0,"open","notepad","",lcPath,1)
ENDFUNC
FUNCTION Cmd
LPARAMETERS lcPath
IF EMPTY(lcPath)
lcPath = ALLTRIM(SYS(5))+"\"
ENDIF
This.ShellExec(0,"open","cmd","",lcPath,1)
ENDFUNC
Function ShellExec
Lparameters hndWin, cAction, cFileName, cParams, cDir, nShowWindow
*!* hndWin - Parent window handle (typical 0)
*!* cAction - Action to be performed on cFileName.
*!* cFileName - File which cAction is to be performed on.
*!* cParams - Parameters to pass if file type is executable.
*!* cDir - Executable program's default or start-up directory.
*!* nShowWindow - Initial window state (1 = normal, 2 = minimized, 3 = maximised).
If Empty(hndWin)
hndWin = 0
Endif
If Empty(cAction)
cAction = "open"
Endif
If Empty(cFileName)
cFileName = "notepad"
Endif
If Empty(cParams)
cParams = ""
Endif
If Empty(cDir)
cDir = ""
Endif
If Empty(nShowWindow)
nShowWindow = 1
Endif
Declare Integer ShellExecute In shell32.Dll ;
INTEGER hndWin, ;
STRING cAction, ;
STRING cFileName, ;
STRING cParams, ;
STRING cDir, ;
INTEGER nShowWin
lnStatus = ShellExecute(hndWin,cAction,cFileName,cParams,cDir,nShowWindow)
If lnStatus <=32
Messagebox("ShellExecute failed: "+Message(),0,"Error")
Endif
Return
ENDFUNC
Enddefine
Regards,
Rob