Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, ByRef lpdwProcessId As Long) As Long Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpszClassName As String, ByVal lpszWindowName As String) As Long
Dim hProc As Long Dim PID As Long Dim threadid As Long hProc = FindWindow("Notepad", vbNullString) threadid = GetWindowThreadProcessId(hProc, PID) ←ここの処理でエラーになる