Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with visual basic and API

Status
Not open for further replies.

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.

 
Replies continue below

Recommended for you

Use FSO library call.
It is much easier.
 
Place (Declare) the API calls in a Module and call them from your main program.

If this is not your problem give me a shout and I'll try to help.

Regards
Derrick
 
Hello,

You can use operating system signalling which is available in newer (maybe older too) version Windowses (a.ka XP, W2K, W3K) to monitor file access.

Search from msdn by using keyword FileChangeNotification

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor