VB 用彙編進行快速CRC較驗

因為利用了彙編代碼,速度特別快,有空可以測試測試.
新建一個EXE工程,加入兩個TEXTBOX控件,默認名稱,一個BUTTON控件即可.

Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, _
ByVal hwnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long


Private Function
AsmCrc(bytInput() As Byte, ByVal Init As Long) As Long
Dim
Asm(5) As Long
Asm(0) = &H5B5A5958
Asm(1) = &HC033505E
Asm(2) = &H3018A36
Asm(3) = &H41CED1F0
Asm(4) = &HF47ECA3B
Asm(5) = &HC3338936
CallWindowProc VarPtr(Asm(0)), _
VarPtr(bytInput(LBound(bytInput))), _
VarPtr(bytInput(UBound(bytInput))), _
VarPtr(AsmCrc), _
Init
End Function

Private Sub
Command1_Click()
Dim myBAry() As Byte
Dim
myL As Long

myBAry = StrConv(Text1.Text, vbFromUnicode)

myL = AsmCrc(myBAry, Len(Text1.Text))
Text2.Text =
"字符串「" & Text1.Text & "」的CRC校驗:" & myLEnd Sub

留言

本月最夯

偷用電腦,怎知?事件檢視器全記錄!(開機時間、啟動項時間...)