Advertisement
4_2005-2006 Windows API Call/ Explanation #151158

Close a window

Close a window when you know the title of this window. Uses the API FindWindow and PostMessage.

AI

สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ซอร์สโค้ด
original-source
Option Explicit
Private Declare Function PostMessage Lib "user32" _
  Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindow Lib "user32" _
  Alias "FindWindowA" (ByVal szClass$, ByVal szTitle$) As Long
Private Const WM_CLOSE = &H10
Private Sub Command1_Click()
  Dim hWnd, retval As Long
  Dim WinTitle As String
  WinTitle = "Recycle Bin" '<- Title of Window
  hWnd = FindWindow(vbNullString, WinTitle)
  retval = PostMessage(hWnd, WM_CLOSE, 0&, 0&)
End Sub
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine