|
-
Aug 29th, 2000, 06:49 PM
#1
Thread Starter
Lively Member
OK, I realize this one might be very involved, in anyone has a sample they would be willing to share please email to [email protected]
Here is the question:
I have a dos program that running out of a vb app using the Shell command. I want to know 2 things, first how do you tell the app when the shell command has finished or the dos thread has finished. Second, is there a way to show a progress bar while this shell command is running. The second is not that important as long as the program knows when the process is done I can slap a Picture or Text saying it is done. Thanks.
Ed Farias
-
Aug 29th, 2000, 06:57 PM
#2
_______
<?>
this is all I've ever touched in dos
perhpas it's not even close to what you are doing
I use a bat file run from a dos command
Code:
'to delete the history and temp internet files.
'copy the 2 lines below into a notepad file and save it as cleaner.bat
'to save as bat you need to put it in quotes save as "Cleaner.bat"
'DELTREE /Y C:\WINDOWS\HISTORY\*.*
'DELTREE /Y C:\WINDOWS\TEMPOR~1\*.*
'
'to close the dow window when done use the Environ("COMSPEC") functio
'this will find the command com no matter where stored on system
'this is your form code
Option Explicit
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
'Use this line in click event (substitute the dir for your own):
'where ever you put the file {cleaner.bat}
'call the bat file
Private Sub Command1_Click()
Dim h As Long
h = Shell(Environ("COMSPEC") & " /C C:\Cleaner.bat")
DoEvents
'I think you could message here as the shell command
'closes the dos window when finished.
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 29th, 2000, 08:22 PM
#3
Guru
You have to use the WaitForSingleObject API.
Code:
Option Explicit
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
Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
Private Const SYNCHRONIZE = &H100000
Private Const PROCESS_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF
Private Const INFINITE = &HFFFFFFFF
Sub DoAnEverydayNormalShellButDontStopUntilTheDosThreadIsDone(PathName, Optional WindowStyle As VbAppWinStyle = vbMinimizedFocus)
Dim lProcessID As Long, hProcess As Long
lProcessID = Shell(PathName, WindowStyle)
hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, lProcessID)
Call WaitForSingleObject(hProcess, INFINITE)
Call CloseHandle(hProcess)
End Sub
Then, just use the DoAnEverydayNormalShellButDontStopUntilTheDosThreadIsDone. Use this like you use an everyday normal shell, but it won't stop until the dos thread is done.
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
|