1
« en: Lunes 19 de Noviembre de 2007, 17:42 »
Usa esto :
Dim ret As Long
ret = Shell("c:\program files\winrar\rar a -ap c:\test.rar -ptest c:\answer.txt c:\test.xml")
= OPEN_FILE("c:\program files\winrar\rar a -ap c:\test.rar -ptest c:\answer.txt c:\test.xml")
Con la API ShellExecute.
FUNCTION OPEN_FILE(pcFileName,pcAction,pcParams,pcDefDir,pnShowWindow )
****************************************************
* Filename
If Vartype(pcFileName) <> "C"
MessageBox("Need a file to open!")
Return 0
Endif
* Action
If Vartype(pcAction) <> "C"
pcAction = "open"
Endif
* Parameters
If Vartype(pcParams) <> "C"
pcParams = ""
ENDIF
* Default Directory
If Vartype(pcDefDir) <> "C"
pcDefDir = ADDBS(SYS(5)+CURDIR())
ENDIF
* Show Window (min / Max etc)
If Vartype(pnShowWindow) <> "N"
pnShowWindow = 1
Endif
#Define SE_ERR_FNF 2
#Define SE_ERR_PNF 3
#Define SE_ERR_ACCESSDENIED 5
#Define SE_ERR_OOM 8
#Define SE_ERR_DLLNOTFOUND 32
#Define SE_ERR_SHARE 26
#Define SE_ERR_ASSOCINCOMPLETE 27
#Define SE_ERR_DDETIMEOUT 28
#Define SE_ERR_DDEFAIL 29
#Define SE_ERR_DDEBUSY 30
#Define SE_ERR_NOASSOC 31
#Define ERROR_BAD_FORMAT 11
Declare Integer ShellExecute In shell32.Dll ;
INTEGER hndWin, ;
STRING cAction, ;
STRING cFileName, ;
STRING cParams, ;
STRING cDir, ;
INTEGER nShowWin
cFileName = pcFileName
cAction = pcAction
cParams = pcParams
cDir = pcDefDir
nShowWin = pnShowWindow
Local lnRetVal
lnRetVal = 0
lnRetVal = ShellExecute(0,cAction,cFileName,cParams,cDir,nShowWin)
If lnRetVal <= 32
Local msg
msg = ""
*There was an error
Do Case
Case lnRetVal = SE_ERR_FNF
msg = "File not found"
Case lnRetVal = SE_ERR_PNF
msg = "Path not found"
Case lnRetVal = SE_ERR_ACCESSDENIED
msg = "Access denied"
Case lnRetVal = SE_ERR_OOM
msg = "Out of memory"
Case lnRetVal = SE_ERR_DLLNOTFOUND
msg = "DLL not found"
Case lnRetVal = SE_ERR_SHARE
msg = "A sharing violation occurred"
Case lnRetVal = SE_ERR_ASSOCINCOMPLETE
msg = "Incomplete or invalid file association"
Case lnRetVal = SE_ERR_DDETIMEOUT
msg = "DDE Time out"
Case lnRetVal = SE_ERR_DDEFAIL
msg = "DDE transaction failed"
Case lnRetVal = SE_ERR_DDEBUSY
msg = "DDE busy"
Case lnRetVal = SE_ERR_NOASSOC
msg = "No association for file extension"
Case lnRetVal = ERROR_BAD_FORMAT
msg = "Invalid EXE file or error in EXE image"
Otherwise
msg = "Unknown error"
Endcase
RETURN .F.
Else
Return .T.
Endif
ENDFUNC