Its been a while since I posted an SnTT. And so - with two minutes on the clock, here's one of a dozen I'm writing over the next few days..
Ever wanted to compare files to see if they're exactly the same ? Not just same size and same date. But exactly the same. Well. This class might help you:
Private Type MSIFILEHASHINFO
dwFileHashInfoSize As Long
strHashBuffer(0 To 15) As Byte
Declare Function msiGetFileHash Lib "msi.dll" Alias "MsiGetFileHashA" (Byval szFilePath As String, Byval dwOptions As Long, pHash As MSIFILEHASHINFO) As Long
Public Function GetHash(strfile As String) As String
On Error Goto errorhandler
Dim pHash As MSIFILEHASHINFO
pHash.dwFileHashInfoSize = Len(pHash)
Call msiGetFileHash(strfile, 0&, pHash)
Forall CharByte In pHash.strHashBuffer
GetHash = GetHash & Lcase(Hex(CharByte))
Print "getHash: Run time error: " +Error$ + " at line: "+ Cstr(Erl)
So what does his do ? It calls the windows specific DLL call to get a Hash of a file. This makes it a windows-platform specific call. I'm sure there are other mechanisms to handle this on other platforms...
To use it:
' I've waited 23 years to write these lines of code...
Dim Spliff As New Hash
getFileChecksum = Spliff.getHash("c:\program files\lotus\notes\notes.exe")