Visual Basic Tips


ウィンドウの検索(API)


ウィンドウのキャプションを指定してウィンドウハンドルを取得します。そのハンドルが0でなければそのウィンドウは存在している事になります。

Private Sub Form_Load()
  
Dim hWnd As Long

  hWnd = FindWindow(vbNullString, Me.Caption)
  
If hWnd = 0 Then
  
Else
    MsgBox "起動されています"
  
End If
End Sub

'----------------------------------------------------------
'
'----------------------------------------------------------
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long


DownLoad vbtips074.lzh 2KB (VB6.0)