用MASM32写的 系统托盘图标管理员 TrayIconMan 0.0.0003

功能

  TrayIconMan可以列举系统托盘区中的图标,提示文本,及它们对应的程序,并控制它们的显示和隐藏状态。
  有些网友反映,在windows xp 使用TrayIconMan来隐藏系统托盘图标,图标只是被转到不活动的区域,并没有真正地从托盘区消失。
  研究发现在启用了任务栏属性中“隐藏不活动的图标”功能的电脑中会出现此情况。
  解决方法有两种:
  一种方法是停用“隐藏不活动的图标”功能
  另一种方法是启用了“隐藏不活动的图标”功能后,把需要让其从托盘区消失的图标设置为“总是显示”
  再用TrayIconMan就可以让相关图标在托盘区隐藏起来了……

下载地址

http://down.51cto.com/data/330739

http://purpleendurer.ys168.com/            (\ myworks \ tools 中)

 

0.0.0.3 的改进 

修正了0.0.0.2版中所显示系统托盘图标对应进程文件说明符中盘符可能不正确的问题。

 

问题分析 

TrayIconMan在Windows XP运行时,会尝试使用GetProcessImageFileName来获取系统托盘图标对应进程文件说明符。返回的对应文件说明符的形式是\Device\HardDiskVolume1\Windows\System32\svchost.exe,在转换成C:\Windows\System32\svchost.exe这样的格式时,0.0.0.2使用的代码为:

    push sizeof szProcImage
    lea  eax, szProcImage
    push eax
    push hProc
    call g_lpfnGetProcessImageFileName

    test eaxeax
    jz   @GetProcImgFileSpecRet ;fail

    lea  eax, szProcImage
    invoke locatePathName ;定位文件路径名的首位置存在ebx中,如\Windows\System32\svchost.exe
    push eax ; 文件路径名的首位置在eax中,push for call lstrcpy()

   ;定位到\Device\HardDiskVolume1
    dec  eax
   ;取最后的数字计算盘符
    mov  albyte ptr [eax]
    sub  al, '1' - 'C'
    mov  ah, ':'
    mov word ptr g_szProcSpec, ax

    push (offset g_szProcSpec)+2
    ;mov eax, offset g_szProcSpec
    ;inc eax
    ;inc eax
    ;push eax
    call lstrcpy

  这个方法在大多数情况下是正确的,但如果系统中存在没有分配盘符的分区的话,那就符盘就可能不正确了。
  在0.0.0.3中改用QueryDosDevice()来精确转换。

 

  附:微软官网对于获取进程对应文件说明符的 best results:

 

 

For best results use the following

For the best results use the following table to convert paths.

Windows 2000 = GetModuleFileName()
Windows XP x32 = GetProcessImageFileName()
Windows XP x64 = GetProcessImageFileName()
Windows Vista = QueryFullProcessImageName()
Windows 7 = QueryFullProcessImageName()


Note: If you are not aware the API GetProcessImageFileName() returns a kernel DOS device path. You can use the following API to map the device paths to a Win32 format.

引自:http://msdn.microsoft.com/en-us/library/windows/desktop/ms684919(v=vs.85).aspx

 

文件信息 

文件说明符 : F:\MASM32\pe-works\TrayIconMan\TrayIconMan.exe
属性 : A---
数字签名:否
PE文件:是
语言 : 中文(中国)
文件版本 : 0.0.0003
说明 : TrayIconMan | 系统托盘图标管理员
版权 : PurpleEndurer
产品版本 : 0.0.0003
产品名称 : TrayIconMan
公司名称 : PurpleEndurer | 紫郢剑侠�I
合法商标 : PurpleEndurer
内部名称 : TrayIconMan
源文件名 : TrayIconMan
创建时间 : 2012-2-17 21:7:20
修改时间 : 2012-2-17 22:5:22
大小 : 8704 字节 8.512 KB
MD5 : d7b0c3b62155b15543fa87a456ca34bf
SHA1: 9BEB81EFAA04A69CF02713D7766FF9BAD62EBA83
CRC32: 8ffff234

你可能感兴趣的:(管理,图标,MASM32,TrayIconMan,系统托盘区)