[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int DecompressMCX(object hComp,ref byte[] @in, uint @in_len, ref byte[] @out, ref uint out_len, bool eod);
public class XceedCompressor
{
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);
byte[] OutRec = new byte[1024 * 100];
uint outlen;
DecompressMCX DecompressDelegate;
int b ;
unsafe int l;
public XceedCompressor()
{
IntPtr pDll = LoadLibrary(@"xceedzip.dll");
IntPtr pAddressOfFunctionToCall = GetProcAddress(pDll, "XcUncompress");
DecompressDelegate = (DecompressMCX)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall, typeof(DecompressMCX));
}
public byte[] Decompress(byte[] InRecArr)
{
outlen = 0;
l = DecompressDelegate(b, ref InRecArr, (uint)InRecArr.Length, ref OutRec, ref outlen, true);
return OutRec;
}
}
这是我要进行减压的课程。
XceedCompressor xcd = new XceedCompressor ();
xcd.Decompress(some data already compressed with the same library);
但它给出的错误是“尝试读取或写入受保护的内存。这通常表明其他内存已损坏。”
http://doc.xceedsoft.com/products/Xceedzip/Uncompress_method.html
是我要调用的功能。希望有最好的解决方案,就像我在这里总能找到的那样。提前致谢。