当前位置: 首页>>代码示例>>Python>>正文


Python win32api.FormatMessage方法代码示例

本文整理汇总了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) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:20,代码来源:win32.py

示例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) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:21,代码来源:test_strerror.py

示例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 
开发者ID:SekoiaLab,项目名称:Fastir_Collector,代码行数:24,代码来源:mem.py

示例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) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:21,代码来源:test_strerror.py

示例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) ) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:__init__.py

示例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. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:redirector.py

示例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() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_bits.py

示例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]) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:win32serviceutil.py

示例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?") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_win32api.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_exceptions.py

示例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)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_exceptions.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_exceptions.py

示例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. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_exceptions.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_exceptions.py

示例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)) 
开发者ID:dictation-toolbox,项目名称:dragonfly,代码行数:14,代码来源:sendinput.py


注:本文中的win32api.FormatMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。