小编dou*_*ugi的帖子

Python的图标叠加问题

我在这个论坛上找到了一些关于使用Python 2.7和win32com包实现图标覆盖处理程序的方法的例子和主题,但它对我不起作用,我不明白为什么.

我创建了DLL,我注册时没有错误.我也直接尝试过脚本,但它是一样的.这就像从未调用过类.

这是代码:

import win32traceutil

from win32com.shell import shell, shellcon
import pythoncom
import winerror
import os

REG_PATH =r'Software\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers'
REG_KEY = "GdIconOverlayTest"

class GdClass:
    _reg_clsid_='{512AE200-F075-41E6-97DD-48ECA4311F2E}'
    _reg_progid_='GD.TestServer'
    _reg_desc_='gd desc'
    _public_methods_ = ['GetOverlayInfo','GetPriority','IsMemberOf']
    _com_interfaces_=[shell.IID_IShellIconOverlayIdentifier, pythoncom.IID_IDispatch]

    def __init__(self):
        pass

    def GetOverlayInfo(self):
        return (os.path.abspath(r'C:\icons\test.ico'), 0, shellcon.ISIOI_ICONFILE)

    def GetPriority(self):
        return 0

    def IsMemberOf(self, fname, attributes):
        print('ismemberOf', fname, os.path.basename(fname))
        if os.path.basename(fname) == "hello.text":
            return winerror.S_OK
        return winerror.E_FAIL

def DllRegisterServer():
    print "Registering %s" % REG_KEY
    import _winreg
    key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, REG_PATH)
    subkey = _winreg.CreateKey(key, GdClass._reg_progid_)
    _winreg.SetValueEx(subkey, None, …
Run Code Online (Sandbox Code Playgroud)

python windows com shell py2exe

6
推荐指数
1
解决办法
1207
查看次数

标签 统计

com ×1

py2exe ×1

python ×1

shell ×1

windows ×1