Visual Basic 6 wait till shellexecute API completes before continuing program execution
Posted on 2007-12-05
I am using the ShellExecute API to print pdf files. I want to loop until the shellexecute api has completed sending the print job to the print queue then continue with program execution. Of course I could put a long delay in the program after the shellexecute line but the size of the print files vary greatly.
Below is the shellexecute function and the line used to call the function.
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
String, ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
PrintDoc = ShellExecute(0, "Print", Fname, " ", " ", SW_HIDE)