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

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

项目:code    作者:ActiveState    | 项目源码 | 文件源码
def which_file(fname):
    """prints paths for fname where fname can be found,
    in case of .dll loads it"""
    files = []
    path = win32api.GetEnvironmentVariable('PATH')
    # try paths as described in MSDN
    dirs = [os.getcwd(), win32api.GetSystemDirectory(), win32api.GetWindowsDirectory()] + path.split(';')
    dirs_norm = []
    dirs_l = []
    for d in dirs:
        dn = d.lower()
        if dn not in dirs_l:
            dirs_l.append(dn)
            dirs_norm.append(d)
    for d in dirs_norm:
        fname2 = os.path.join(d, fname)
        if os.path.exists(fname2):
            if fname2 not in files:
                files.append(fname2)
    if files:
        print('\n'.join([get_file_info(f) for f in files]))
    h = 0
    if fname.lower().endswith('.dll'):
        print('\ttrying to load "%s" ...' % (fname))
        try:
            h = win32api.LoadLibrary(fname)
            if h:
                dll_name = win32api.GetModuleFileName(h)
                print('\t%s loaded' % (dll_name))
        except:
            print('\tCannot load "%s" !!!' % (fname))
项目: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()
项目:purelove    作者:hucmosin    | 项目源码 | 文件源码
def __getitem__(self, filename):
        key = filename.lower()
        return self.__cache.setdefault(key, win32api.LoadLibrary(key))
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def CreateViewWindow(self, prev, settings, browser, rect):
        print "ScintillaShellView.CreateViewWindow", prev, settings, browser, rect
        # Make sure scintilla.dll is loaded.  If not, find it on sys.path
        # (which it generally is for Pythonwin)
        try:
            win32api.GetModuleHandle("Scintilla.dll")
        except win32api.error:
            for p in sys.path:
                fname = os.path.join(p, "Scintilla.dll")
                if not os.path.isfile(fname):
                    fname = os.path.join(p, "Build", "Scintilla.dll")
                if os.path.isfile(fname):
                    win32api.LoadLibrary(fname)
                    break
            else:
                raise RuntimeError("Can't find scintilla!")

        style = win32con.WS_CHILD | win32con.WS_VSCROLL | \
                win32con.WS_HSCROLL | win32con.WS_CLIPCHILDREN | \
                win32con.WS_VISIBLE
        self.hwnd = win32gui.CreateWindow("Scintilla", "Scintilla", style,
                              rect[0], rect[1], rect[2]-rect[0], rect[3]-rect[1], 
                              self.hwnd_parent, 1000, 0, None)

        message_map = {
                win32con.WM_SIZE: self.OnSize,
        }
#        win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map)

        file_data = file(self.filename, "U").read()

        self._SetupLexer()
        self._SendSci(scintillacon.SCI_ADDTEXT, len(file_data), file_data)
        if self.lineno != None:
            self._SendSci(scintillacon.SCI_GOTOLINE, self.lineno)
        print "Scintilla's hwnd is", self.hwnd
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def __getitem__(self, filename):
        key = filename.lower()
        return self.__cache.setdefault(key, win32api.LoadLibrary(key))
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def CreateViewWindow(self, prev, settings, browser, rect):
        print "ScintillaShellView.CreateViewWindow", prev, settings, browser, rect
        # Make sure scintilla.dll is loaded.  If not, find it on sys.path
        # (which it generally is for Pythonwin)
        try:
            win32api.GetModuleHandle("Scintilla.dll")
        except win32api.error:
            for p in sys.path:
                fname = os.path.join(p, "Scintilla.dll")
                if not os.path.isfile(fname):
                    fname = os.path.join(p, "Build", "Scintilla.dll")
                if os.path.isfile(fname):
                    win32api.LoadLibrary(fname)
                    break
            else:
                raise RuntimeError("Can't find scintilla!")

        style = win32con.WS_CHILD | win32con.WS_VSCROLL | \
                win32con.WS_HSCROLL | win32con.WS_CLIPCHILDREN | \
                win32con.WS_VISIBLE
        self.hwnd = win32gui.CreateWindow("Scintilla", "Scintilla", style,
                              rect[0], rect[1], rect[2]-rect[0], rect[3]-rect[1], 
                              self.hwnd_parent, 1000, 0, None)

        message_map = {
                win32con.WM_SIZE: self.OnSize,
        }
#        win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map)

        file_data = file(self.filename, "U").read()

        self._SetupLexer()
        self._SendSci(scintillacon.SCI_ADDTEXT, len(file_data), file_data)
        if self.lineno != None:
            self._SendSci(scintillacon.SCI_GOTOLINE, self.lineno)
        print "Scintilla's hwnd is", self.hwnd
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def CreateViewWindow(self, prev, settings, browser, rect):
        print("ScintillaShellView.CreateViewWindow", prev, settings, browser, rect)
        # Make sure scintilla.dll is loaded.  If not, find it on sys.path
        # (which it generally is for Pythonwin)
        try:
            win32api.GetModuleHandle("Scintilla.dll")
        except win32api.error:
            for p in sys.path:
                fname = os.path.join(p, "Scintilla.dll")
                if not os.path.isfile(fname):
                    fname = os.path.join(p, "Build", "Scintilla.dll")
                if os.path.isfile(fname):
                    win32api.LoadLibrary(fname)
                    break
            else:
                raise RuntimeError("Can't find scintilla!")

        style = win32con.WS_CHILD | win32con.WS_VSCROLL | \
                win32con.WS_HSCROLL | win32con.WS_CLIPCHILDREN | \
                win32con.WS_VISIBLE
        self.hwnd = win32gui.CreateWindow("Scintilla", "Scintilla", style,
                              rect[0], rect[1], rect[2]-rect[0], rect[3]-rect[1], 
                              self.hwnd_parent, 1000, 0, None)

        message_map = {
                win32con.WM_SIZE: self.OnSize,
        }
#        win32gui.SetWindowLong(self.hwnd, win32con.GWL_WNDPROC, message_map)

        file_data = file(self.filename, "U").read()

        self._SetupLexer()
        self._SendSci(scintillacon.SCI_ADDTEXT, len(file_data), file_data)
        if self.lineno != None:
            self._SendSci(scintillacon.SCI_GOTOLINE, self.lineno)
        print("Scintilla's hwnd is", self.hwnd)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def __getitem__(self, filename):
        key = filename.lower()
        return self.__cache.setdefault(key, win32api.LoadLibrary(key))
项目:gyp    作者:electron    | 项目源码 | 文件源码
def __enter__(self):
      self._handle = win32api.LoadLibrary(self._path)
      return self._handle
项目:gyp    作者:electron    | 项目源码 | 文件源码
def extract_manifest(path, resource_name):
    """Reads manifest from |path| and returns it as a string.
    Returns None is there is no such manifest."""
    with LoadLibrary(path) as handle:
      try:
        return win32api.LoadResource(handle, RT_MANIFEST, resource_name)
      except pywintypes.error as error:
        if error.args[0] == winerror.ERROR_RESOURCE_DATA_NOT_FOUND:
          return None
        else:
          raise
项目:gyp    作者:electron    | 项目源码 | 文件源码
def __enter__(self):
      self._handle = win32api.LoadLibrary(self._path)
      return self._handle
项目:gyp    作者:electron    | 项目源码 | 文件源码
def extract_manifest(path, resource_name):
    """Reads manifest from |path| and returns it as a string.
    Returns None is there is no such manifest."""
    with LoadLibrary(path) as handle:
      try:
        return win32api.LoadResource(handle, RT_MANIFEST, resource_name)
      except pywintypes.error as error:
        if error.args[0] == winerror.ERROR_RESOURCE_DATA_NOT_FOUND:
          return None
        else:
          raise
项目:gyp    作者:electron    | 项目源码 | 文件源码
def __enter__(self):
      self._handle = win32api.LoadLibrary(self._path)
      return self._handle
项目:gyp    作者:electron    | 项目源码 | 文件源码
def __enter__(self):
      self._handle = win32api.LoadLibrary(self._path)
      return self._handle
项目:gyp    作者:electron    | 项目源码 | 文件源码
def extract_manifest(path, resource_name):
    """Reads manifest from |path| and returns it as a string.
    Returns None is there is no such manifest."""
    with LoadLibrary(path) as handle:
      try:
        return win32api.LoadResource(handle, RT_MANIFEST, resource_name)
      except pywintypes.error as error:
        if error.args[0] == winerror.ERROR_RESOURCE_DATA_NOT_FOUND:
          return None
        else:
          raise