www.pudn.com > Modbus.rar > zlib.cs, change:2013-04-09,size:1318b


using System; 
using System.Collections.Generic; 
//using System.Linq; 
using System.Text; 
using System.Runtime.InteropServices;   
     
  namespace Modbus数据采集工具   
  {   
      public enum ZLibError:int   
      {   
          Z_OK  =  0,   
          Z_STREAM_END  =  1,   
          Z_NEED_DICT  =  2,   
          Z_ERRNO  =  (-1),   
          Z_STREAM_ERROR  =  (-2),   
          Z_DATA_ERROR  =  (-3),   
          Z_MEM_ERROR  =  (-4),   
          Z_BUF_ERROR  =  (-5),   
          Z_VERSION_ERROR  =  (-6),   
      }   
         
      public enum ZLibCompressionLevel:int   
      {   
          Z_NO_COMPRESSION  =  0,  
          Z_BEST_SPEED  =  1,  
          Z_BEST_COMPRESSION  =  9,  
          Z_DEFAULT_COMPRESSION  =  (-1)  
      }   
     
      public  class  ZLib   
      { 
          [DllImport("zlib1.dll")]   
          public static extern ZLibError compress(byte[]dest,ref int destLength,byte[]source,int sourceLength); 
          [DllImport("zlib1.dll")]   
          public static extern ZLibError compress2(byte[]dest,ref int destLength,byte[]source,int sourceLength,ZLibCompressionLevel level); 
          [DllImport("zlib1.dll")]   
          public static extern ZLibError uncompress(byte[]dest,ref int destLen,byte[]source,int sourceLen);  
      }   
  }