清理任务栏残留图标VB6版 附源程序
2006-09-20 11:31
253 查看
今日的工作中要强制结束另外一个进程,但是那个进程却拥有任务栏图标,在强制结束后它的任务栏图标没有被清除...呵呵,网上找不到这样的的函数,不过有个Delphi版,那只有俺亲自动手改写它了,...
下面是我写的VB6源代码,需要就拿去..不需要的就学习..呵呵
'程序设计:唐细刚
'清理任务栏残留图标 2006-9-20
'我想任何人都遇到过这样的情况:
'任务栏右下角的快捷图标有时并不会随着程序的关闭而消失
'只有当鼠标划过时才消失
'下面的函数可以通过自动划过并清除这些图标
Option Explicit
Private Declare Function RedrawWindow Lib "user32" (ByVal hwnd As Long, lprcUpdate As Long, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
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 Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
x As Long
y As Long
End Type
Private Const RDW_INVALIDATE = &H1
Private Const RDW_ERASE = &H4
Private Const RDW_UPDATENOW = &H100
Private Const SM_CXSMICON = 49
Private Const SM_CYSMICON = 50
Public Sub RemoveDeadIconFromSysTray()
Dim TrayWindow As Long
Dim WindowRect As RECT
Dim SmallIconWidth As Long
Dim SmallIconHeight As Long
Dim CursorPos As POINTAPI
Dim Row As Long
Dim Col As Long
'获得任务栏句柄和边框
TrayWindow = FindWindowEx(FindWindow("Shell_TrayWnd", vbNullString), 0, "TrayNotifyWnd", vbNullString)
If GetWindowRect(TrayWindow, WindowRect) = 0 Then Exit Sub
'获得小图标大小
SmallIconWidth = GetSystemMetrics(SM_CXSMICON)
SmallIconHeight = GetSystemMetrics(SM_CYSMICON)
'保存当前鼠标位置
Call GetCursorPos(CursorPos)
'使鼠标快速划过每个图标
For Row = 0 To (WindowRect.Bottom - WindowRect.Top) / SmallIconHeight
For Col = 0 To (WindowRect.Right - WindowRect.Left) / SmallIconWidth
Call SetCursorPos(WindowRect.Left + Col * SmallIconWidth, WindowRect.Top + Row * SmallIconHeight)
Call Sleep(0)
Next
Next
'恢复鼠标位置
Call SetCursorPos(CursorPos.x, CursorPos.y)
'重画任务栏
Call RedrawWindow(TrayWindow, 0, 0, RDW_INVALIDATE Or RDW_ERASE Or RDW_UPDATENOW)
End Sub
(请参考Delphi版:清理任务栏残留图标Delphi版 附源程序)
http://blog.csdn.net/tanaya/archive/2006/09/20/1253004.aspx
下面是我写的VB6源代码,需要就拿去..不需要的就学习..呵呵
'程序设计:唐细刚
'清理任务栏残留图标 2006-9-20
'我想任何人都遇到过这样的情况:
'任务栏右下角的快捷图标有时并不会随着程序的关闭而消失
'只有当鼠标划过时才消失
'下面的函数可以通过自动划过并清除这些图标
Option Explicit
Private Declare Function RedrawWindow Lib "user32" (ByVal hwnd As Long, lprcUpdate As Long, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
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 Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
x As Long
y As Long
End Type
Private Const RDW_INVALIDATE = &H1
Private Const RDW_ERASE = &H4
Private Const RDW_UPDATENOW = &H100
Private Const SM_CXSMICON = 49
Private Const SM_CYSMICON = 50
Public Sub RemoveDeadIconFromSysTray()
Dim TrayWindow As Long
Dim WindowRect As RECT
Dim SmallIconWidth As Long
Dim SmallIconHeight As Long
Dim CursorPos As POINTAPI
Dim Row As Long
Dim Col As Long
'获得任务栏句柄和边框
TrayWindow = FindWindowEx(FindWindow("Shell_TrayWnd", vbNullString), 0, "TrayNotifyWnd", vbNullString)
If GetWindowRect(TrayWindow, WindowRect) = 0 Then Exit Sub
'获得小图标大小
SmallIconWidth = GetSystemMetrics(SM_CXSMICON)
SmallIconHeight = GetSystemMetrics(SM_CYSMICON)
'保存当前鼠标位置
Call GetCursorPos(CursorPos)
'使鼠标快速划过每个图标
For Row = 0 To (WindowRect.Bottom - WindowRect.Top) / SmallIconHeight
For Col = 0 To (WindowRect.Right - WindowRect.Left) / SmallIconWidth
Call SetCursorPos(WindowRect.Left + Col * SmallIconWidth, WindowRect.Top + Row * SmallIconHeight)
Call Sleep(0)
Next
Next
'恢复鼠标位置
Call SetCursorPos(CursorPos.x, CursorPos.y)
'重画任务栏
Call RedrawWindow(TrayWindow, 0, 0, RDW_INVALIDATE Or RDW_ERASE Or RDW_UPDATENOW)
End Sub
(请参考Delphi版:清理任务栏残留图标Delphi版 附源程序)
http://blog.csdn.net/tanaya/archive/2006/09/20/1253004.aspx
相关文章推荐
- 清理任务栏残留图标VB6版 附源程序
- 清理任务栏残留图标Delphi版 附源程序 .
- 清理任务栏残留图标Delphi版 附源程序
- 清理任务栏残留图标Delphi版 附源程序
- 清除异常关闭进程的任务栏托盘区残留图标
- 清理win7任务栏图标
- 【进程处理】4,刷新任务栏托盘区,清除异常关闭进程的残留图标
- //刷新任务栏图标 终止别的进程序有些程序有托盘会残留
- windows清理图标缓存并重新加载
- 360不显示图标(清理系统图标缓存数据库)
- 如何改变ISA或WSUS在任务栏图标的运行状态
- 处理win7任务栏通知区域图标异常问题
- Windows Server 2016-清理残留域控信息
- 任务栏程序图标显示白色的解决方法
- 如何隐藏应用程序的任务栏图标zz
- 对话框修改左上角的图标和任务栏里图标
- 通过修改注册表缩小任务栏窗口图标尺寸[转载]
- 如何在任务栏添加托盘图标
- 隐藏窗口任务栏图标
- C#编写最小化时隐藏为任务栏图标的Window appllication.