我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用ctypes.c_longlong()。
def fsbsize(path): """ Get optimal file system buffer size (in bytes) for I/O calls """ path = encode(path) if os.name == "nt": import ctypes drive = "%s\\" % os.path.splitdrive(path)[0] cluster_sectors, sector_size = ctypes.c_longlong(0) ctypes.windll.kernel32.GetDiskFreeSpaceW(ctypes.c_wchar_p(drive), ctypes.pointer( cluster_sectors), ctypes.pointer(sector_size), None, None) return cluster_sectors * sector_size else: return os.statvfs(path).f_frsize
def kill_thread(thread=None, name=None, tid=0, exctype=SystemExit): """raises the exception, performs cleanup if needed""" if name: thread = search_thread(name=name, part=True) if thread and isinstance(thread, threading.Thread): if not thread.is_alive(): return '??????' tid = thread.ident if not tid: return '?????' if not isinstance(tid, ctypes.c_longlong): tid = ctypes.c_longlong(tid) if not inspect.isclass(exctype): raise TypeError("Only types can be raised (not instances)") res = ctypes.pythonapi.PyThreadState_SetAsyncExc( tid, ctypes.py_object(exctype)) if res == 0: raise ValueError("invalid thread id") elif res != 1: # """if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect""" ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, 0) raise SystemError("PyThreadState_SetAsyncExc failed")
def list_alttab_windows(cls): """ Return the list of the windows handles that are currently guessed to be eligible to the Alt+Tab panel. Raises a OSError exception on error. """ # LPARAM is defined as LONG_PTR (signed type) if ctypes.sizeof(ctypes.c_long) == ctypes.sizeof(ctypes.c_void_p): LPARAM = ctypes.c_long elif ctypes.sizeof(ctypes.c_longlong) == ctypes.sizeof(ctypes.c_void_p): LPARAM = ctypes.c_longlong EnumWindowsProc = ctypes.WINFUNCTYPE( ctypes.c_bool, ctypes.c_void_p, LPARAM) def _enum_proc(hwnd, lparam): try: if cls.is_alttab_window(hwnd): handles.append(hwnd) except OSError: pass return True handles = [] ctypes.windll.user32.EnumWindows(EnumWindowsProc(_enum_proc), 0) return handles
def _copyData(self, archiveR, archiveW): ''' ''' r = ctypes.c_int() buff = ctypes.c_void_p() size = ctypes.c_int() offs = ctypes.c_longlong() while True: # Read in a block r = self._readDataBlock( archiveR, # Archive (reading) ctypes.byref(buff), # Buffer pointer ctypes.byref(size), # Size pointer ctypes.byref(offs)) # Offset pointer # Check ourselves if r == self.ARCH_EOF: return self.ARCH_OK if r != self.ARCH_OK: return r # Write out a block r = self._writeDataBlock( archiveW, # Archive (writing) buff, # Buffer data size, # Size data offs) # Offset data # And check ourselves again if r != self.ARCH_OK: print(self._errorString(archiveB)) return r
def libvlc_media_get_duration(p_md): '''Get duration (in ms) of media descriptor object item. @param p_md: media descriptor object. @return: duration of media item or -1 on error. ''' f = _Cfunctions.get('libvlc_media_get_duration', None) or \ _Cfunction('libvlc_media_get_duration', ((1,),), None, ctypes.c_longlong, Media) return f(p_md)
def libvlc_media_player_get_length(p_mi): '''Get the current movie length (in ms). @param p_mi: the Media Player. @return: the movie length (in ms), or -1 if there is no media. ''' f = _Cfunctions.get('libvlc_media_player_get_length', None) or \ _Cfunction('libvlc_media_player_get_length', ((1,),), None, ctypes.c_longlong, MediaPlayer) return f(p_mi)
def libvlc_media_player_get_time(p_mi): '''Get the current movie time (in ms). @param p_mi: the Media Player. @return: the movie time (in ms), or -1 if there is no media. ''' f = _Cfunctions.get('libvlc_media_player_get_time', None) or \ _Cfunction('libvlc_media_player_get_time', ((1,),), None, ctypes.c_longlong, MediaPlayer) return f(p_mi)
def libvlc_media_player_set_time(p_mi, i_time): '''Set the movie time (in ms). This has no effect if no media is being played. Not all formats and protocols support this. @param p_mi: the Media Player. @param i_time: the movie time (in ms). ''' f = _Cfunctions.get('libvlc_media_player_set_time', None) or \ _Cfunction('libvlc_media_player_set_time', ((1,), (1,),), None, None, MediaPlayer, ctypes.c_longlong) return f(p_mi, i_time)
def _getintp_ctype(): val = _getintp_ctype.cache if val is not None: return val char = dtype('p').char if (char == 'i'): val = ctypes.c_int elif char == 'l': val = ctypes.c_long elif char == 'q': val = ctypes.c_longlong else: val = ctypes.c_long _getintp_ctype.cache = val return val
def __init__(self, slot_count, *, start=None): default = start if start is not None else 0 self.counter = multiprocessing.RawValue(ctypes.c_longlong, default) self.position = Position(slot_count)
def AwaClientGetResponse_GetValueAsIntegerPointer(self, response, path, value): self._lib.AwaClientGetResponse_GetValueAsIntegerPointer.restype = c_int mem = cast(value, POINTER(POINTER(c_longlong))) ret = self._lib.AwaClientGetResponse_GetValueAsIntegerPointer(response, path, byref(mem)) result = None if ret == 0: result = pickle.dumps(cast(mem, POINTER(c_longlong)).contents.value) # serialise as XML-RPC only supports 32 bit integers return result, ret
def AwaClientGetResponse_GetValueAsTimePointer(self, response, path, value): self._lib.AwaClientGetResponse_GetValueAsTimePointer.restype = c_int mem = cast(value, POINTER(POINTER(c_longlong))) ret = self._lib.AwaClientGetResponse_GetValueAsTimePointer(response, path, byref(mem)) result = None if ret == 0: result = pickle.dumps(cast(mem, POINTER(c_longlong)).contents.value) # serialise as XML-RPC only supports 32 bit integers return result, ret
def AwaClientSetOperation_AddValueAsInteger(self, operation, path, value): self._lib.AwaClientSetOperation_AddValueAsInteger.restype = c_int self._lib.AwaClientSetOperation_AddValueAsInteger.argtypes = [c_void_p, c_char_p, c_longlong] return self._lib.AwaClientSetOperation_AddValueAsInteger(operation, path, value)
def AwaClientSetOperation_AddValueAsTime(self, operation, path, value): self._lib.AwaClientSetOperation_AddValueAsTime.restype = c_int self._lib.AwaClientSetOperation_AddValueAsTime.argtypes = [c_void_p, c_char_p, c_longlong] return self._lib.AwaClientSetOperation_AddValueAsTime(operation, path, value)
def AwaClientSetOperation_AddArrayValueAsInteger(self, operation, path, resourceInstanceID, value): self._lib.AwaClientSetOperation_AddArrayValueAsInteger.restype = c_int self._lib.AwaClientSetOperation_AddArrayValueAsInteger.argtypes = [c_void_p, c_char_p, c_int, c_longlong] return self._lib.AwaClientSetOperation_AddArrayValueAsInteger(operation, path, resourceInstanceID, value)
def AwaIntegerArray_SetValue(self, array, index, value): self._lib.AwaIntegerArray_SetValue.restype = c_void_p self._lib.AwaIntegerArray_SetValue.argtypes = [c_void_p, c_ulong, c_longlong] return self._lib.AwaIntegerArray_SetValue(array, index, value)
def AwaTimeArray_SetValue(self, array, index, value): self._lib.AwaTimeArray_SetValue.restype = c_void_p self._lib.AwaTimeArray_SetValue.argtypes = [c_void_p, c_ulong, c_longlong] return self._lib.AwaTimeArray_SetValue(array, index, value)
def AwaIntegerArray_GetValue(self, array, index): self._lib.AwaIntegerArray_GetValue.restype = c_longlong self._lib.AwaIntegerArray_GetValue.argtypes = [c_void_p, c_ulong] return self._lib.AwaIntegerArray_GetValue(array, index)
def AwaTimeArray_GetValue(self, array, index): self._lib.AwaTimeArray_GetValue.restype = c_longlong self._lib.AwaTimeArray_GetValue.argtypes = [c_void_p, c_ulong] return self._lib.AwaTimeArray_GetValue(array, index)
def AwaIntegerArrayIterator_GetValue(self, iterator): self._lib.AwaIntegerArrayIterator_GetValue.restype = c_longlong self._lib.AwaIntegerArrayIterator_GetValue.argtypes = [c_void_p] return self._lib.AwaIntegerArrayIterator_GetValue(iterator)
def AwaObjectDefinition_AddResourceDefinitionAsInteger(self, objectDefinition, resourceID, resourceName, isMandatory, operations, defaultValue): self._lib.AwaObjectDefinition_AddResourceDefinitionAsInteger.restype = c_int self._lib.AwaObjectDefinition_AddResourceDefinitionAsInteger.argtypes = [c_void_p, c_int, c_char_p, c_bool, c_void_p, c_longlong] return self._lib.AwaObjectDefinition_AddResourceDefinitionAsInteger(objectDefinition, resourceID, resourceName, isMandatory, operations, defaultValue)
def AwaObjectDefinition_AddResourceDefinitionAsTime(self, objectDefinition, resourceID, resourceName, isMandatory, operations, defaultValue): self._lib.AwaObjectDefinition_AddResourceDefinitionAsTime.restype = c_int self._lib.AwaObjectDefinition_AddResourceDefinitionAsTime.argtypes = [c_void_p, c_int, c_char_p, c_bool, c_void_p, c_longlong] return self._lib.AwaObjectDefinition_AddResourceDefinitionAsTime(objectDefinition, resourceID, resourceName, isMandatory, operations, defaultValue)
def AwaChangeSet_GetValueAsIntegerPointer(self, changeSet, path, value): self._lib.AwaChangeSet_GetValueAsIntegerPointer.restype = c_int mem = cast(value, POINTER(POINTER(c_longlong))) ret = self._lib.AwaChangeSet_GetValueAsIntegerPointer(changeSet, path, byref(mem)) result = None if ret == 0: result = cast(mem, POINTER(c_longlong)).contents.value return result
def AwaChangeSet_GetValueAsTimePointer(self, changeSet, path, value): self._lib.AwaChangeSet_GetValueAsTimePointer.restype = c_int mem = cast(value, POINTER(POINTER(c_longlong))) ret = self._lib.AwaChangeSet_GetValueAsTimePointer(changeSet, path, byref(mem)) result = None if ret == 0: result = cast(mem, POINTER(c_longlong)).contents.value return result # * @}
def AwaServerReadResponse_GetValueAsIntegerPointer(self, response, path, value): self._lib.AwaServerReadResponse_GetValueAsIntegerPointer.restype = c_int mem = cast(value, POINTER(POINTER(c_longlong))) ret = self._lib.AwaServerReadResponse_GetValueAsIntegerPointer(response, path, byref(mem)) # serialise as XML-RPC only supports 32 bit integers result = None if ret == 0: result = pickle.dumps(cast(mem, POINTER(c_longlong)).contents.value) return result, ret
def AwaServerWriteOperation_New(self, session, defaultMode): self._lib.AwaServerWriteOperation_New.restype = c_void_p self._lib.AwaServerWriteOperation_New.argtypes = [c_void_p, c_longlong] return self._lib.AwaServerWriteOperation_New(session, defaultMode)
def AwaServerWriteOperation_AddValueAsInteger(self, operation, path, value): self._lib.AwaServerWriteOperation_AddValueAsInteger.restype = c_int self._lib.AwaServerWriteOperation_AddValueAsInteger.argtypes = [c_void_p, c_char_p, c_longlong] return self._lib.AwaServerWriteOperation_AddValueAsInteger(operation, path, value)
def AwaServerWriteOperation_AddValueAsTime(self, operation, path, value): self._lib.AwaServerWriteOperation_AddValueAsTime.restype = c_int self._lib.AwaServerWriteOperation_AddValueAsTime.argtypes = [c_void_p, c_char_p, c_longlong] return self._lib.AwaServerWriteOperation_AddValueAsTime(operation, path, value)
def AwaServerWriteOperation_AddArrayValueAsInteger(self, operation, path, resourceInstanceID, value): self._lib.AwaServerWriteOperation_AddArrayValueAsInteger.restype = c_int self._lib.AwaServerWriteOperation_AddArrayValueAsInteger.argtypes = [c_void_p, c_char_p, c_int, c_longlong] return self._lib.AwaServerWriteOperation_AddArrayValueAsInteger(operation, path, resourceInstanceID, value)
def AwaServerWriteOperation_AddArrayValueAsTime(self, operation, path, resourceInstanceID, value): self._lib.AwaServerWriteOperation_AddArrayValueAsTime.restype = c_int self._lib.AwaServerWriteOperation_AddArrayValueAsTime.argtypes = [c_void_p, c_char_p, c_int, c_longlong] return self._lib.AwaServerWriteOperation_AddArrayValueAsTime(operation, path, resourceInstanceID, value)
def AwaServerDiscoverResponse_GetAttributeValueAsIntegerPointer(self, response, path, link, value): self._lib.AwaServerDiscoverResponse_GetAttributeValueAsIntegerPointer.restype = c_int mem = cast(value, POINTER(c_longlong)) return self._lib.AwaServerDiscoverResponse_GetAttributeValueAsIntegerPointer(byref(mem))