我现在想使用 LZMA 压缩算法中的 LZMA.dll ,但总是调试不出来,谁有如何测试使用 LZMA.dll的 VC 测试程序,发一下呀,特别感谢。就是如何调用使用这两个函数呀。
EXPORTS
  LzmaCompress
  LzmaUncompress

解决方案 »

  1.   

    http://www.pudn.com/downloads22/sourcecode/zip/detail71749.html
    看看有没有你要的
      

  2.   

    谢谢 Troj4n 但这个并不是我想要的。
      

  3.   

    这个dll你可以自己生成,要是没有,提供个信箱。
      

  4.   

    http://www.namipan.com/d/thirdlib.rar/4420c4cd998b8d0462e5d66ebafc386bcd29ce99141c0200我上传了。
    一个lib,一个dll,里面因为还有zlib,和其他一些压缩解压函数,所以有点大。
      

  5.   

    我有zlib的静态库和头文件。不知道怎么给你。
      

  6.   

    SizeT destBufLen=packet->orgLength;
    Byte *destBuf=new Byte[destBufLen];
    SizeT srcLen=packet->length;
    SRes ret=Lzma86_Decode(destBuf,&destBufLen,(const Byte *)packet->data,&srcLen);
    我用的是Lzma86_Decode,这是解压部分,压缩部分也差不多。
      

  7.   

    谢谢上面各位,这些 DLL LIB 头文件我都 有,LZMA 的SDK  我也下载 了。只是不会调用DLL  中的这两个函数 LzmaCompress   LzmaUncompress  HINSTANCE hInst;
    hInst = LoadLibrary("LZMA.dll");
    // LzmaCompress
    // LzmaUncompress

    typedef int (*FuncCompress)(unsigned char *dest, 
     size_t *destLen, 
     const unsigned char *src, 
     size_t srcLen,
     unsigned char *outProps, 
     size_t *outPropsSize, /* *outPropsSize must be = 5 */
     int level,      /* 0 <= level <= 9, default = 5 */
     unsigned dictSize,  /* default = (1 << 24) */
     int lc,        /* 0 <= lc <= 8, default = 3  */
     int lp,        /* 0 <= lp <= 4, default = 0  */
     int pb,        /* 0 <= pb <= 4, default = 2  */
     int fb,        /* 5 <= fb <= 273, default = 32 */
     int numThreads /* 1 or 2, default = 2 */
      );
    typedef int (*FuncUnCompress)(unsigned char *dest, 
    size_t *destLen, 
    const unsigned char *src,
    size_t  *srcLen,
    const unsigned char *props, 
    size_t propsSize); FuncCompress    MyCompress = (FuncCompress)GetProcAddress(hInst, "LzmaCompress");
    FuncUnCompress  MyUnCompress = (FuncUnCompress)GetProcAddress(hInst, "LzmaUncompress"); 
    if(!MyCompress)
    {
    MessageBox("获取函数地址失败! ");
    return;
    }
    if(!MyUnCompress)
    {
    MessageBox("获取uncompress函数地址失败! ");
    return;
    } const unsigned char srcarr[] = "hello hello world";
    unsigned int   PropsSize = 5; unsigned char outpprops[] = "abcde"; unsigned char *dest;  
    size_t *destLen;
        const unsigned char *src = srcarr;
    size_t srcLen = 18;
    unsigned char *outProps = outpprops; 
    size_t *outPropsSize = &PropsSize; // outPropsSize must be = 5 
    int level = 5; // 0 <= level <= 9, default = 5
    unsigned dictSize = 1; // default = (1 << 24)
    int lc = 3; // 0 <= lc <= 8, default = 3
    int lp = 0; // 0 <= lp <= 4, default = 0
    int pb = 2; // 0 <= pb <= 4, default = 2
    int fb = 32; // 5 <= fb <= 273, default = 32
    int numThreads = 2; // 1 or 2, default = 2
        MyCompress(dest, destLen, src, srcLen,outProps, outPropsSize, level, dictSize, lc, lp, pb, fb, numThreads );//在这些出错了。#define MY_STDAPI MY_EXTERN_C int MY_STD_CALLLzmaCompress
    ------------outPropsSize -
         In:  the pointer to the size of outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.
         Out: the pointer to the size of written properties in outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.  LZMA Encoder will use defult values for any parameter, if it is
      -1  for any from: level, loc, lp, pb, fb, numThreads
       0  for dictSize
      
    level - compression level: 0 <= level <= 9;  level dictSize algo  fb
        0:    16 KB   0    32
        1:    64 KB   0    32
        2:   256 KB   0    32
        3:     1 MB   0    32
        4:     4 MB   0    32
        5:    16 MB   1    32
        6:    32 MB   1    32
        7+:   64 MB   1    64
     
      The default value for "level" is 5.  algo = 0 means fast method
      algo = 1 means normal methoddictSize - The dictionary size in bytes. The maximum value is
            128 MB = (1 << 27) bytes for 32-bit version
              1 GB = (1 << 30) bytes for 64-bit version
         The default value is 16 MB = (1 << 24) bytes.
         It's recommended to use the dictionary that is larger than 4 KB and
         that can be calculated as (1 << N) or (3 << N) sizes.lc - The number of literal context bits (high bits of previous literal).
         It can be in the range from 0 to 8. The default value is 3.
         Sometimes lc=4 gives the gain for big files.lp - The number of literal pos bits (low bits of current position for literals).
         It can be in the range from 0 to 4. The default value is 0.
         The lp switch is intended for periodical data when the period is equal to 2^lp.
         For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often it's
         better to set lc=0, if you change lp switch.pb - The number of pos bits (low bits of current position).
         It can be in the range from 0 to 4. The default value is 2.
         The pb switch is intended for periodical data when the period is equal 2^pb.fb - Word size (the number of fast bytes).
         It can be in the range from 5 to 273. The default value is 32.
         Usually, a big number gives a little bit better compression ratio and
         slower compression process.numThreads - The number of thereads. 1 or 2. The default value is 2.
         Fast mode (algo = 0) can use only 1 thread.Out:
      destLen  - processed output size
    Returns:
      SZ_OK               - OK
      SZ_ERROR_MEM        - Memory allocation error
      SZ_ERROR_PARAM      - Incorrect paramater
      SZ_ERROR_OUTPUT_EOF - output buffer overflow
      SZ_ERROR_THREAD     - errors in multithreading functions (only for Mt version)
    */MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen,
      unsigned char *outProps, size_t *outPropsSize, /* *outPropsSize must be = 5 */
      int level,      /* 0 <= level <= 9, default = 5 */
      unsigned dictSize,  /* default = (1 << 24) */
      int lc,        /* 0 <= lc <= 8, default = 3  */
      int lp,        /* 0 <= lp <= 4, default = 0  */
      int pb,        /* 0 <= pb <= 4, default = 2  */
      int fb,        /* 5 <= fb <= 273, default = 32 */
      int numThreads /* 1 or 2, default = 2 */
      );/*
    LzmaUncompress
    --------------
    In:
      dest     - output data
      destLen  - output data size
      src      - input data
      srcLen   - input data size
    Out:
      destLen  - processed output size
      srcLen   - processed input size
    Returns:
      SZ_OK                - OK
      SZ_ERROR_DATA        - Data error
      SZ_ERROR_MEM         - Memory allocation arror
      SZ_ERROR_UNSUPPORTED - Unsupported properties
      SZ_ERROR_INPUT_EOF   - it needs more bytes in input buffer (src)
    */MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen,
      const unsigned char *props, size_t propsSize);
      

  8.   

    #define MY_STDAPI MY_EXTERN_C int MY_STD_CALL 以上我写的,以下是头文件拷过来的。
      

  9.   

    这两个函数以前我用过,后来嫌麻烦我就直接用那个lzma86的两个了,但可以肯定,这个函数没问题。
      

  10.   

    我在这句时 MyCompress(dest, destLen, src, srcLen,outProps, outPropsSize, level, dictSize, lc, lp, pb, fb, numThreads ); 时出错了,大家看看哪有错呀,我这会加了 typedef int (_stdcall *FuncCompress)(unsigned char *dest, 
     size_t *destLen, 
     const unsigned char *src, 
     size_t srcLen,
     unsigned char *outProps, 
     size_t *outPropsSize, /* *outPropsSize must be = 5 */
     int level,      /* 0 <= level <= 9, default = 5 */
     unsigned dictSize,  /* default = (1 << 24) */
     int lc,        /* 0 <= lc <= 8, default = 3  */
     int lp,        /* 0 <= lp <= 4, default = 0  */
     int pb,        /* 0 <= pb <= 4, default = 2  */
     int fb,        /* 5 <= fb <= 273, default = 32 */
     int numThreads /* 1 or 2, default = 2 */
      );
      

  11.   

    没有使用过这个库,但使用过zlib库,很好用,压缩解压缩很方便。
    压缩:
    compress2(dstbuffer, &streamlen, buffer, buffersize, Z_BEST_COMPRESSION);
    看下定义:
    ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,  uLongf *destLen,
                                      const Bytef *source, uLong sourceLen,
                                      int level));
    当然也可以使用compress,定义如下:
    ZEXTERN int ZEXPORT compress OF((Bytef *dest,  uLongf *destLen,
                                    const Bytef *source, uLong sourceLen));解压缩uncompress,看定义:
    ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,  uLongf *destLen,
                                      const Bytef *source, uLong sourceLen));
      

  12.   

    这个最后没有做出来,最后用了 fengrx 说的 zlib1.dll 效果还可以。不过花了两天时间没有做出来,很遗憾的。谢谢各位,散分了。
      

  13.   

    来学习下,也纠结了LzmaCompress好久,期待高人解答,回去试试zlib1.dll