Private Const FILE_ATTRIBUTE_NORMAL As Long = &H80
Private Const GENERIC_READ As Long = &H80000000
Private Const OPEN_EXISTING As Long = 3
Private Declare Function CreateFile Lib "kernel32.dll" Alias "CreateFileA" (ByVal lpFileName As String, _
    ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, _
    ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, _
    ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function GetFileSize Lib "kernel32.dll" (ByVal hFile As Long, ByVal lpFileSizeHigh As Long) As Long
Private Declare Function ReadFile Lib "kernel32.dll" (ByVal hFile As Long, ByRef lpBuffer As Any, _
    ByVal nNumberOfBytesToRead As Long, ByRef lpNumberOfBytesRead As Long, _
    ByVal lpOverlapped As Long) As Long
Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
Private Declare Function CompMemory Lib "ntdll.dll" Alias "RtlCompareMemory" _
(ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long) As Long
Function [COLOR=#ff0000]IsIdenticFiles_API[/COLOR](ByVal f1 As String, ByVal f2 As String) As Boolean
Dim hFile1 As Long, hFile2 As Long, FileSize1 As Long, FileSize2 As Long
Dim m1() As Byte, m2() As Byte, dwBytes As Long
    On Error GoTo end_
    hFile1 = CreateFile(f1, GENERIC_READ, 0, ByVal 0, _
                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
    hFile2 = CreateFile(f2, GENERIC_READ, 0, ByVal 0, _
                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
    If hFile1 = -1 Or hFile2 = -1 Then GoTo end_
    FileSize1 = GetFileSize(hFile1, ByVal 0)
    FileSize2 = GetFileSize(hFile2, ByVal 0)
    If FileSize1 <> FileSize2 Then
        IsIdenticFiles_API = False
    Else
        ReDim m1(0 To FileSize1 - 1)
        ReDim m2(0 To FileSize2 - 1)
        ReadFile hFile1, m1(0), FileSize1, dwBytes, ByVal 0
        ReadFile hFile2, m2(0), FileSize2, dwBytes, ByVal 0
        IsIdenticFiles_API = CompMemory(m1(0), m2(0), FileSize1) = FileSize1
    End If
end_:
    CloseHandle hFile1
    CloseHandle hFile2
End Function