Trả lời mọi thắc mắc của bạn


Liệt kê những bài viết mới nhất

Bài viết mớiNgười viếtVào lúc
paltalk code
Sun Mar 06, 2016 1:28 am
vb ListView
Sun Mar 06, 2016 1:00 am
Find occurent of character in string nth
Sat Jan 16, 2016 10:48 pm
Send listbox items to textbox
Wed Jan 13, 2016 9:55 pm
[VB] Find word in listbox items
Wed Jan 13, 2016 7:55 pm
code cho hint2
Wed Jan 13, 2016 3:22 pm
[vb] Font RTB
Tue Dec 29, 2015 10:29 am
[vb] selected text RTB
Tue Dec 29, 2015 9:06 am
[vb] send unicode text
Tue Dec 29, 2015 9:03 am
[vb] format multi richtextbox
Tue Dec 29, 2015 9:01 am
Trang web tai cac bang sang che
Mon Dec 28, 2015 1:28 pm
[VB] Sử dụng resource của chính chương trình
Sat Dec 26, 2015 8:56 pm
[vb] Phân biệt class và Module
Thu Dec 24, 2015 2:39 pm
[VB] MY API and Functions declaration
Mon Dec 21, 2015 1:45 pm
[vb] Khai báo và sử dụng hàm Setforeground
Mon Dec 21, 2015 1:29 pm
[VB] Sử dụng hàm Sendmessage để gửi tiếng việt, và format richtextbox
Mon Dec 21, 2015 1:26 pm
[VB] Find menu context handle/ID by SPY++
Fri Dec 18, 2015 1:20 pm
[VB] Find menu context handle/ID - Vu Hai Ninh
Fri Dec 18, 2015 1:00 pm
[VB] Find menu context handle/ID
Fri Dec 18, 2015 12:54 pm
[VB] Sleep in VB program
Thu Dec 17, 2015 7:48 pm
[VB] CLose window if found
Wed Dec 16, 2015 7:07 pm
[VB] Không cho thay đổi kích cỡ form khi chạy
Wed Dec 16, 2015 3:28 pm
[VB] Không cho thay đổi text box khi chạy
Wed Dec 16, 2015 3:22 pm
[VB] Tìm cửa sổ và Button bằng FindWindow & FindWindowsEx
Wed Dec 16, 2015 3:16 pm
[VB] Xóa text mặc định của text box khi click
Wed Dec 16, 2015 3:12 pm


You are not connected. Please login or register

[VB] CLose window if found

Go down  Message [Page 1 of 1]

1[VB] CLose window if found  Empty [VB] CLose window if found Wed Dec 16, 2015 7:07 pm

HdAd

HdAd
Admin

Try using something like this. using 
Code:
Process.MainWindowTitle
[size]
 to get the Title Text and 
[/size]
Code:
Process.CloseMainWindow
[size]
 to close down the UI, its a little more graceful than killing the Process.[/size]
Note: Contains does a case-sensitive search
Code:
Imports System.Diagnostics
Module Module1

    Sub Main()
        Dim myProcesses() As Process = Process.GetProcesses

        For Each p As Process In myProcesses
            If p.MainWindowTitle.Contains("Notepad") Then
                p.CloseMainWindow()
            End If
        Next

    End Sub

End Module


As far as Win API functions try something like this. Be aware if you close the parent window youwill close the children also.
Code:
Module Module1
    Private Declare Auto Function FindWindowEx Lib "user32" (ByVal parentHandle As Integer, _
                                              ByVal childAfter As Integer, _
                                              ByVal lclassName As String, _
                                              ByVal windowTitle As String) As Integer

    Private Declare Auto Function PostMessage Lib "user32" (ByVal hwnd As Integer, _
                                                            ByVal message As UInteger, _
                                                            ByVal wParam As Integer, _
                                                            ByVal lParam As Integer) As Boolean

    Dim WM_QUIT As UInteger = &H12
    Dim WM_CLOSE As UInteger = &H10


    Sub Main()
        Dim handle As Integer = FindWindowEx(0, 0, Nothing, "YourFormsTitle")
        PostMessage(handle, WM_CLOSE, 0, 0)
    End Sub

End Module

https://hoidap.forumotion.com

Back to top  Message [Page 1 of 1]

Similar topics

-

» Find open window (VB)

Permissions in this forum:
You cannot reply to topics in this forum