|
-
Dec 18th, 2001, 11:59 PM
#1
Hide Shelled Application
I need to run another application from within my VB application and I need to have my app wait for the shelled process to terminate.
I know I can use Shell ("XXXXX"), vbHide to hide the shelled app while it's running or I can use the ExecCmd approach from MS knowledge base article Q129796 to cause my app to wait for the shelled app to end. Is there a way I can accomplish both waiting & hiding at the same time?
Thanks.
-
Dec 19th, 2001, 02:55 AM
#2
Registered User
Option Explicit
VB Code:
Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
Private Const SYNCHRONIZE = &H100000 ' Remove the spaces between the digits
Private Const PROCESS_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)
Private Const STATUS_TIMEOUT = &H102
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessID As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public sub SyncShell(PathName, Optional WindowStyle As VbAppWinStyle = vbMinimizedFocus)
'Yonatan, modified by Nucleus
Dim dwProcessID As Long, hProcess As Long
dwProcessID = Shell(PathName, WindowStyle)
hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, dwProcessID)
If hProcess Then
Do
DoEvents
Loop While WaitForSingleObject(hProcess, 0) = STATUS_TIMEOUT
end if
End Sub
Usage:
call syncshell("c:\temp\test.bat")
To hide the shelled app pass vbHide as the second argument
-
Dec 19th, 2001, 12:08 PM
#3
Thanks for the reply. It really helped.
-
Dec 19th, 2001, 05:19 PM
#4
Registered User
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|