[API]
RtlMoveMemory
WriteFile
CloseHandle

[INCLUDE]
CreateFile
RegionSet_Free

[DEFINE]

[CODE]
Public Function RegionSet_Save(ByVal hRegionSet As Long, ByVal Filename As String) As Boolean
  Dim xNumEnts(5) As Integer
  Dim xSize As Long
  Dim hFile As Long
  Dim xLong1 As Long

  If Not hRegionSet = 0& Then
    Call RtlMoveMemory(ByVal VarPtr(xNumEnts(0&)), ByVal hRegionSet, 12&)
    xSize = 12& + xNumEnts(0&) * 9& + (xNumEnts(1&) + xNumEnts(2&) + xNumEnts(3&) + xNumEnts(4&) + xNumEnts(5&)) * 4&
    If Not xSize = 0& Then
      hFile = CreateFile(Filename, CreateAlwaysNew, FILE_WRITE)
      If Not hFile = -1& Then
        If Not WriteFile(hFile, ByVal hRegionSet, xSize, xLong1, 0&) = 0& Then
          RegionSet_Save = (xLong1 = xSize)
          End If
        Call CloseHandle(hFile)
        End If
      End If
    End If
  End Function
