用vb關(guān)閉其他應(yīng)用程序的窗體(已知窗口句柄)
'我寫了一個(gè)代碼,,用findwindow查找窗口獲取窗口句柄,,然后用sendmessage發(fā)送關(guān)閉信息使其關(guān)閉。但是我在findwindow函數(shù)里面顯示返回值,句柄是對(duì)的,??墒莝endmessage函數(shù)好像沒用一樣,,連最簡(jiǎn)單的窗體(如vbs彈窗,,vb測(cè)試的窗體沒用cancel)都關(guān)不了,請(qǐng)問是什么問題?也沒用報(bào)錯(cuò),,但是關(guān)不掉,,我也沒加語句 on error resume next 或者goto。別說直接結(jié)束,,我本身做彈窗攔截,,一出來就關(guān),不要手動(dòng)操作,,還不如直接點(diǎn)關(guān)閉按鈕關(guān)掉,。我的代碼:Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Longprivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (Byval hwnd As Long, Byval wMsg As Long,Byval wParam As Long,lParam As Any) As Long '聲明a = FindWindow(vbNullString, "標(biāo)題")'sendmessage關(guān)窗口:SendMessage a, WM_CLOSE, 0, 0自己寫的,有什么不對(duì)求大神請(qǐng)教,。
你的WM_CLOSE沒有定義,,當(dāng)然不行
定義一個(gè)
Private Const WM_CLOSE = &H10
或直接
SendMessage a, &H10, 0, 0
Tags:句柄窗體應(yīng)用程序