主题:用FindWindow获得窗口句柄,为何指定的窗口没打开时FindWindow不返回0?
最近刚开始学VB.NET
我的操作系统winXP sp2
我先在模块里声明FindWindow函数
Module Module1
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
End Module
我建了一个窗体,窗体中加入一个Button按钮,然后在Button1_Click加入代码
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim GameHwnd As Long
GameHwnd = FindWindow(vbNullString, "我的电脑")
If GameHwnd = 0 Then
MsgBox("Error:Can Not Find window!")
Exit Sub
Else
MsgBox(GameHwnd)
End If
End Sub
不管我打没打开“我的电脑”这个窗口,点击Button按钮时GameHwnd都不会返回0,并且每次返回的数都不一样,这是为什么啊??
我的操作系统winXP sp2
我先在模块里声明FindWindow函数
Module Module1
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
End Module
我建了一个窗体,窗体中加入一个Button按钮,然后在Button1_Click加入代码
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim GameHwnd As Long
GameHwnd = FindWindow(vbNullString, "我的电脑")
If GameHwnd = 0 Then
MsgBox("Error:Can Not Find window!")
Exit Sub
Else
MsgBox(GameHwnd)
End If
End Sub
不管我打没打开“我的电脑”这个窗口,点击Button按钮时GameHwnd都不会返回0,并且每次返回的数都不一样,这是为什么啊??