VB中的FindWindow返回值一直为0
PrivateDeclareFunctionFindWindowLib"user32"Alias"FindWindowA"(ByVallpClassNameAsStrin...
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Form_Load()
Dim hWnd As Long
Dim x As String
Do While x <> "a"
hWnd = FindWindow(0&, 0&)
x = InputBox(hWnd)
Loop
End Sub
可以看到hWnd一直是0,不知道是为什么 展开
Private Sub Form_Load()
Dim hWnd As Long
Dim x As String
Do While x <> "a"
hWnd = FindWindow(0&, 0&)
x = InputBox(hWnd)
Loop
End Sub
可以看到hWnd一直是0,不知道是为什么 展开
2个回答
展开全部
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Form_Load()
Dim hWnd As Long
Dim x As String
Do While x <> 0
hWnd = FindWindow(vbNullString, x)
x = InputBox(hWnd)
Loop
End Sub
FindWindow里需要传入值才能获取句柄
追问
传入0的话是匹配任意类和窗口标题,不是吗
追答
那就用FindWindow(vbNullString, vbNullString),传入空值
或者
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
hWnd = FindWindow(0&, 0&)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询