evenstar
Computer
- Jul 16, 2002
- 1
I'm creating a program through VB 6 that monitors file access (aka if someone's been messing with your stuff). Basically it involves choosing the files to be monitored, obtaining properties such as file size, last modified, last accessed, etc. and running that information through the md5 algorithm to create a default hash. The properties will be hashed every x minutes and compared to the default hashes, and if any differences occur a message box/email/phone message will be sent to the computer's administrator. I tried to use API calls but I'm lost because I'm a complete beginner. This is my first real VB program anyway. Here is what I have so far. It seems I can't run those calls even though I put in the code...its really frustrating.
Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Public Declare Function GetFileSize Lib "kernel32.dll" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Public Declare Function GetFileTime Lib "kernel32.dll" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
Private Declare Function MakeMD5Digest _
Lib "di_MD5DLL.dll" _
(ByVal sData As String, ByVal sDigest As String) As Long
Public Function MD5HexDigest(sData As String) As String
Dim iRet As Long
Dim sDigest As String
' Set sDigest to be 32 chars
sDigest = String(32, " "
iRet = MakeMD5Digest(sData, sDigest)
MD5HexDigest = Trim(sDigest)
End Function
Private Sub cmdRun_Click()
Dim FileInfo As String
Dim StandardComp As String
Dim Size As String
Dim lastacc As String
Size = GetFileSize(txtFolder.Text)
lastacc = GetFileTime(txtFolder.Text)
FileInfo = Size + lastacc
StandardComp = MD5HexDigest(FileInfo)
End Sub
Private Sub Command1_Click()
listFolders.AddItem txtFolder.Text
End Sub
'thats just to add file names to a list box.
I just want to make the md5 compare itself to StandardComp every x minutes and alert if they arent equal.
Help would be great from anyone.