vb 关闭窗口

引用:http://tieba.baidu.com/f?kz=622302614

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
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 SetForegroundWindow Lib "user32" (ByVal hwnd As Long) 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 closeWin As New Class1
Private Const wm_close = &H10
Private b As Integer


Private Sub Command1_Click()
'a = FindWindow(vbNullString, "我的电脑")
a = FindWindow(vbNullString, "Internet Explorer 无法显示该网页 - Windows Internet Explorer")'里面是窗口的标题
PostMessage a, wm_close, 0, 0

End Sub

posted @ 2011-12-09 14:33  镇水古月  阅读(387)  评论(0编辑  收藏  举报