using System; using System.Runtime.InteropServices; namespace test { /// /// Summary description for al. /// public class al { public al() { // // TODO: Add constructor logic here // } [DllImport("al21mfc.dll",EntryPoint="newALGlDecompressor")] public static extern long newALGlDecompressor(int compressionlevel); [DllImport("al21mfc.dll",EntryPoint="newALWinMemory")] public static extern long newALWinMemory(string BufferName,byte[] UserBuffer, long UserBufferSize); [DllImport("al21mfc.dll",EntryPoint="ALDecompress",SetLastError=true)] public static extern long ALDecompress(long Decompressor, long InputStorage, long OutputStorage, long CompressedLength); [DllImport("al21mfc.dll",EntryPoint="ALMemoryBaseGetBufferSize")] public static extern long ALMemoryBaseGetBufferSize(long storage); // [DllImport("al21mfc.dll",EntryPoint="ALWinMemoryGetBuffer")] // public static extern byte[] ALWinMemoryGetBuffer(long storage); [DllImport("al21mfc.dll",EntryPoint="deleteALStorage")] public static extern void deleteALStorage(long storage); [DllImport("al21mfc.dll",EntryPoint="ALStorageIsOpen")] public static extern long ALStorageIsOpen(long storage); [DllImport("al21mfc.dll",EntryPoint="ALStorageOpen")] public static extern long ALStorageOpen(long storage); [DllImport("al21mfc.dll",EntryPoint="ALStorageFlushBuffer")] public static extern long ALStorageFlushBuffer(long storage); [DllImport("al21mfc.dll",EntryPoint="ALStorageSeek")] public static extern long ALStorageSeek(long storage,long address); [DllImport("al21mfc.dll",EntryPoint="ALStorageGetSize")] public static extern long ALStorageGetSize(long storage); [DllImport("al21mfc.dll",EntryPoint="ALStorageReadBuffer")] public static extern long ALStorageReadBuffer(long storage, byte [] buffer, long length); [DllImport("al21mfc.dll",EntryPoint="ALStorageClose")] public static extern long ALStorageClose(long storage); public static byte[] ALWinMemoryGetBuffer(long mem_object) { long open_object=0; open_object = ALStorageIsOpen(mem_object); if(open_object == 0 ) ALStorageOpen (mem_object); long Length=0; ALStorageFlushBuffer (mem_object); long I; I = ALStorageSeek(mem_object, 0); Length = ALStorageGetSize(mem_object); byte[] a = new byte[Length]; I = ALStorageReadBuffer(mem_object, a, Length); if (open_object == 0 ) ALStorageClose (mem_object); return a; } public enum Compressionlevel { AL_GREENLEAF_LEVEL_0 = 0, AL_GREENLEAF_LEVEL_1 = 1, AL_GREENLEAF_LEVEL_2 = 2, AL_GREENLEAF_LEVEL_3 = 3, AL_GREENLEAF_LEVEL_4 = 4 } } }