本文主要是介绍清理任务栏残留图标VB6版 附源程序,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
今日的工作中要强制结束另外一个进程,但是那个进程却拥有任务栏图标,在强制结束后它的任务栏图标没有被清除...呵呵,网上找不到这样的的函数,不过有个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 LongPrivate 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 RECTLeft As LongTop As LongRight As LongBottom As Long
End Type
Private Type POINTAPIx As Longy 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 = 50Public Sub RemoveDeadIconFromSysTray()Dim TrayWindow As LongDim WindowRect As RECTDim SmallIconWidth As LongDim SmallIconHeight As LongDim CursorPos As POINTAPIDim Row As LongDim 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) / SmallIconHeightFor Col = 0 To (WindowRect.Right - WindowRect.Left) / SmallIconWidthCall SetCursorPos(WindowRect.Left + Col * SmallIconWidth, WindowRect.Top + Row * SmallIconHeight)Call Sleep(10) '发现这个地方参数为 0 的时候,有时候是不够的NextNext'恢复鼠标位置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版 附源程序的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!