-
I am using ShellExecute to run a DOS shell disk image program and copy files to the A drive. I need to prompt the user to remove the floppy when it is done, however once the API is called the program continues on. I have tried loops and DoEvents to use drv.IsReady but drv.IsReady is always true. Is there some function or API I can use to tell when the disk drive is no longer running or the DOS window has closed. Help Please!!!
-
...
Gotthisawhileback
Call the following function this way
Shell32Bit "program to run"
use this function
Sub Shell32Bit(ByVal JobToDo As String, Optional frm As Form)
Dim hProcess As Long
Dim RetVal As Long
'Get process ID
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(JobToDo, vbMinimizedNoFocus))
Do
'Get the status of the process
GetExitCodeProcess hProcess, RetVal
'Sleep command recommended as well as DoEvents
DoEvents: Sleep 200
'Loop while the process is active
Loop While RetVal = STILL_ACTIVE
Beep
CloseHandle hProcess
End Sub
'declare these
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400
Private Declare Function CloseHandle Lib "kernel32" (hObject As Long) As Boolean
Good luck!
-
Lafor thanks!!!! It works great. I appreciate your help.