C#中的lzo_1z解压缩 [英] lzo_1z decompression in C#

查看:77
本文介绍了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

推荐答案

中遇到pinvoke
解决方案

错误,您已经问了这个问题

You have already asked this question here[^], and been given some suggestions. Please do not repost the same question more than once.


如果可以得到LZO .NET包装器,为什么还要跳过篮球?
请在此处查看:
用于.NET的LZO.NET高速压缩 [
Why do you want to jump through hoops if you can get a LZO .NET wrapper?
Please see here: LZO.NET Highspeed Compression for .NET[^].

Regards,

Manfred


在DllImport中,您可以选择CallingConvention=CallingConvention.StdCall.您确定压缩库使用此格式,因为此处使用错误的选项可能会导致您看到错误?
In your DllImport you have the option CallingConvention=CallingConvention.StdCall. Are you sure that the compression library uses this form, as using the wrong option here will probably cause the error you are seeing?


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆