玩酷之家

 找回密码
 立即注册
查看: 59|回复: 0

VB Explorer 崩溃重启后的任务栏图标重建

[复制链接]
发表于 2021-1-8 16:44:29 | 显示全部楼层 |阅读模式
以下代码来自可爱猪(lovelypig43@163.com ),为了使代码更好用,下面的代码在源代码中有删改!
  1. 'Module1 中

  2. 'Explorer 崩溃重启后的任务栏图标重建
  3. '作者 可爱猪
  4. 'Email:lovelypig43@163.com

  5. Option Explicit

  6. Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  7. Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
  8. Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

  9. Public Const GWL_WNDPROC = (-4)
  10. Private Const WM_USER = &H400
  11. Private Const WM_NOTIFYICON = WM_USER + &H100
  12. Private Const NIF_ICON = &H2
  13. Private Const NIF_TIP = &H4
  14. Private Const NIF_MESSAGE = &H1
  15. Private Const NIM_ADD = &H0

  16. Public Type NOTIFYICONDATA
  17. cbSize As Long
  18. hwnd As Long
  19. uID As Long
  20. uFlags As Long
  21. uCallbackMessage As Long
  22. hIcon As Long
  23. szTip As String * 64
  24. End Type

  25. Public MsgTaskbarRestart As Long
  26. Public OldWndProc As Long
  27. Public ano As NOTIFYICONDATA

  28. Function WndProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  29. If uMsg <> MsgTaskbarRestart Then
  30. WndProc = CallWindowProc(OldWndProc, hwnd, uMsg, wParam, lParam)
  31. Else
  32. MsgBox "请在这里填写添加拖盘图标的代码"
  33. WndProc = True
  34. End If
  35. End Function
复制代码

  1. 'Form1 中

  2. 'Explorer 崩溃重启后的任务栏图标重建
  3. '作者 可爱猪
  4. 'Email:lovelypig43@163.com

  5. Option Explicit

  6. Private Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long

  7. Private Const NIM_DELETE = &H2

  8. Private Sub Form_Load()
  9. MsgTaskbarRestart = RegisterWindowMessage("TaskbarCreated")
  10. OldWndProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WndProc)
  11. End Sub

  12. Private Sub Form_Unload(Cancel As Integer)
  13. Call SetWindowLong(hwnd, GWL_WNDPROC, OldWndProc)
  14. End Sub
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|玩酷之家 ( 鄂ICP备14012049号 )

GMT+8, 2021-1-25 17:31 , Processed in 1.092002 second(s), 17 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表