本文整理匯總了Python中win32api.LoadResource方法的典型用法代碼示例。如果您正苦於以下問題:Python win32api.LoadResource方法的具體用法?Python win32api.LoadResource怎麽用?Python win32api.LoadResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類win32api
的用法示例。
在下文中一共展示了win32api.LoadResource方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: extract_manifest
# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import LoadResource [as 別名]
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
示例2: extract_manifest
# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import LoadResource [as 別名]
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).decode('utf-8', 'ignore')
except pywintypes.error as error:
if error.args[0] == winerror.ERROR_RESOURCE_DATA_NOT_FOUND:
return None
else:
raise
示例3: extract_manifest
# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import LoadResource [as 別名]
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
示例4: extract_manifest
# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import LoadResource [as 別名]
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).decode('utf-8', 'ignore')
except pywintypes.error as error:
if error.args[0] == winerror.ERROR_RESOURCE_DATA_NOT_FOUND:
return None
else:
raise
示例5: decode
# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import LoadResource [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
示例6: _GetResources
# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import LoadResource [as 別名]
def _GetResources(hsrc, types=None, names=None, languages=None):
"""
Get resources from hsrc.
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.
"""
if types: types = set(types)
if names: names = set(names)
if languages: languages = set(languages)
res = {}
try:
# logger.debug("Enumerating resource types")
enum_types = win32api.EnumResourceTypes(hsrc)
if types and not "*" in types:
enum_types = filter(lambda type_:
type_ in types,
enum_types)
for type_ in enum_types:
# logger.debug("Enumerating resources of type %s", type_)
enum_names = win32api.EnumResourceNames(hsrc, type_)
if names and not "*" in names:
enum_names = filter(lambda name:
name in names,
enum_names)
for name in enum_names:
# logger.debug("Enumerating resources of type %s name %s", type_, name)
enum_languages = win32api.EnumResourceLanguages(hsrc,
type_,
name)
if languages and not "*" in languages:
enum_languages = filter(lambda language:
language in languages,
enum_languages)
for language in enum_languages:
data = win32api.LoadResource(hsrc, type_, name, language)
if not type_ in res:
res[type_] = {}
if not name in res[type_]:
res[type_][name] = {}
res[type_][name][language] = data
except pywintypes.error, exception:
if exception.args[0] in (ERROR_RESOURCE_DATA_NOT_FOUND,
ERROR_RESOURCE_TYPE_NOT_FOUND,
ERROR_RESOURCE_NAME_NOT_FOUND,
ERROR_RESOURCE_LANG_NOT_FOUND):
# logger.info('%s: %s', exception.args[1:3])
pass
else:
raise exception