Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
Posted: Nov 3rd, 2003 05:53 AM Post subject: Closing NOTEPAD using Code! |
|
|
| Code: | Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_CLOSE = &H10
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Sub Form_Load()
Dim l As Long
Dim r As Long
l = FindWindow("Notepad", vbNullString)
Debug.Print l
If l <> 0 Then
SendMessage l, WM_CLOSE, 0, 0
End If
Do Until l = 0
l = FindWindowEx(0, l, "Notepad", vbNullString)
Debug.Print l
If l <> 0 Then
SendMessage l, WM_CLOSE, 0, 0
End If
Loop
End Sub |
_________________ Code Snippets, Tutorials, Utilities, Controls
Low cost Web Hosting
Hosting starts at as low as $4 per year!
Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags! |
|