大家好,又见面了,我是全栈君。
//dll内部封装API格式
//gzip BOOL fnZlibDecompressPacket (__IN_PARAM unsigned char* gZlibDataBuffer, __IN_PARAM size_t gZLibDataLength, __OUT_PARAM char* pChDataBuffer, __OUT_PARAM DWORD *pdwLength); BOOL fnZlibCompressPacket (__IN_PARAM unsigned char* gZlibDataBuffer, __IN_PARAM size_t gZLibDataLength, __OUT_PARAM char * pchGzipOutData, __OUT_PARAM DWORD *pdwLength); //zlib BOOL fnGzipDecompressPacket (__IN_PARAM unsigned char* gzipDataBuffer, __IN_PARAM size_t gzipDataBuffer_Length, __OUT_PARAM char* pChDataBuffer, __OUT_PARAM DWORD *pdwLength); BOOL fnGzipCompressPacket (__IN_PARAM const char * gzipDataBuffer, __IN_PARAM int gzipDataBuffer_Length, __OUT_PARAM char * dstDataBuffer, __OUT_PARAM int *pdwLength);
//GZIP调用核心代码演示
typedef BOOL (*UncompressionGzipPacketToBuffer) (unsigned char* gZipDataBuffer, size_t gZipDataLength, char * pDataBuffer,DWORD *dwLength); typedef BOOL (*CompressionBufferPacketToGzip) ( unsigned char* chDataBuffer, size_t chDataLength, char* pGzipBuffer,DWORD *dwLength); HINSTANCE hInst=NULL; UncompressionGzipPacketToBuffer UngzipPacket; CompressionBufferPacketToGzip ComGzipBuffer; hInst=LoadLibrary(_T("GzipZlibdll.dll")); if (hInst==NULL) { return -1; } UngzipPacket=(UncompressionGzipPacketToBuffer)GetProcAddress(hInst,"fnGzipDecompressPacket"); ComGzipBuffer=(CompressionBufferPacketToGzip)GetProcAddress(hInst,"fnGzipCompressPacket"); if (UngzipPacket==NULL) { return -1; } if (ComGzipBuffer==NULL) { return -1; } BOOL bRet=UngzipPacket((unsigned char*)pChGzipBuff,dwReaded,pChDataBuff,&dwTransferSize); //注意此处dwGzipSize的必须有值,不能传递0考虑到压缩之后一定比原来数据小。传递dwTransferSize大小就可以 BOOL bReturn=ComGzipBuffer((unsigned char*)pChDataBuff,dwTransferSize,pChGzipBuff,&dwGzipSize); FreeLibrary(hInst);
//zlib同上演示样例。
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/115681.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...