def Detach(self): h = int(self) if h != -1: c_handle = self.c_handle self.c_handle = _INVALID_HANDLE_VALUE _ffi.gc(c_handle, None) return h
def Close(self): if int(self) != -1: c_handle = self.c_handle self.c_handle = _INVALID_HANDLE_VALUE _ffi.gc(c_handle, None) _kernel32.CloseHandle(c_handle)
def __init__(self, c_handle): # 'c_handle' is a cffi cdata of type HANDLE, which is basically 'void *' self.c_handle = c_handle if int(self) != -1: self.c_handle = _ffi.gc(self.c_handle, _kernel32.CloseHandle)