Code: Select all
IF cExt = 'EXE' .OR. cExt = 'BAT' .OR. cExt = 'COM'
_Execute( 0,, cFile,, cPath, 5 )
ELSE
cExe := GetOpenCommand( cExt )
IF !EMPTY( cExe )
cFile := cPath + '\' + cFile
_Execute( 0,, cExe, IF( AT( " ", cFile ) > 0, '"' + cFile + '"', cFile ), cPath, 5 )
ELSE
MsgInfo( 'Error executing program!', "Alert" )
ENDIF
ENDIF
but this is IMHO not need when use ShellExecute()
https://docs.microsoft.com/en-us/window ... llexecutea
now in c:\hmg.3.4.4\SOURCE\h_winapimisc.prg
Code: Select all
Function _Execute( nActiveWindowhandle , cOperation , cFile , cParaMeters , cDefault , nState )
If ValType ( nActiveWindowhandle ) == 'U'
nActiveWindowhandle := 0
EndIf
If ValType ( cOperation ) == 'U'
cOperation := Nil
EndIf
If ValType ( cFile ) == 'U'
cFile := ""
EndIf
If ValType ( cParaMeters ) == 'U'
cParaMeters := Nil
EndIf
If ValType ( cDefault ) == 'U'
cDefault := Nil
EndIf
If ValType ( nState ) == 'U'
nState := 10 // SW_SHOWDEFAULT
EndIf
ShellExecute ( nActiveWindowhandle , cOperation , cFile , cParaMeters , cDefault , nState )
RETURN Nil
Code: Select all
FUNCTION SHELLOPENFILE( cPath, cFILE, cPara )
LOCAL lSuccess
LOCAL Retvar := .F.
DEFAULT cPath TO ""
DEFAULT cFILE TO ""
DEFAULT cPara TO CURDIR()
lSuccess := ShellExecute( 0, ;
"open", ;
cPath + cFILE, ;
cPara, ;
0, ;
SW_NORMAL )
2nd Parameter "lpOperation" is a "Verb" which can be "open","print" ... depend on File or Folder
so i correct Code this Way and get rid of Registry "C"-Code
Code: Select all
IF cExt = 'EXE' .OR. cExt = 'BAT' .OR. cExt = 'COM'
_Execute( 0,, cFile,, cPath, 5 )
ELSEIF cExt = 'LNK'
// LNK need to open other Way
ELSE
_Execute( 0,"open", '"' +cFile + '"', , cPath, 5 )
ENDIF