VB 高手帮忙,关于获取IE主窗口类名为Internet Explorer_Server它的名柄。函数声明了的。把问题看明白哈。
Hand1=FindWindow("IEFrame",Str)'IEFrame是类名,str是窗体名Hand2=FindWindowEx(Hand1,0&,"Intern...
Hand1 = FindWindow("IEFrame", Str) 'IEFrame 是类名,str 是窗体名
Hand2 = FindWindowEx(Hand1, 0&, "Internet Explorer_Server", vbNullString)
Hand1返回的值与SPY++查看的值是一样,但Hand2返回的值却是0,没有成功。
也就是无法获得IE主窗口的句柄。 展开
Hand2 = FindWindowEx(Hand1, 0&, "Internet Explorer_Server", vbNullString)
Hand1返回的值与SPY++查看的值是一样,但Hand2返回的值却是0,没有成功。
也就是无法获得IE主窗口的句柄。 展开
3个回答
展开全部
’看来你不会用spy++,给你写个测试例,一看就会明白的:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim myhwnd As Long
With CreateObject("InternetExplorer.Application")
.Visible = True
.navigate "http://www.baidu.com"
Do Until .Readystate = 4
DoEvents
Loop
End With
myhwnd = FindWindow(vbNullString, "百度一下,你就知道 - Microsoft Internet Explorer")
myhwnd = FindWindowEx(myhwnd, 0&, "Shell DocObject View", vbNullString)
myhwnd = FindWindowEx(myhwnd, 0&, "Internet Explorer_Server", vbNullString)
MsgBox IIf(myhwnd > 0, "true", "false")
End Sub
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim myhwnd As Long
With CreateObject("InternetExplorer.Application")
.Visible = True
.navigate "http://www.baidu.com"
Do Until .Readystate = 4
DoEvents
Loop
End With
myhwnd = FindWindow(vbNullString, "百度一下,你就知道 - Microsoft Internet Explorer")
myhwnd = FindWindowEx(myhwnd, 0&, "Shell DocObject View", vbNullString)
myhwnd = FindWindowEx(myhwnd, 0&, "Internet Explorer_Server", vbNullString)
MsgBox IIf(myhwnd > 0, "true", "false")
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
应该是下面这样,你参考一下:
Dim lRet As Long
lRet = FindWindow("IEFrame", "VB 高手帮忙,关于获取IE主窗口类名为Internet Explorer_Server它的名柄。函数声明了的。把问题看明白哈。_百度知道 - Windows Internet Explorer")
lRet = FindWindowEx(lRet, 0&,"Frame Tab", "")
lRet = FindWindowEx(lRet, 0&,"TabWindowClass", "VB 高手帮忙,关于获取IE主窗口类名为Internet Explorer_Server它的名柄。函数声明了的。把问题看明白哈。_百度知道 - Windows Internet Explorer")
lRet = FindWindowEx(lRet, 0&,"Shell DocObject View", "")
lRet = FindWindowEx(lRet, 0&,"Internet Explorer_Server", "")
Dim lRet As Long
lRet = FindWindow("IEFrame", "VB 高手帮忙,关于获取IE主窗口类名为Internet Explorer_Server它的名柄。函数声明了的。把问题看明白哈。_百度知道 - Windows Internet Explorer")
lRet = FindWindowEx(lRet, 0&,"Frame Tab", "")
lRet = FindWindowEx(lRet, 0&,"TabWindowClass", "VB 高手帮忙,关于获取IE主窗口类名为Internet Explorer_Server它的名柄。函数声明了的。把问题看明白哈。_百度知道 - Windows Internet Explorer")
lRet = FindWindowEx(lRet, 0&,"Shell DocObject View", "")
lRet = FindWindowEx(lRet, 0&,"Internet Explorer_Server", "")
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
说明类名不对
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询