# File lib/win32/clipboard.rb, line 30
      def self.set_data(clip_data, format = TEXT)
         self.open
         EmptyClipboard()

         # NULL terminate text
         case format
            when TEXT, OEMTEXT, UNICODETEXT                             
               clip_data << "\0"
         end

         # Global Allocate a movable piece of memory.
         hmem = GlobalAlloc(GHND, clip_data.length + 4)
         mem  = GlobalLock(hmem)
         @@Memcpy.call(mem, clip_data, clip_data.length)

         # Set the new data
         if SetClipboardData(format, hmem) == 0
            error = get_last_error
            GlobalFree(hmem)
            self.close
            raise Error, "SetClipboardData() failed: #{error}"
         end

         GlobalFree(hmem)   
         self.close
         self
      end