1
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 Integer
Dim processID As Int32
Return GetWindowThreadProcessId(GetForegroundWindow(), processID)
End Function
我使用上述函数来获取活动窗口的进程ID。它返回4060AppActivate不适用于进程ID
之后,我打电话
AppActivate(4060)
和应用程序崩溃。我尝试使用整数变量来代替4060,但同样的问题。
您没有正确使用GetWindowThreadProcessId()。您正在返回拥有窗口的线程的*线程ID *,而不是进程ID。 –