Results 1 to 3 of 3

Thread: ShellExecute - Help!!!!!!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    USA
    Posts
    6

    Angry

    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!!!

  2. #2
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ...

    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!

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    USA
    Posts
    6

    Talking

    Lafor thanks!!!! It works great. I appreciate your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width