Python win32api 模块,GetProcAddress() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用win32api.GetProcAddress()

项目:grid    作者:russelg    | 项目源码 | 文件源码
def MakeTransparent(self, amount):
        if os.name == 'nt':  # could substitute: sys.platform == 'win32'
            hwnd = self.GetHandle()
            _winlib = win32api.LoadLibrary("user32")
            pSetLayeredWindowAttributes = win32api.GetProcAddress(
                _winlib, "SetLayeredWindowAttributes")
            if pSetLayeredWindowAttributes is None:
                return
            exstyle = win32api.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
            if 0 == (exstyle & 0x80000):
                exstyle |= win32con.WS_EX_LAYERED | win32con.WS_EX_TOOLWINDOW | win32con.WS_EX_TRANSPARENT
                win32api.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, exstyle)
            win32gui.SetLayeredWindowAttributes(hwnd, 0, amount, 2)
        else:
            print('####  OS Platform must be MS Windows')
            self.Destroy()
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def testOtherHandle(self):
        h=pywintypes.HANDLE(1)
        h2=pywintypes.HANDLE(h)
        self.failUnlessEqual(h, h2)
        # but the above doesn't really test everything - we want a way to
        # pass the handle directly into PyWinLong_AsVoidPtr.  One way to
        # to that is to abuse win32api.GetProcAddress() - the 2nd param
        # is passed to PyWinLong_AsVoidPtr() if its not a string.
        # passing a handle value of '1' should work - there is something
        # at that ordinal
        win32api.GetProcAddress(sys.dllhandle, h)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def testOtherHandle(self):
        h=pywintypes.HANDLE(1)
        h2=pywintypes.HANDLE(h)
        self.failUnlessEqual(h, h2)
        # but the above doesn't really test everything - we want a way to
        # pass the handle directly into PyWinLong_AsVoidPtr.  One way to
        # to that is to abuse win32api.GetProcAddress() - the 2nd param
        # is passed to PyWinLong_AsVoidPtr() if its not a string.
        # passing a handle value of '1' should work - there is something
        # at that ordinal
        win32api.GetProcAddress(sys.dllhandle, h)
项目:MechaTranslator    作者:reddo9999    | 项目源码 | 文件源码
def __init__(self, atlasPath = None, direction=2):
        """Intialise the Atlas translation engine
        Args: atlasPath: a path to atlas; will try and figure it out from registry if not given
              direction: 1 = JP to ENG, 2 = ENG to JP
        """
        if atlasPath is None:
            try:
                atlasPath = findAtlasPath()
            except MissingAtlasException:
                print("Could not find ATLAS Translator")

        atlecont  = win32api.LoadLibraryEx(os.path.join(atlasPath, "AtleCont.dll"), 0,  LOAD_WITH_ALTERED_SEATCH_PATH)

        self.createEngine = createEngineType(win32api.GetProcAddress(atlecont, "CreateEngine"))
        self.destroyEngine = destroyEngineType(win32api.GetProcAddress(atlecont, "DestroyEngine"))
        self.translatePair = translatePairType(win32api.GetProcAddress(atlecont, "TranslatePair"))
        self.atlInitEngineData = atlInitEngineDataType(win32api.GetProcAddress(atlecont, "AtlInitEngineData"))
        self.freeAtlasData = freeAtlasDataType(win32api.GetProcAddress(atlecont, "FreeAtlasData"))

        intarray1 = intarrayType()
        intarray2 = intarrayType()
        genString = b'General'
        ret = self.atlInitEngineData(c_int(0), c_int(2), byref(intarray1), c_int(0), byref(intarray2))
        if ret != 0: raise AtlasInitErrorException()
        ret2 = self.createEngine(c_int(1), c_int(direction), c_int(0), c_char_p(genString))
        if ret2 != 1: raise AtlasInitErrorException()