Citation :
Option Explicit
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, ByVal lParam As Long) As Long
Private Const WM_CLOSE = &H10
Private Sub Form_Load()
Dim hWnd As Long
hWnd = FindWindow(vbNullString, "Lecteur CD" )
If hWnd <> 0 Then
Call PostMessage(hWnd, WM_CLOSE, 0, 0)
Else
MsgBox "Impossible de trouver la fenêtre !", vbExclamation
End If
End Sub
|