PostMessage无法关闭窗口

kris2010 2007-11-06 04:42:36
我使用SHDocVw.InternetExplorer查找指定web页的html源文件
每次执行时都产生iexplore.exe的进程,并建立3个线程
如果不理会就会持续的占用内存,所以用PostMessage函数关闭线程,但似乎没有效果,iexplore.exe进程依然存在?
如果我先开一个ie窗口,再运行我的程序,就会在当前的窗口建立线程。
想问一下怎样使用PostMessage才能正确的关闭进程?
...全文
184 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzyong00 2007-11-07
  • 打赏
  • 举报
回复
dim ie as InternetExplorer
set ie=new InternetExplorer
..............
ie.quit
set ie=nothing
kris2010 2007-11-07
  • 打赏
  • 举报
回复
程序运行时并没有窗口,而是隐式的建立了一个ie的进程。
mndsoft 2007-11-06
  • 打赏
  • 举报
回复
先给个代码示例,更多请去枕善居VB.NET博客找一找,http://www.mndsoft.com

Option Explicit


Private Declare Function PostMessage Lib "user32" _
Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long


Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal szClass$, ByVal szTitle$) As Long
Private Const WM_CLOSE = &H10


Private Sub Command1_Click()
Dim hWnd, retval As Long
Dim WinTitle As String
WinTitle = "Recycle Bin" '<- Title of Window
hWnd = FindWindow(vbNullString, WinTitle)
retval = PostMessage(hWnd, WM_CLOSE, 0&, 0&)
End Sub

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧