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


Python win32api.GetLastError方法代码示例

本文整理汇总了Python中win32api.GetLastError方法的典型用法代码示例。如果您正苦于以下问题:Python win32api.GetLastError方法的具体用法?Python win32api.GetLastError怎么用?Python win32api.GetLastError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32api的用法示例。


在下文中一共展示了win32api.GetLastError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: stop

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
def stop(self):
        if not self.is_set:
            self.bus.log('Handler for console events already off.', level=20)
            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=20)
            self.is_set = False 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:19,代码来源:win32.py

示例2: stop

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
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 
开发者ID:naparuba,项目名称:opsbro,代码行数:19,代码来源:win32.py

示例3: release

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
def release(self):
        # unlock
        assert self._mylock
        if os.name == 'nt':
            win32event.ReleaseMutex(self._mutex)
            # Error code 123? 
            #lasterror = win32api.GetLastError()
            #if lasterror != 0:
            #    raise IOError( _("Could not release mutex %s due to "
            #                     "error windows code %d.") % 
            #                    (self._name,lasterror) )
        elif os.name == 'posix':
            self._mylock = False
            if not os.path.exists(self._path):
                raise IOError( _("Non-existent file: %s") % self._path )
            flock( self._mutex.fileno(), fcntl.LOCK_UN )
            self._mutex.close() 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:19,代码来源:NamedMutex.py

示例4: stop

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
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 
开发者ID:binhex,项目名称:moviegrabber,代码行数:19,代码来源:win32.py

示例5: update

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
def update( self, window, hdc ):
            rect = self.rect or window.get_client_region()
            try:
                background = self.background or win32gui.GetPixel( hdc, rect[0], rect[1] )
                self.last_background = background
            except:
                print "FIXME: Figure out why GetPixel( hdc, 0, 0 ) is failing..."
                #traceback.print_exc()
                #print "GetLastError() => {}".format( win32api.GetLastError() )
                background = self.last_background
                
            color = ((background >> 0 ) & 255,
                     (background >> 8 ) & 255,
                     (background >> 16 ) & 255,
                     255)
            size = ( rect[2] - rect[0], rect[3] - rect[1] )
            combined = self.render( size, color )
            self.image = Image.Bitmap( combined ) 
开发者ID:mailpile,项目名称:gui-o-matic,代码行数:20,代码来源:winapi.py

示例6: __acquire

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
def __acquire(self):
        '''
        Attempts to acquire the mutex
        @raise MutexAlreadyAcquired
        '''

        mutex = win32event.CreateMutex(None, 1, self.MUTEX_NAME)
        if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
            raise MutexAlreadyAcquired()

        return mutex


# ================================================================
# = MutexAlreadyAcquired Exception Class
# =============================================================== 
开发者ID:sithis993,项目名称:Crypter,代码行数:18,代码来源:Mutex.py

示例7: start

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
def start(self):
        if self.is_set:
            self.bus.log('Handler for console events already set.', level=20)
            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=20)
            self.is_set = True 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:14,代码来源:win32.py

示例8: OpenDynamicChannel

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
def OpenDynamicChannel(self, channelname, priority):
		# C+Python = OMG...
		global pywintypes
		import ctypes.wintypes
		import ctypes
		import pywintypes
		import win32api

		wts = ctypes.windll.LoadLibrary("Wtsapi32.dll")

		hWTSHandle = wts.WTSVirtualChannelOpenEx(0xFFFFFFFF, channelname, 0x00000001 | priority)
		if not hWTSHandle:
			common.internal_print("Opening channel failed: {0}".format(win32api.GetLastError()), -1)
			return None

		WTSVirtualFileHandle = 1
		vcFileHandlePtr = ctypes.pointer(ctypes.c_int())
		length = ctypes.c_ulong(0)

		if not wts.WTSVirtualChannelQuery(hWTSHandle, WTSVirtualFileHandle, ctypes.byref(vcFileHandlePtr), ctypes.byref(length)):
			wts.WTSVirtualChannelClose(hWTSHandle)
			common.internal_print("Channel query: {0}".format(win32api.GetLastError()), -1)
			return None

		common.internal_print("Connected to channel: {0}".format(channelname))

		return pywintypes.HANDLE(vcFileHandlePtr.contents.value) 
开发者ID:earthquake,项目名称:XFLTReaT,代码行数:29,代码来源:RDP.py

示例9: test_last_error

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
def test_last_error(self):
        for x in (0, 1, -1, winerror.TRUST_E_PROVIDER_UNKNOWN):
            win32api.SetLastError(x)
            self.failUnlessEqual(x, win32api.GetLastError()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_win32api.py

示例10: send_input_array

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [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

示例11: start

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
def start(self, cmd):
        sAttr = win32security.SECURITY_ATTRIBUTES()
        sAttr.bInheritHandle = True

        stdout_r, stdout_w = win32pipe.CreatePipe(sAttr,0)
        stdin_r, stdin_w = win32pipe.CreatePipe(sAttr,0)
        self.read_handle=stdout_r
        self.write_handle=stdout_w
        self.stdin_write=stdin_w

        si = win32process.STARTUPINFO()
        si.dwFlags = win32process.STARTF_USESHOWWINDOW | win32process.STARTF_USESTDHANDLES
        si.wShowWindow = win32con.SW_HIDE
        si.hStdInput = stdin_r            # file descriptor of origin stdin
        si.hStdOutput = stdout_w
        si.hStdError = stdout_w
        hProcess, hThread, dwProcessID, dwThreadID = win32process.CreateProcess(None,"cmd", None, None, True, win32process.CREATE_NEW_CONSOLE, None, None, si)
        self.dwProcessID=dwProcessID
        self.hProcess=hProcess
        sleep(0.5)
        if self.hProcess == 0:
            DebugOutput("Start Process Fail:{:d}".format(win32api.GetLastError()))
        DebugOutput('[*] pid: {:x}'.format(self.dwProcessID))
        self.Console_hwnd = get_hwnds_for_pid(self.dwProcessID)
        if len(self.Console_hwnd)==0:
            raise Exception("Fail to run,No Process!")
        DebugOutput('[*] hwnd:{:x}'.format(self.Console_hwnd[0])) 
开发者ID:turingsec,项目名称:marsnake,代码行数:29,代码来源:winpty.py

示例12: start

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
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 
开发者ID:naparuba,项目名称:opsbro,代码行数:14,代码来源:win32.py

示例13: create

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
def create(self):
        obtain_mutex = 1
        mutex = win32event.CreateMutex(None, obtain_mutex, app_name)

        # prevent the PyHANDLE from going out of scope, ints are fine
        self.mutex = int(mutex)
        mutex.Detach()

        lasterror = win32api.GetLastError()
        
        if lasterror == winerror.ERROR_ALREADY_EXISTS:
            takeover = 0

            try:
                # if the mutex already exists, discover which port to connect to.
                # if something goes wrong with that, tell us to take over the
                # role of master
                takeover = self.discover_sic_socket()
            except:
                pass
            
            if not takeover:
                raise BTFailure(_("Global mutex already created."))

        self.master = 1

        # lazy free port code
        port_limit = 50000
        while self.port < port_limit:
            try:
                controlsocket = self.rawserver.create_serversocket(self.port,
                                                                   '127.0.0.1')
                self.controlsocket = controlsocket
                break
            except socket.error, e:
                self.port += 1 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:38,代码来源:IPC.py

示例14: __init__

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
def __init__(self):
        obtain_mutex = False
        self.mutex = win32event.CreateMutex(None, obtain_mutex, app_name)
        self.lasterror = win32api.GetLastError() 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:6,代码来源:IPC.py

示例15: __init__

# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetLastError [as 别名]
def __init__(self, func=None, err=0):
		if err:
			self.err = err
		else:
			self.err = win32api.GetLastError()
		self.message = win32api.FormatMessageW(self.err)
		self.args = (self.err, func, self.message) 
开发者ID:grawity,项目名称:code,代码行数:9,代码来源:wts.py


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