本文介绍了C#中的lzo_1z解压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好


我想在C#中使用lzo1.07.dll文件中的lzo_1z解压缩功能

该函数的语法为

hello


i want to use lzo_1z decompress function from lzo1.07.dll file in C#

The syntax for the function is

lzo_decomp (char* inp_buff, unsigned int* inp_len, char* buffer_decomp,
unsigned int *output_len, unsigned short *errorCode)



在哪里,



where,

Inp_buff- Specifies the input buffer (Compressed Buffer)
Inp_len- Specifies the length of input buffer (Compressed Length)
Buffer_decomp- Specifies the Buffer after decompression
output_len- Specifies the length after decompression ( Out put length )
errorCode- Specifies the error code



可以拨打



and call can be made as

lzo1z_decompress (out, decomp_inlen, in, & decomp_outlen, NULL)


我想在C#中使用以上功能



i wanted to use above function in C#


unsafe class lzoCompress {

[DllImport(@"C:\Documents and Settings\Developer1\My Documents\Visual Studio 2010\Projects\lzoCTCLDecompression\lzoCTCLDecompression\bin\Debug\lzo107.dll",CallingConvention=CallingConvention.StdCall)]

public static extern int lzo1z_decompress([MarshalAs(UnmanagedType.LPArray)] char[] inp_buff, ref ushort inp_len, [MarshalAs(UnmanagedType.LPArray)] char[] out_buff, ref int out_len, ref ushort errorCode);

public static char[] Decompress(byte[] src)
{
int origlen = BitConverter.ToInt32(src, src.Length - 4);
char[] ch = new char[origlen];
string str = BitConverter.ToString(src);
ch = str.ToCharArray();
char[] dst = new char[origlen];
int outlen = origlen;
int Srclength = src.Length - 4;
ushort inp_len = (ushort)src.Length;
int out_len = dst.Length;
ushort error = 0;
try
{
int i =lzo1z_decompress(ch, ref inp_len, dst, ref out_len, ref error);
} catch (Exception e) { }
}




我在try block




i am getting an error as pinvoke

推荐答案

解决方案

错误,您已经问了这个问题 [ ^ ],并提出了一些建议.请不要重复发布相同的问题一次.




这篇关于C#中的lzo_1z解压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 08:03