當前位置: 首頁>>代碼示例>>Python>>正文


Python win32api.FreeLibrary方法代碼示例

本文整理匯總了Python中win32api.FreeLibrary方法的典型用法代碼示例。如果您正苦於以下問題:Python win32api.FreeLibrary方法的具體用法?Python win32api.FreeLibrary怎麽用?Python win32api.FreeLibrary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在win32api的用法示例。


在下文中一共展示了win32api.FreeLibrary方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: FormatMessage

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import FreeLibrary [as 別名]
def FormatMessage( eventLogRecord, logType="Application" ):
    """Given a tuple from ReadEventLog, and optionally where the event
    record came from, load the message, and process message inserts.

    Note that this function may raise win32api.error.  See also the
    function SafeFormatMessage which will return None if the message can
    not be processed.
    """

    # From the event log source name, we know the name of the registry
    # key to look under for the name of the message DLL that contains
    # the messages we need to extract with FormatMessage. So first get
    # the event log source name...
    keyName = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (logType, eventLogRecord.SourceName)

    # Now open this key and get the EventMessageFile value, which is
    # the name of the message DLL.
    handle = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, keyName)
    try:
        dllNames = win32api.RegQueryValueEx(handle, "EventMessageFile")[0].split(";")
        # Win2k etc appear to allow multiple DLL names
        data = None
        for dllName in dllNames:
            try:
                # Expand environment variable strings in the message DLL path name,
                # in case any are there.
                dllName = win32api.ExpandEnvironmentStrings(dllName)

                dllHandle = win32api.LoadLibraryEx(dllName, 0, win32con.LOAD_LIBRARY_AS_DATAFILE)
                try:
                    data = win32api.FormatMessageW(win32con.FORMAT_MESSAGE_FROM_HMODULE,
                                    dllHandle, eventLogRecord.EventID, langid, eventLogRecord.StringInserts)
                finally:
                    win32api.FreeLibrary(dllHandle)
            except win32api.error:
                pass # Not in this DLL - try the next
            if data is not None:
                break
    finally:
        win32api.RegCloseKey(handle)
    return data or u'' # Don't want "None" ever being returned. 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:43,代碼來源:win32evtlogutil.py

示例2: __exit__

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import FreeLibrary [as 別名]
def __exit__(self, type, value, traceback):
    win32api.FreeLibrary(self._handle) 
開發者ID:refack,項目名稱:GYP3,代碼行數:4,代碼來源:gyptest-link-generate-manifest.py

示例3: __exit__

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import FreeLibrary [as 別名]
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
開發者ID:turbulenz,項目名稱:gyp,代碼行數:4,代碼來源:gyptest-link-generate-manifest.py

示例4: GetResources

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import FreeLibrary [as 別名]
def GetResources(filename, types=None, names=None, languages=None):
    """
    Get resources from dll/exe file.
    
    types = a list of resource types to search for (None = all)
    names = a list of resource names to search for (None = all)
    languages = a list of resource languages to search for (None = all)
    Return a dict of the form {type_: {name: {language: data}}} which 
    might also be empty if no matching resources were found.
    
    """
    hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
    res = _GetResources(hsrc, types, names, languages)
    win32api.FreeLibrary(hsrc)
    return res 
開發者ID:Lithium876,項目名稱:ConTroll_Remote_Access_Trojan,代碼行數:17,代碼來源:winresource.py

示例5: decode

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import FreeLibrary [as 別名]
def decode(pathnm):
    h = win32api.LoadLibraryEx(pathnm, 0, LOAD_LIBRARY_AS_DATAFILE)
    nm = win32api.EnumResourceNames(h, RT_VERSION)[0]
    data = win32api.LoadResource(h, RT_VERSION, nm)
    vs = VSVersionInfo()
    j = vs.fromRaw(data)
    if TEST:
        print vs
        if data[:j] != vs.toRaw():
            print "AAAAAGGHHHH"
        glbls = {
            'VSVersionInfo': VSVersionInfo,
            'FixedFileInfo': FixedFileInfo,
            'StringFileInfo': StringFileInfo,
            'StringTable': StringTable,
            'StringStruct': StringStruct,
            'VarFileInfo': VarFileInfo,
            'VarStruct': VarStruct,
            }
        vs2 = eval(repr(vs), glbls)
        if vs.toRaw() != vs2.toRaw():
            print
            print 'reconstruction not the same!'
            print vs2
    win32api.FreeLibrary(h)
    return vs 
開發者ID:Lithium876,項目名稱:ConTroll_Remote_Access_Trojan,代碼行數:28,代碼來源:versioninfo.py

示例6: hook

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import FreeLibrary [as 別名]
def hook(mod):
    import sys
    newname = 'pywintypes%d%d' % sys.version_info[:2]
    if mod.typ == 'EXTENSION':
        mod.__name__ = newname
    else:
        import win32api
        h = win32api.LoadLibrary(newname + '.dll')
        pth = win32api.GetModuleFileName(h)
        #win32api.FreeLibrary(h)
        mod = PyInstaller.depend.modules.ExtensionModule(newname, pth)
    return mod 
開發者ID:Lithium876,項目名稱:ConTroll_Remote_Access_Trojan,代碼行數:14,代碼來源:hook-pywintypes.py

示例7: hook

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import FreeLibrary [as 別名]
def hook(mod):
    import sys
    newname = 'pythoncom%d%d' % sys.version_info[:2]
    if mod.typ == 'EXTENSION':
        mod.__name__ = newname
    else:
        import win32api
        h = win32api.LoadLibrary(newname + '.dll')
        pth = win32api.GetModuleFileName(h)
        #win32api.FreeLibrary(h)
        mod = PyInstaller.depend.modules.ExtensionModule(newname, pth)
    return mod 
開發者ID:Lithium876,項目名稱:ConTroll_Remote_Access_Trojan,代碼行數:14,代碼來源:hook-pythoncom.py

示例8: load_string_resource

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import FreeLibrary [as 別名]
def load_string_resource(pointer):
    """Resolve a @dllname,ordinal string resource pointer"""

    if pointer[0] != "@":
        return pointer

    resfile, resid = pointer[1:].split(",")
    resid = int(resid)

    hRes = Api.LoadLibraryEx(resfile, 0, Con.LOAD_LIBRARY_AS_DATAFILE)
    val = Api.LoadString(hRes, -resid, 1024)
    Api.FreeLibrary(hRes)

    return val.split('\x00', 1)[0] 
開發者ID:grawity,項目名稱:code,代碼行數:16,代碼來源:util.py


注:本文中的win32api.FreeLibrary方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。