2010年7月29日 星期四

get active window processID

Declare Function GetForegroundWindow Lib "user32.dll" () As Int32

Declare Function GetWindowThreadProcessId Lib "user32.dll" ( _
ByVal hwnd As Int32, _
ByRef lpdwProcessId As Int32) As Int32

Public Function RetCurTitle() As String
Dim processID As Int32
GetWindowThreadProcessId(GetForegroundWindow(), processID)
Return Process.GetProcessById(processID).MainWindowTitle
End Function

沒有留言:

張貼留言