How can I use API to do.....

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi EveryBody:

How can I use win32 API to destroy or close spicfied window ?

any help will be appreciated

regard's

Husam
 
' API & Constant

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal
lParam As Int32) As Int32
Private Const WM_CLOSE = &H10

' Put this behind a button for example:

Dim intHandle As Integer = FindWindow("Notepad", vbNullString)
If intHandle > 0 Then
SendMessage(intHandle, WM_CLOSE, 0, 0)
End If

I used 'Notepad in the above example & found the handle by passing the
classname to the FindWindow function

I hope this helps
 
Back
Top