__init__.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:OSPTF 作者: xSploited 项目源码 文件源码
def SetupEnvironment():
    HKEY_LOCAL_MACHINE = -2147483646 # Avoid pulling in win32con for just these...
    KEY_QUERY_VALUE = 0x1
    # Open the root key once, as this is quite slow on NT.
    try:
        keyName = "SOFTWARE\\Python\\PythonCore\\%s\\PythonPath\\win32com" % sys.winver
        key = win32api.RegOpenKey(HKEY_LOCAL_MACHINE , keyName, 0, KEY_QUERY_VALUE)
    except (win32api.error, AttributeError):
        key = None

    try:
        found = 0
        if key is not None:
            try:
                __path__.append( win32api.RegQueryValue(key, "Extensions" ))
                found = 1
            except win32api.error:
                # Nothing registered
                pass
        if not found:
            try:
                __path__.append( win32api.GetFullPathName( __path__[0] + "\\..\\win32comext") )
            except win32api.error:
                # Give up in disgust!
                pass

        # For the sake of developers, we also look up a "BuildPath" key
        # If extension modules add support, we can load their .pyd's from a completely
        # different directory (see the comments below)
        try:
            if key is not None:
                global __build_path__
                __build_path__ = win32api.RegQueryValue(key, "BuildPath")
                __path__.append(__build_path__)
        except win32api.error:
            # __build_path__ neednt be defined.
            pass
        global __gen_path__
        if key is not None:
            try:
                __gen_path__ = win32api.RegQueryValue(key, "GenPath")
            except win32api.error:
                pass
    finally:
        if key is not None:
            key.Close()

# A Helper for developers.  A sub-package's __init__ can call this help function,
# which allows the .pyd files for the extension to live in a special "Build" directory
# (which the win32com developers do!)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号