+// smart buffeer using GlobalAlloc/GlobalFree()
+class GlobalPtr
+{
+public:
+    // allocates a block of given size
+    GlobalPtr(size_t size, unsigned flags = GMEM_MOVEABLE)
+    {
+        m_hGlobal = ::GlobalAlloc(flags, size);
+        if ( !m_hGlobal )
+            wxLogLastError(_T("GlobalAlloc"));
+    }
+
+    ~GlobalPtr()
+    {
+        if ( m_hGlobal && ::GlobalFree(m_hGlobal) )
+            wxLogLastError(_T("GlobalFree"));
+    }
+
+    // implicit conversion
+    operator HGLOBAL() const { return m_hGlobal; }
+
+private:
+    HGLOBAL m_hGlobal;
+
+    DECLARE_NO_COPY_CLASS(GlobalPtr)
+};
+