当前位置: 代码迷 >> PB >> 最小化到系统托盘的有关问题
  详细解决方案

最小化到系统托盘的有关问题

热度:161   发布时间:2016-04-29 05:24:47.0
最小化到系统托盘的问题
程序最小化到系统托盘后,如果系统意外出现资源管理器(explorer.exe)重启后,我的程序的系统托盘图标,就不会重建了,而进程里能看到我的程序,我只能通过 任务管理去结束进程,然后重新开程序,才行,请问有什么别的办法吗,可以在系统资源管理器重启加载的时候,把我的图标也加载进去呢?

以下是我用的api调用函数:
Public Function Integer Shell_NotifyIcon(long dwmessage,any lpdata) Library "shell32" Alias for "Shell_NotifyIconA;Ansi"
Public Function Long LoadImage(long hinst,string lpsz,long un1,long n1,long n2,long un2) Library "user32" Alias For "LoadImageA;Ansi"
Public Function Long DestroyIcon(long hicon) Library "user32" Alias For "DestroyIcon"
Public Function Long SetForegroundWindow(long hwnd) Library "user32" Alias For "SetForegroundWindow"
Public Function Long OpenIcon(long hwnd) Library "user32" Alias For "OpenIcon"

------解决思路----------------------
引用:
程序最小化到系统托盘后,如果系统意外出现资源管理器(explorer.exe)重启后,我的程序的系统托盘图标,就不会重建了,而进程里能看到我的程序,我只能通过 任务管理去结束进程,然后重新开程序,才行,请问有什么别的办法吗,可以在系统资源管理器重启加载的时候,把我的图标也加载进去呢?

以下是我用的api调用函数:
Public Function Integer Shell_NotifyIcon(long dwmessage,any lpdata) Library "shell32" Alias for "Shell_NotifyIconA;Ansi"
Public Function Long LoadImage(long hinst,string lpsz,long un1,long n1,long n2,long un2) Library "user32" Alias For "LoadImageA;Ansi"
Public Function Long DestroyIcon(long hicon) Library "user32" Alias For "DestroyIcon"
Public Function Long SetForegroundWindow(long hwnd) Library "user32" Alias For "SetForegroundWindow"
Public Function Long OpenIcon(long hwnd) Library "user32" Alias For "OpenIcon"


我也碰到过,没有好办法,没有一个具体的消息是在结束资源管理器时触发的,如果真要解决,估计要用底层钩子应该可以,用pb是写不了的,用c应该可以
  相关解决方案