Python ctypes.c_long() Examples
The following are 30
code examples of ctypes.c_long().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ctypes
, or try the search function
.
Example #1
Source File: _core_foundation_ctypes.py From oscrypto with MIT License | 6 votes |
def cf_number_from_integer(integer): """ Creates a CFNumber object from an integer :param integer: The integer to create the CFNumber for :return: A CFNumber """ integer_as_long = c_long(integer) return CoreFoundation.CFNumberCreate( CoreFoundation.kCFAllocatorDefault, kCFNumberCFIndexType, byref(integer_as_long) )
Example #2
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def GetObjectText(self, flags): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, ctypes.POINTER(BSTR)) paramflags = ((_In_, 'lFlags'), (_Out_, 'pstrObjectText'), ) _GetObjectText = prototype(IWbemClassObject_GetObjectText_Idx, 'GetObjectText', paramflags) _GetObjectText.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj = _GetObjectText(self.this, flags ) return_obj = winapi.convert_bstr_to_str(return_obj) return return_obj
Example #3
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def SpawnDerivedClass(self, flags): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, ctypes.POINTER(wintypes.LPVOID)) paramflags = ((_In_, 'lFlags'), (_Out_, 'ppNewClass'), ) _SpawnDerivedClass = prototype(IWbemClassObject_SpawnDerivedClass_Idx, 'SpawnDerivedClass', paramflags) _SpawnDerivedClass.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj = _SpawnDerivedClass(self.this, flags ) try: return_obj = IWbemClassObject(return_obj) except WindowsError: return_obj = None return return_obj
Example #4
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def CompareTo(self, flags, compare_to): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, ctypes.POINTER(IWbemClassObject)) paramflags = ((_In_, 'lFlags'), (_In_, 'pCompareTo'), ) _CompareTo = prototype(IWbemClassObject_CompareTo_Idx, 'CompareTo', paramflags) _CompareTo.errcheck = winapi.RAISE_NON_ZERO_ERR _CompareTo(self.this, flags, compare_to.this if compare_to else None )
Example #5
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def SpawnInstance(self, flags): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, ctypes.POINTER(wintypes.LPVOID)) paramflags = ((_In_, 'lFlags'), (_Out_, 'ppNewInstance'), ) _SpawnInstance = prototype(IWbemClassObject_SpawnInstance_Idx, 'SpawnInstance', paramflags) _SpawnInstance.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj = _SpawnInstance(self.this, flags ) try: return_obj = IWbemClassObject(return_obj) except WindowsError: return_obj = None return return_obj
Example #6
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def GetNames(self, qualifier_name, flags, qualifier_val): prototype = ctypes.WINFUNCTYPE(HRESULT, wintypes.LPCWSTR, ctypes.c_long, ctypes.POINTER(winapi.VARIANT), ctypes.POINTER(wintypes.LPVOID)) paramflags = ((_In_, 'wszQualifierName'), (_In_, 'lFlags'), (_In_, 'pQualifierVal'), (_Out_, 'pNames'), ) _GetNames = prototype(IWbemClassObject_GetNames_Idx, 'GetNames', paramflags) _GetNames.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj = _GetNames(self.this, qualifier_name, flags, ctypes.byref(qualifier_val) if qualifier_val else None ) return_obj = ctypes.cast(wintypes.LPVOID(return_obj), ctypes.POINTER(winapi.SAFEARRAY)) return return_obj
Example #7
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def Put(self, name, flags, val, type_param): prototype = ctypes.WINFUNCTYPE(HRESULT, wintypes.LPCWSTR, ctypes.c_long, ctypes.POINTER(winapi.VARIANT), CIMTYPE) paramflags = ((_In_, 'wszName'), (_In_, 'lFlags'), (_In_, 'pVal'), (_In_, 'Type'), ) _Put = prototype(IWbemClassObject_Put_Idx, 'Put', paramflags) _Put.errcheck = winapi.RAISE_NON_ZERO_ERR _Put(self.this, name, flags, ctypes.byref(val) if val else None, type_param )
Example #8
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def Get(self, name, flags): prototype = ctypes.WINFUNCTYPE(HRESULT, wintypes.LPCWSTR, ctypes.c_long, ctypes.POINTER(winapi.VARIANT), ctypes.POINTER(CIMTYPE), ctypes.POINTER(ctypes.c_long)) paramflags = ((_In_, 'wszName'), (_In_, 'lFlags'), (_Out_, 'pVal'), (_Out_, 'pType'), (_Out_, 'plFlavor'), ) _Get = prototype(IWbemClassObject_Get_Idx, 'Get', paramflags) _Get.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj, return_obj2, return_obj3 = _Get(self.this, name, flags ) return return_obj, return_obj2, return_obj3
Example #9
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def GetNames(self, flags): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, ctypes.POINTER(wintypes.LPVOID)) paramflags = ((_In_, 'lFlags'), (_Out_, 'pNames'), ) _GetNames = prototype(IWbemQualifierSet_GetNames_Idx, 'GetNames', paramflags) _GetNames.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj = _GetNames(self.this, flags ) return_obj = ctypes.cast(wintypes.LPVOID(return_obj), ctypes.POINTER(winapi.SAFEARRAY)) return return_obj
Example #10
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def Put(self, name, val, flavor): prototype = ctypes.WINFUNCTYPE(HRESULT, wintypes.LPCWSTR, ctypes.POINTER(winapi.VARIANT), ctypes.c_long) paramflags = ((_In_, 'wszName'), (_In_, 'pVal'), (_In_, 'lFlavor'), ) _Put = prototype(IWbemQualifierSet_Put_Idx, 'Put', paramflags) _Put.errcheck = winapi.RAISE_NON_ZERO_ERR _Put(self.this, name, ctypes.byref(val) if val else None, flavor )
Example #11
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def Get(self, name, flags): prototype = ctypes.WINFUNCTYPE(HRESULT, wintypes.LPCWSTR, ctypes.c_long, ctypes.POINTER(winapi.VARIANT), ctypes.POINTER(ctypes.c_long)) paramflags = ((_In_, 'wszName'), (_In_, 'lFlags'), (_Out_, 'pVal'), (_Out_, 'plFlavor'), ) _Get = prototype(IWbemQualifierSet_Get_Idx, 'Get', paramflags) _Get.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj, return_obj2 = _Get(self.this, name, flags ) return return_obj, return_obj2
Example #12
Source File: element.py From UISoup with Apache License 2.0 | 6 votes |
def _find_windows_by_same_proc(self): """ Find window by same process id. :rtype: list :return: list of windows. """ enum_windows_proc = \ ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.c_long, ctypes.c_long) self._EnumWindowsCallback.same_proc_handles = set() ctypes.windll.user32.EnumWindows( enum_windows_proc( self._EnumWindowsCallback.callback), self.proc_id) if self._hwnd in self._EnumWindowsCallback.same_proc_handles: self._EnumWindowsCallback.same_proc_handles.remove(self._hwnd) result = [WinElement(hwnd, 0) for hwnd in self._EnumWindowsCallback.same_proc_handles] return result
Example #13
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def Next(self, flags): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, ctypes.POINTER(BSTR), ctypes.POINTER(winapi.VARIANT), ctypes.POINTER(ctypes.c_long)) paramflags = ((_In_, 'lFlags'), (_Out_, 'pstrName'), (_Out_, 'pVal'), (_Out_, 'plFlavor'), ) _Next = prototype(IWbemQualifierSet_Next_Idx, 'Next', paramflags) _Next.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj, return_obj2, return_obj3 = _Next(self.this, flags ) return_obj = winapi.convert_bstr_to_str(return_obj) return return_obj, return_obj2, return_obj3
Example #14
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def Skip(self, timeout, count): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, wintypes.ULONG) paramflags = ((_In_, 'lTimeout'), (_In_, 'nCount'), ) _Skip = prototype(IEnumWbemClassObject_Skip_Idx, 'Skip', paramflags) _Skip.errcheck = winapi.RAISE_NON_ZERO_ERR _Skip(self.this, timeout, count )
Example #15
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def GetResultObject(self, timeout): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, ctypes.POINTER(wintypes.LPVOID)) paramflags = ((_In_, 'lTimeout'), (_Out_, 'ppResultObject'), ) _GetResultObject = prototype(IWbemCallResult_GetResultObject_Idx, 'GetResultObject', paramflags) _GetResultObject.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj = _GetResultObject(self.this, timeout ) try: return_obj = IWbemClassObject(return_obj) except WindowsError: return_obj = None return return_obj
Example #16
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def GetResultServices(self, timeout): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, ctypes.POINTER(wintypes.LPVOID)) paramflags = ((_In_, 'lTimeout'), (_Out_, 'ppServices'), ) _GetResultServices = prototype(IWbemCallResult_GetResultServices_Idx, 'GetResultServices', paramflags) _GetResultServices.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj = _GetResultServices(self.this, timeout ) try: return_obj = IWbemServices(return_obj) except WindowsError: return_obj = None return return_obj
Example #17
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def GetCallStatus(self, timeout): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, ctypes.POINTER(ctypes.c_long)) paramflags = ((_In_, 'lTimeout'), (_Out_, 'plStatus'), ) _GetCallStatus = prototype(IWbemCallResult_GetCallStatus_Idx, 'GetCallStatus', paramflags) _GetCallStatus.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj = _GetCallStatus(self.this, timeout ) return return_obj
Example #18
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def GetNames(self, flags): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, ctypes.POINTER(wintypes.LPVOID)) paramflags = ((_In_, 'lFlags'), (_Out_, 'pNames'), ) _GetNames = prototype(IWbemContext_GetNames_Idx, 'GetNames', paramflags) _GetNames.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj = _GetNames(self.this, flags ) return_obj = ctypes.cast(wintypes.LPVOID(return_obj), ctypes.POINTER(winapi.SAFEARRAY)) return return_obj
Example #19
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def Next(self, flags): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, ctypes.POINTER(BSTR), ctypes.POINTER(winapi.VARIANT)) paramflags = ((_In_, 'lFlags'), (_Out_, 'pstrName'), (_Out_, 'pValue'), ) _Next = prototype(IWbemContext_Next_Idx, 'Next', paramflags) _Next.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj, return_obj2 = _Next(self.this, flags ) return_obj = winapi.convert_bstr_to_str(return_obj) return return_obj, return_obj2
Example #20
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def GetValue(self, name, flags): prototype = ctypes.WINFUNCTYPE(HRESULT, wintypes.LPCWSTR, ctypes.c_long, ctypes.POINTER(winapi.VARIANT)) paramflags = ((_In_, 'wszName'), (_In_, 'lFlags'), (_Out_, 'pValue'), ) _GetValue = prototype(IWbemContext_GetValue_Idx, 'GetValue', paramflags) _GetValue.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj = _GetValue(self.this, name, flags ) return return_obj
Example #21
Source File: workspace.py From typhon with MIT License | 6 votes |
def __verbosity_init__(self): """ Executes verbosityInit WSM directly through the ARTS api to suppress output. """ wsm = workspace_methods["verbosityInit"] (m_id, args_out, args_in, ts) = wsm._parse_output_input_lists(self, [], {}) arg_out_ptr = c.cast((c.c_long * len(args_out))(*args_out), c.POINTER(c.c_long)) arg_in_ptr = c.cast((c.c_long * len(args_in))(*args_in), c.POINTER(c.c_long)) with CoutCapture(self, silent = True): e_ptr = arts_api.execute_workspace_method(self.ptr, m_id, len(args_out), arg_out_ptr, len(args_in), arg_in_ptr) for t in ts[::-1]: t.erase()
Example #22
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def QueryObjectSink(self, flags): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, ctypes.POINTER(wintypes.LPVOID)) paramflags = ((_In_, 'lFlags'), (_Out_, 'ppResponseHandler'), ) _QueryObjectSink = prototype(IWbemServices_QueryObjectSink_Idx, 'QueryObjectSink', paramflags) _QueryObjectSink.errcheck = winapi.RAISE_NON_ZERO_ERR return_obj = _QueryObjectSink(self.this, flags ) try: return_obj = IWbemObjectSink(return_obj) except WindowsError: return_obj = None return return_obj
Example #23
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def PutClassAsync(self, object_param, flags, ctx, response_handler): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.POINTER(IWbemClassObject), ctypes.c_long, ctypes.POINTER(IWbemContext), ctypes.POINTER(IWbemObjectSink)) paramflags = ((_In_, 'pObject'), (_In_, 'lFlags'), (_In_, 'pCtx'), (_In_, 'pResponseHandler'), ) _PutClassAsync = prototype(IWbemServices_PutClassAsync_Idx, 'PutClassAsync', paramflags) _PutClassAsync.errcheck = winapi.RAISE_NON_ZERO_ERR _PutClassAsync(self.this, object_param.this if object_param else None, flags, ctx.this if ctx else None, response_handler.this if response_handler else None )
Example #24
Source File: _internal.py From recruit with Apache License 2.0 | 6 votes |
def _getintp_ctype(): val = _getintp_ctype.cache if val is not None: return val if ctypes is None: import numpy as np val = dummy_ctype(np.intp) else: 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
Example #25
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def PutInstanceAsync(self, inst, flags, ctx, response_handler): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.POINTER(IWbemClassObject), ctypes.c_long, ctypes.POINTER(IWbemContext), ctypes.POINTER(IWbemObjectSink)) paramflags = ((_In_, 'pInst'), (_In_, 'lFlags'), (_In_, 'pCtx'), (_In_, 'pResponseHandler'), ) _PutInstanceAsync = prototype(IWbemServices_PutInstanceAsync_Idx, 'PutInstanceAsync', paramflags) _PutInstanceAsync.errcheck = winapi.RAISE_NON_ZERO_ERR _PutInstanceAsync(self.this, inst.this if inst else None, flags, ctx.this if ctx else None, response_handler.this if response_handler else None )
Example #26
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def Indicate(self, object_count, obj_array): prototype = ctypes.WINFUNCTYPE(HRESULT, ctypes.c_long, ctypes.POINTER(wintypes.LPVOID)) paramflags = ((_In_, 'lObjectCount'), (_In_, 'apObjArray'), ) _Indicate = prototype(IWbemObjectSink_Indicate_Idx, 'Indicate', paramflags) _Indicate.errcheck = winapi.RAISE_NON_ZERO_ERR _Indicate(self.this, object_count, obj_array.this if obj_array else None )
Example #27
Source File: utils.py From contextualbandits with BSD 2-Clause "Simplified" License | 6 votes |
def fit(self, X, y): if X.shape[0] == 0: return self elif np.unique(y).shape[0] <= 1: self.update_aux(y) return self seed = self.random_state.integers(np.iinfo(np.int32).max) self.model.set_params(random_state = seed) self.model.fit(X, y) n_nodes = self.model.tree_.node_count self.pos = np.zeros(n_nodes, dtype=ctypes.c_long) self.neg = np.zeros(n_nodes, dtype=ctypes.c_long) pred_node = self.model.apply(X).astype(ctypes.c_long) _create_node_counters(self.pos, self.neg, pred_node, y.astype(ctypes.c_double)) self.pos = self.pos.astype(ctypes.c_double) + self.beta_prior[0] self.neg = self.neg.astype(ctypes.c_double) + self.beta_prior[1] self.is_fitted = True return self
Example #28
Source File: wmi.py From cWMI with Apache License 2.0 | 6 votes |
def DeleteValue(self, name, flags): prototype = ctypes.WINFUNCTYPE(HRESULT, wintypes.LPCWSTR, ctypes.c_long) paramflags = ((_In_, 'wszName'), (_In_, 'lFlags'), ) _DeleteValue = prototype(IWbemContext_DeleteValue_Idx, 'DeleteValue', paramflags) _DeleteValue.errcheck = winapi.RAISE_NON_ZERO_ERR _DeleteValue(self.this, name, flags )
Example #29
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 5 votes |
def readSpecificSkip(self, id_): self.canlib.fn = inspect.currentframe().f_code.co_name # msg will be replaced by class when CAN FD is supported _MAX_SIZE = 64 msg = ct.create_string_buffer(_MAX_SIZE) id_ = ct.c_long(id_) dlc = ct.c_uint() flag = ct.c_uint() time = ct.c_ulong() self.dll.canReadSpecificSkip(self.handle, id_, msg, dlc, flag, time) length = min(_MAX_SIZE, dlc.value) return(id_.value, bytearray(msg.raw[:length]), dlc.value, flag.value, time.value)
Example #30
Source File: canlib.py From Udacity-SDC-Radar-Driver-Micro-Challenge with MIT License | 5 votes |
def getBusParamsFd(self): """Get bus timing parameters for BRS in CAN FD This function retrieves the bus current timing parameters used in BRS (Bit rate switch) mode for the current CANlib channel. The library provides default values for tseg1_brs, tseg2_brs and sjw_brs when freq is specified to one of the pre-defined constants, canFD_BITRATE_xxx. If freq is any other value, no default values are supplied by the library. Returns: A tuple containing: freq_brs: Bitrate in bit/s. tseg1_brs: Number of quanta from (but not including) the Sync Segment to the sampling point. tseg2_brs: Number of quanta from the sampling point to the end of the bit. sjw_brs: The Synchronization Jump Width. """ self.canlib.fn = inspect.currentframe().f_code.co_name freq_brs = ct.c_long() tseg1_brs = ct.c_uint() tseg2_brs = ct.c_uint() sjw_brs = ct.c_uint() self.dll.canGetBusParamsFd(self.handle, ct.byref(freq_brs), ct.byref(tseg1_brs), ct.byref(tseg2_brs), ct.byref(sjw_brs)) return (freq_brs.value, tseg1_brs.value, tseg2_brs.value, sjw_brs.value)