| Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As
Long 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 GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Const SW_SHOWNORMAL = 1 Const WM_CLOSE = &H10 Const gcClassnameMSWord = "OpusApp" Const gcClassnameMSExcel = "XLMAIN" Const gcClassnameMSIExplorer = "IEFrame" Const gcClassnameMSVBasic = "wndclass_desked_gsk" Const gcClassnameNotePad = "Notepad" Const gcClassnameMyVBApp = "ThunderForm" Private Sub Form_Load() 'VbAndJava 1999/2000 'Guerrault Yonni 'E-Mail : Yonni4@iFrance.com Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String Ret = InputBox("Entrez exactement le titre de la fenêtre : " + Chr$(13) + Chr$(10) + "Respectez la casse.") WinWnd = FindWindow(vbNullString, Ret) If WinWnd = 0 Then MsgBox "Ne peux pas trouver la fenêtre...": Exit Sub ShowWindow WinWnd, SW_SHOWNORMAL lpClassName = Space(256) RetVal = GetClassName(WinWnd, lpClassName, 256) MsgBox "Classname: " + Left$(lpClassName, RetVal) PostMessage WinWnd, WM_CLOSE, 0&, 0& End Sub |