-
-
[求助]网络传输用什么压缩引擎比较好?
-
发表于:
2008-11-27 00:28
6755
-
网络上数据传输,类型不限,一般用什么算法比较合理?
我测试用 Windows 自带的 RtlCompressBuffer 函数,好象压缩比和速度都不是很好啊,难道我参数设置的不合理?
该函数采用的是什么压缩算法,请高手赐教!
#define CMP_FRM COMPRESSION_FORMAT_LZNT1 | COMPRESSION_ENGINE_STANDARD
BOOL WINAPI InitApi()
{
HMODULE hNtDll=GetModuleHandle("ntdll.dll");
if(hNtDll==NULL)
return FALSE;
RtlGetCompressionWorkSpaceSize=(GetCompressionWorkSpaceSize)GetProcAddress(hNtDll,"RtlGetCompressionWorkSpaceSize");
RtlCompressBuffer=(CompressBuffer)GetProcAddress(hNtDll,"RtlCompressBuffer");
RtlDecompressBuffer=(DecompressBuffer)GetProcAddress(hNtDll,"RtlDecompressBuffer");
return RtlGetCompressionWorkSpaceSize!=NULL && RtlCompressBuffer!=NULL && RtlDecompressBuffer!=NULL;
}
DWORD WINAPI MyCompressBuffer ( LPVOID lpDest, LPDWORD lpdwDestLen, LPCVOID lpSrc, DWORD dwSrcLen )
{
DWORD ret=0,dwLen1=0,dwLen2=0;
LPVOID lpTempMemory=NULL;
ret=RtlGetCompressionWorkSpaceSize(CMP_FRM, &dwLen1, &dwLen2);
lpTempMemory =LocalAlloc(LPTR,dwLen1);
ret=RtlCompressBuffer(CMP_FRM, lpSrc, dwSrcLen, lpDest, *lpdwDestLen, dwLen2, &dwLen1, lpTempMemory);
LocalFree(lpTempMemory);
*lpdwDestLen=dwLen1;
return ret;
}
DWORD WINAPI MyDecompressBuffer( LPVOID lpDest, LPDWORD lpdwDestLen, LPCVOID lpSrc, DWORD dwSrcLen )
{
DWORD ret=0,dwLen1=0,dwLen2=0;
ret=RtlGetCompressionWorkSpaceSize(CMP_FRM, &dwLen1, &dwLen2);
ret=RtlDecompressBuffer(CMP_FRM, lpDest, *lpdwDestLen, lpSrc, dwSrcLen, &dwLen2);
*lpdwDestLen=dwLen2;
return ret;
}
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!