|
-
Sep 23rd, 2000, 01:45 AM
#1
Thread Starter
Member
I used the command "shell" to open a DOS program and my problem is that once the DOS program is done, the windows stay open. I tried to hide the windows, but it will just stay loaded in memory but invisible.
I'm pretty sure I could close it using the ID it return but I have no idea how to do it in VB.
-
Sep 23rd, 2000, 04:40 AM
#2
_______
<?>
Code:
'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
Private Sub Command1_Click()
Dim h As Long
h = Shell(Environ("COMSPEC") & " /C yourpath/yourfile.ext")
DoEvents
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
-
Sep 23rd, 2000, 04:55 AM
#3
Thread Starter
Member
-
Sep 23rd, 2000, 11:50 AM
#4
Or use SendMessage.
Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Const WM_CLOSE = &H10
Private Sub Command1_Click()
Dim hDos As Long
hDos = FindWindowEx(0, 0, "tty", "MS-DOS Prompt")
If hDos <> 0 Then
SendMessage hDos, WM_CLOSE, 0, 0
DestroyWindow hDos
End If
End Sub
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
|