欢迎来到天天文库
浏览记录
ID:9370680
大小:87.50 KB
页数:10页
时间:2018-04-29
《vb源代码-crc32自校验》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、'类模块(名称为clsCRC)代码OptionExplicitPublicEnumCRCAlgorithmsCRC16CRC32EndEnumPrivatem_AlgorithmAsBooleanPrivatem_CRC16AsLongPrivatem_CRC16Asm()AsBytePrivatem_CRC16InitAsBooleanPrivatem_CRC16Table(0To255)AsLongPrivatem_CRC32AsLongPrivatem_CRC32Asm()AsBytePrivatem_CRC32InitAsBooleanPrivatem_CRC32Tab
2、le(0To255)AsLongPrivateDeclareFunctionCallWindowProcLib"user32"Alias"CallWindowProcA"(ByVallpPrevWndFuncAsLong,ByValhWndAsLong,ByValMsgAsLong,ByValwParamAsLong,ByVallParamAsLong)AsLongPublicFunctionAddBytes(ByteArray()AsByte)AsVariantDimByteSizeAsLongOnLocalErrorGoToNoDataByteSize=UBound(Byt
3、eArray)-LBound(ByteArray)+1OnLocalErrorGoTo0SelectCasem_AlgorithmCaseCRC16CallCallWindowProc(VarPtr(m_CRC16Asm(0)),VarPtr(m_CRC16),VarPtr(ByteArray(LBound(ByteArray))),VarPtr(m_CRC16Table(0)),ByteSize)CaseCRC32CallCallWindowProc(VarPtr(m_CRC32Asm(0)),VarPtr(m_CRC32),VarPtr(ByteArray(LBound(B
4、yteArray))),VarPtr(m_CRC32Table(0)),ByteSize)EndSelectNoData:AddBytes=ValueEndFunctionPublicFunctionAddString(TextAsString)AsVariantAddString=AddBytes(StrConv(Text,vbFromUnicode))EndFunctionPublicPropertyLetAlgorithm(New_ValueAsCRCAlgorithms)m_Algorithm=New_ValueSelectCasem_AlgorithmCaseCRC1
5、6If(Notm_CRC16Init)ThenCallInitializeCRC16CaseCRC32If(Notm_CRC32Init)ThenCallInitializeCRC32EndSelectCallClearEndPropertyPublicPropertyGetAlgorithm()AsCRCAlgorithmsAlgorithm=m_AlgorithmEndPropertyPublicFunctionCalculateBytes(ByteArray()AsByte)AsVariantCallClearCalculateBytes=AddBytes(ByteArr
6、ay)EndFunctionPublicFunctionCalculateFile(FilenameAsString)AsVariantDimFilenrAsIntegerDimByteArray()AsByteIf(FileLen(Filename)=0)ThenExitFunctionFilenr=FreeFileOpenFilenameForBinaryAs#FilenrReDimByteArray(0ToLOF(Filenr)-9)Get#Filenr,,ByteArray()Close#FilenrCalculateFile=CalculateBytes(ByteAr
7、ray)EndFunctionPublicPropertyGetValue()AsVariantSelectCasem_AlgorithmCaseCRC16Value=(m_CRC16And65535)CaseCRC32Value=(Notm_CRC32)EndSelectEndPropertyPublicPropertyLetValue(New_ValueAsVariant)SelectCasem_AlgorithmCaseCRC16m_CRC16=New_ValueCaseCRC32m_
此文档下载收益归作者所有