vb6.0如何实现关闭WebBrowser1打开的IE浏览器
用vb6.0的WebBrowser1做的一个小软件,当鼠标点击网页的链接后自动在IE里面打开,这一个已经实现,但在软件里面如何控制5秒后就自动关闭打开的IE窗口,求可行的...
用vb6.0的WebBrowser1做的一个小软件,当鼠标点击网页的链接后自动在IE里面打开,这一个已经实现,但在软件里面如何控制5秒后就自动关闭打开的IE窗口,求可行的详细代码。
展开
3个回答
展开全部
Private Declare Function GetTickCount Lib "kernel32" () As Long 'API函数调用
Private Sub Command1_Click() '延时前面加入你自己的代码
delay (5000) '延时5秒
Killprocess ("IEXPLORE.exe") '实现关闭IE,不管有多少窗口都能关闭
End Sub
Public Sub delay(t As Long) '延时程序
Dim temp As Long
temp = GetTickCount
While GetTickCount - temp <= t
DoEvents
Wend
End Sub
Private Sub Killprocess(s As String) '终止进程
On Error Resume Next
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name='" & s & "'")
For Each objProcess In colProcessList
objProcess.Terminate '结束进程
Next
Set objProcess = Nothing
Set colProcessList = Nothing
Set objWMIService = Nothing
End Sub
Private Sub Command1_Click() '延时前面加入你自己的代码
delay (5000) '延时5秒
Killprocess ("IEXPLORE.exe") '实现关闭IE,不管有多少窗口都能关闭
End Sub
Public Sub delay(t As Long) '延时程序
Dim temp As Long
temp = GetTickCount
While GetTickCount - temp <= t
DoEvents
Wend
End Sub
Private Sub Killprocess(s As String) '终止进程
On Error Resume Next
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name='" & s & "'")
For Each objProcess In colProcessList
objProcess.Terminate '结束进程
Next
Set objProcess = Nothing
Set colProcessList = Nothing
Set objWMIService = Nothing
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询