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。 –