hatem
11-02-2000, 12:33 PM
I just need some help with running another exe file from my program. I want to create a driver CD where I can select the driver(an exe file) from a list box and hit a command button to execute the driver. Also with API, is it possible to use absolute paths?
niktesla
11-02-2000, 05:37 PM
This question seem to get asked about once a week, but here it is again.
'This goes in your declarations section
'A constant needed for Shell Execute
Private Const SW_SHOW = 5
'declare Shell Execute
Private declare function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
'Here is the sub to call shell execute
Public Sub OpenThisDoc(strFileName As String)
'strFileName is the fully qualified path to the file from the application directory
On Error Resume Next 'You have to check the return value of X below to determine if it worked, I don't here
Dim X As Long
X = ShellExecute(0&, vbNullString, strFileName, vbNullString, vbNullString, SW_SHOW)
End Sub
'The call to OpenThisDoc
Call OpenThisDoc(strFileName)
'If the file is found, the system will open it with it's associated executable
'If not, nothing will happen
'You have to check the return value of X.
'I think 326 is success and 2 is faulure. Who knows why!
Brian T. Wiehoff