udfFileChecksumc32 (sFilename, iRequest)
;------------------------------------------------------------------------------------------------------------------------------------------
If ItemLocate("udffilechecksum",IntControl(77,103,0,0,0),@TAB) Then Goto skip_udffilechecksum

#DefineFunction udfFileChecksum (sFilename, iRequest)
If (VersionDLL()<"3.8hch") Then Return ("")
iBBSize = FileSizeEx(sFilename)
If !iBBSize Then Return ("")
iRequest = Min(2,Max(0,iRequest))
hBB = BinaryAlloc(iBBSize)
BinaryRead(hBB,sFilename)
sChecksum = BinaryChecksum(hBB,iRequest)
BinaryFree(hBB)
Return (sChecksum)
;..........................................................................................................................................
;   "iRequest" specifies the type of digest or CRC to generate,
;   and can be one of the following values:
;
;    Request   Meaning      Return string format (x = hex character)
;    -------   ----------   ----------------------------------------
;       0      MD5 digest   "xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx"
;       1      16-bit CRC   "xxxx"
;       2      32-bit CRC   "xxxxxxxx"
;
; Requires WinBatch version 2002h, 3.8hch.
; Returns empty string if input file is not readable or if current WinBatch version is too old.
;..........................................................................................................................................
; Detlev Dalitz.20020825
;..........................................................................................................................................
#EndFunction

:skip_udffilechecksum
;------------------------------------------------------------------------------------------------------------------------------------------



; --- test ---

sFilename = IntControl(1004,0,0,0,0) ; We use this script as input file.

sChecksum1 = udfFileChecksum (sFilename, 0)
sChecksum2 = udfFileChecksum (sFilename, 1)
sChecksum3 = udfFileChecksum (sFilename, 2)

sMsgTitle = "Demo  udfFileChecksum (sFilename, iRequest)"
sMsgText = StrCat("Filename",@TAB,sFilename,@LF,@LF)
sMsgText = StrCat(sMsgText,"MD5"  ,@TAB,sChecksum1,@LF)
sMsgText = StrCat(sMsgText,"CRC16",@TAB,sChecksum2,@LF)
sMsgText = StrCat(sMsgText,"CRC32",@TAB,sChecksum3,@LF)
Pause(sMsgTitle,sMsgText)

:CANCEL
Exit
;------------------------------------------------------------------------------------------------------------------------------------------
;*EOF*