當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。