git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34708
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
#define wxGetOSFHandle(fd) ((HANDLE)_get_osfhandle(fd))
#endif
+// close the handle in the class dtor
+class AutoHANDLE
+{
+public:
+ wxEXPLICIT AutoHANDLE(HANDLE handle) : m_handle(handle) { }
+
+ bool IsOk() const { return m_handle != INVALID_HANDLE_VALUE; }
+ operator HANDLE() const { return m_handle; }
+
+ ~AutoHANDLE() { if ( IsOk() ) ::CloseHandle(m_handle); }
+
+protected:
+ HANDLE m_handle;
+};
+
#if wxUSE_GUI
#include <wx/gdicmn.h>