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

G

Guest

Hi EveryBody:

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

any help will be appreciated

regard's

Husam
 
G

Guest

' 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top