Mercurial > vba-clojure
view src/win32/7zip/7z/CPP/Windows/Handle.h @ 4:5f6f2134e8ce
apu appears to not be used
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:35:58 -0600 |
parents | f9f4f1b99eed |
children |
line wrap: on
line source
1 // Windows/Handle.h3 #ifndef __WINDOWS_HANDLE_H4 #define __WINDOWS_HANDLE_H6 namespace NWindows {8 class CHandle9 {10 protected:11 HANDLE _handle;12 public:13 operator HANDLE() { return _handle; }14 CHandle(): _handle(NULL) {}15 ~CHandle() { Close(); }16 bool Close()17 {18 if (_handle == NULL)19 return true;20 if (!::CloseHandle(_handle))21 return false;22 _handle = NULL;23 return true;24 }25 void Attach(HANDLE handle)26 { _handle = handle; }27 HANDLE Detach()28 {29 HANDLE handle = _handle;30 _handle = NULL;31 return handle;32 }33 };35 }37 #endif