本文整理汇总了Python中win32api.FormatMessage方法的典型用法代码示例。如果您正苦于以下问题:Python win32api.FormatMessage方法的具体用法?Python win32api.FormatMessage怎么用?Python win32api.FormatMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32api
的用法示例。
在下文中一共展示了win32api.FormatMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fromEnvironment
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def fromEnvironment(cls):
"""
Get as many of the platform-specific error translation objects as
possible and return an instance of C{cls} created with them.
"""
try:
from ctypes import WinError
except ImportError:
WinError = None
try:
from win32api import FormatMessage
except ImportError:
FormatMessage = None
try:
from socket import errorTab
except ImportError:
errorTab = None
return cls(WinError, FormatMessage, errorTab)
示例2: test_correctLookups
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def test_correctLookups(self):
"""
Given a known-good errno, make sure that formatMessage gives results
matching either C{socket.errorTab}, C{ctypes.WinError}, or
C{win32api.FormatMessage}.
"""
acceptable = [socket.errorTab[ECONNABORTED]]
try:
from ctypes import WinError
acceptable.append(WinError(ECONNABORTED).strerror)
except ImportError:
pass
try:
from win32api import FormatMessage
acceptable.append(FormatMessage(ECONNABORTED))
except ImportError:
pass
self.assertIn(formatError(ECONNABORTED), acceptable)
示例3: _GetProcessModules
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def _GetProcessModules(self, ProcessID, isPrint):
me32 = MODULEENTRY32()
me32.dwSize = sizeof(MODULEENTRY32)
hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessID)
ret = Module32First(hModuleSnap, pointer(me32))
if ret == 0:
errCode = GetLastError()
self.logger.warn('GetProcessModules() Error on Module32First[%d] with PID : %d' % (errCode, ProcessID))
self.logger.warn(win32api.FormatMessage(errCode))
CloseHandle(hModuleSnap)
return []
modules = []
while ret:
if isPrint:
self.logger.info(" executable = %s" % me32.szExePath)
modules.append(me32.szExePath)
ret = Module32Next(hModuleSnap, pointer(me32))
CloseHandle(hModuleSnap)
return modules
示例4: test_correctLookups
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def test_correctLookups(self):
"""
Given an known-good errno, make sure that formatMessage gives results
matching either C{socket.errorTab}, C{ctypes.WinError}, or
C{win32api.FormatMessage}.
"""
acceptable = [socket.errorTab[ECONNABORTED]]
try:
from ctypes import WinError
acceptable.append(WinError(ECONNABORTED)[1])
except ImportError:
pass
try:
from win32api import FormatMessage
acceptable.append(FormatMessage(ECONNABORTED))
except ImportError:
pass
self.assertIn(formatError(ECONNABORTED), acceptable)
示例5: __str__
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def __str__(self):
if self.strerror is None:
try:
import win32api
self.strerror = win32api.FormatMessage(self.errno).strip()
except:
self.strerror = "no error message is available"
# str() looks like a win32api error.
return str( (self.errno, self.strerror, self.funcname) )
示例6: io_callback
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def io_callback(ecb, url, cbIO, errcode):
# Get the status of our ExecURL
httpstatus, substatus, win32 = ecb.GetExecURLStatus()
print "ExecURL of %r finished with http status %d.%d, win32 status %d (%s)" % (
url, httpstatus, substatus, win32, win32api.FormatMessage(win32).strip())
# nothing more to do!
ecb.DoneWithSession()
# The ISAPI extension - handles all requests in the site.
示例7: _print_error
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def _print_error(self, err):
ctx, hresult = err.GetError()
try:
hresult_msg = win32api.FormatMessage(hresult)
except win32api.error:
hresult_msg = ""
print "Context=0x%x, hresult=0x%x (%s)" % (ctx, hresult, hresult_msg)
print err.GetErrorDescription()
示例8: WaitForServiceStatus
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def WaitForServiceStatus(serviceName, status, waitSecs, machine=None):
"""Waits for the service to return the specified status. You
should have already requested the service to enter that state"""
for i in range(waitSecs*4):
now_status = QueryServiceStatus(serviceName, machine)[1]
if now_status == status:
break
win32api.Sleep(250)
else:
raise pywintypes.error(winerror.ERROR_SERVICE_REQUEST_TIMEOUT, "QueryServiceStatus", win32api.FormatMessage(winerror.ERROR_SERVICE_REQUEST_TIMEOUT)[:-2])
示例9: test_FromString
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def test_FromString(self):
msg = "Hello %1, how are you %2?"
inserts = ["Mark", "today"]
result = win32api.FormatMessage(win32con.FORMAT_MESSAGE_FROM_STRING,
msg, # source
0, # ID
0, # LangID
inserts)
self.assertEqual(result, "Hello Mark, how are you today?")
示例10: testUnpack
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def testUnpack(self):
try:
win32api.CloseHandle(1)
self.fail("expected exception!")
except win32api.error, exc:
self.failUnlessEqual(exc.winerror, winerror.ERROR_INVALID_HANDLE)
self.failUnlessEqual(exc.funcname, "CloseHandle")
expected_msg = win32api.FormatMessage(winerror.ERROR_INVALID_HANDLE).rstrip()
self.failUnlessEqual(exc.strerror, expected_msg)
示例11: testAsStr
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def testAsStr(self):
exc = self._getInvalidHandleException()
err_msg = win32api.FormatMessage(winerror.ERROR_INVALID_HANDLE).rstrip()
# early on the result actually *was* a tuple - it must always look like one
err_tuple = (winerror.ERROR_INVALID_HANDLE, 'CloseHandle', err_msg)
self.failUnlessEqual(str(exc), str(err_tuple))
示例12: testAsTuple
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def testAsTuple(self):
exc = self._getInvalidHandleException()
err_msg = win32api.FormatMessage(winerror.ERROR_INVALID_HANDLE).rstrip()
# early on the result actually *was* a tuple - it must be able to be one
err_tuple = (winerror.ERROR_INVALID_HANDLE, 'CloseHandle', err_msg)
if sys.version_info < (3,):
self.failUnlessEqual(tuple(exc), err_tuple)
else:
self.failUnlessEqual(exc.args, err_tuple)
示例13: testAttributes
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def testAttributes(self):
exc = self._getInvalidHandleException()
err_msg = win32api.FormatMessage(winerror.ERROR_INVALID_HANDLE).rstrip()
self.failUnlessEqual(exc.winerror, winerror.ERROR_INVALID_HANDLE)
self.failUnlessEqual(exc.strerror, err_msg)
self.failUnlessEqual(exc.funcname, 'CloseHandle')
# some tests for 'insane' args.
示例14: testMessageIndex
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def testMessageIndex(self):
exc = self._getException()
expected = win32api.FormatMessage(winerror.STG_E_INVALIDFLAG).rstrip()
self._testExceptionIndex(exc, 1, expected)
示例15: send_input_array
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import FormatMessage [as 别名]
def send_input_array(input_array):
length = len(input_array)
assert length >= 0
size = sizeof(input_array[0])
ptr = pointer(input_array)
count_inserted = windll.user32.SendInput(length, ptr, size)
if count_inserted != length:
last_error = win32api.GetLastError()
message = win32api.FormatMessage(last_error)
raise ValueError("windll.user32.SendInput(): %s" % (message))