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

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

项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __init__ (self):
        wx.Frame.__init__ (self, None, title="Clipboard viewer", size=(250,150))

        self.first   = True
        self.nextWnd = None

        # Get native window handle of this wxWidget Frame.
        self.hwnd    = self.GetHandle ()

        # Set the WndProc to our function.
        self.oldWndProc = win32gui.SetWindowLong (self.hwnd,
                                                  win32con.GWL_WNDPROC,
                                                  self.MyWndProc)

        try:
            self.nextWnd = win32clipboard.SetClipboardViewer (self.hwnd)
        except win32api.error:
            if win32api.GetLastError () == 0:
                # information that there is no other window in chain
                pass
            else:
                raise
项目:autosub-bootstrapbill    作者:BenjV    | 项目源码 | 文件源码
def stop(self):
        if not self.is_set:
            self.bus.log('Handler for console events already off.', level=40)
            return

        try:
            result = win32api.SetConsoleCtrlHandler(self.handle, 0)
        except ValueError:
            # "ValueError: The object has not been registered"
            result = 1

        if result == 0:
            self.bus.log('Could not remove SetConsoleCtrlHandler (error %r)' %
                         win32api.GetLastError(), level=40)
        else:
            self.bus.log('Removed handler for console events.', level=40)
            self.is_set = False
项目:watcher    作者:nosmokingbandit    | 项目源码 | 文件源码
def stop(self):
        if not self.is_set:
            self.bus.log('Handler for console events already off.', level=40)
            return

        try:
            result = win32api.SetConsoleCtrlHandler(self.handle, 0)
        except ValueError:
            # "ValueError: The object has not been registered"
            result = 1

        if result == 0:
            self.bus.log('Could not remove SetConsoleCtrlHandler (error %r)' %
                         win32api.GetLastError(), level=40)
        else:
            self.bus.log('Removed handler for console events.', level=40)
            self.is_set = False
项目:KeyCounter    作者:Microcore    | 项目源码 | 文件源码
def instance_running(self):
        '''
        Use CreateEvent to make sure there is only one instance running
        '''
        if self.SICHECK_EVENT is None:
            self.SICHECK_EVENT = win32event.CreateEvent(
                None, 1, 0, self.GUID
            )
            # An instance is already running, quit
            if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
                win32gui.MessageBox(
                    self.HWND,
                    'You can only run one instance at a time',
                    'Seems like KeyCounter is already running',
                    win32con.MB_OK
                )
                return self.stop()
项目:LoLVRSpectate    作者:Fire-Proof    | 项目源码 | 文件源码
def read_bytes(self, address, bytes = 4):
        address = int(address)
        if not self.isProcessOpen:
            raise ProcessException("Can't read_bytes(%s, bytes=%s), process %s is not open" % (address, bytes, self.pid))
        buffer = create_string_buffer(bytes)
        bytesread = c_ulong(0)
        data = b''
        length = bytes
        _address = address
        _length = length
        while length:
            if not windll.kernel32.ReadProcessMemory(self.h_process, address, buffer, bytes, byref(bytesread)):
                if bytesread.value:
                    data += buffer.raw[:bytesread.value]
                    length -= bytesread.value
                    address += bytesread.value
                if not len(data):
                    raise ProcessException('Error %s in ReadProcessMemory(%08x, %d, read=%d)' % (win32api.GetLastError(),
                     address,
                     length,
                    bytesread.value))
                return data
            data += buffer.raw[:bytesread.value]
            length -= bytesread.value
            address += bytesread.value

        return data
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def __init__(self):
        self.mutexname = "testmutex_{D0E858DF-985E-4907-B7FB-8D732C3FC3B9}"
        self.mutex = CreateMutex(None, False, self.mutexname)
        self.lasterror = GetLastError()
项目:django-runner    作者:awecode    | 项目源码 | 文件源码
def create_mutex(self, argv):
        try:
            from win32event import CreateMutex
            from win32api import GetLastError

            self.mutexname = "awecode_dr_" + str(argv[0])
            self.mutex = CreateMutex(None, False, self.mutexname)
            self.lasterror = GetLastError()
        except ImportError:
            pass
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def test_last_error(self):
        for x in (0, 1, -1, winerror.TRUST_E_PROVIDER_UNKNOWN):
            win32api.SetLastError(x)
            self.failUnlessEqual(x, win32api.GetLastError())
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def test_last_error(self):
        for x in (0, 1, -1, winerror.TRUST_E_PROVIDER_UNKNOWN):
            win32api.SetLastError(x)
            self.failUnlessEqual(x, win32api.GetLastError())
项目:autosub-bootstrapbill    作者:BenjV    | 项目源码 | 文件源码
def start(self):
        if self.is_set:
            self.bus.log('Handler for console events already set.', level=40)
            return

        result = win32api.SetConsoleCtrlHandler(self.handle, 1)
        if result == 0:
            self.bus.log('Could not SetConsoleCtrlHandler (error %r)' %
                         win32api.GetLastError(), level=40)
        else:
            self.bus.log('Set handler for console events.', level=40)
            self.is_set = True
项目:watcher    作者:nosmokingbandit    | 项目源码 | 文件源码
def start(self):
        if self.is_set:
            self.bus.log('Handler for console events already set.', level=40)
            return

        result = win32api.SetConsoleCtrlHandler(self.handle, 1)
        if result == 0:
            self.bus.log('Could not SetConsoleCtrlHandler (error %r)' %
                         win32api.GetLastError(), level=40)
        else:
            self.bus.log('Set handler for console events.', level=40)
            self.is_set = True