×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

help with visual basic and API

help with visual basic and API

help with visual basic and API

(OP)

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.

RE: help with visual basic and API

Use FSO library call.
It is much easier.

RE: help with visual basic and API

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

RE: help with visual basic and API

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources