内嵌汇编的这个CRC32代码应该很多人都用过吧,也是不可多得的经典。
下面这个是做了小小修改后的,贴之...
Option Explicit
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
Public Function CRC32(Data() As Byte) As Long
Dim Asm(5) As Long, Init As Long
Asm(0) = &H5B5A5958
Asm(1) = &HC033505E
Asm(2) = &H3018A36
Asm(3) = &H41CED1F0
Asm(4) = &HF47ECA3B
Asm(5) = &HC3338936
On Error GoTo Err
Init = UBound(Data) - LBound(Data) + 1
CallWindowProc VarPtr(Asm(0)), VarPtr(Data(LBound(Data))), VarPtr(Data(UBound(Data))), VarPtr(CRC32), Init
Err:
End Function
阅读(477) | 评论(0) | 转发(0) |