我想用vb6.0寫一個程式
用command按一下就可以關閉
已開啟的執行檔不知道這樣可行嗎?
請各位前輩指點一下
2006-03-09 17:13:26 · 1 個解答 · 發問者 Nick 5 in 電腦與網際網路 ➔ 程式設計
'要先得知你要關閉程式的視窗標題,如先開啟一個空的記事本,它的視窗標題是"未命名 - 記事本"Const WM_CLOSE = &H10Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Sub Command1_Click()Dim H As Long'先利用FindWindow找到此程式的hWndH = FindWindow(vbNullString, "未命名 - 記事本")'用PostMessage送出WM_CLOSE指令來關閉程式If H Then PostMessage H, WM_CLOSE, 0, 0&End Sub
2006-03-09 15:32:35 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋