![]() |
help with visual basic and API
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. 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.
Code:
Type FILETIMEHelp would be great from anyone. |
Quote:
can you be a bit more specific, what does happen when you try to run this code? There is a hell lot of what you can do wrong when calling a dll from vb, and the calling method highly differs depending on how the dll export was defined. Besides that you declared GetFileSize and GetFileTime but the way you call does not nearly match their declaration and you will also need these api's if you want to complete your task: Code:
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As LongGreetnx The Mad Guy |
You really should take a look at the documentation for the API's you're using :D
If you check GetFileSize on MSDN (hxxp://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/getfilesize.asp), you'll see it takes two arguments: - hFile, a handle to a file that should be obtained from CreateFile - a pointer to the high-order dword of the size It will return the low-order dword with the size, or an error code. The way you're using: Quote:
But you're passing it a String!!! You should pass a handle from CreateFile, and a 2nd Long variable, to receive the high-order dword. For GetFileTime you have a similar problem, you need to check the API docs to see you must pass the 3 structures to get the 3 filetimes, and not use the function return value as you currently do. For this function, the return value merely indicates if it succeeded or not. Finally, don't forget to "CloseHandle" after you don't need it any more, as is probably explained in the "CreateFile" docs. |
i have a DLL created with Delphi,
Code:
procedure MyProc(MyPtr: pointer);Code:
Private Declare Sub MyProc Lib "mylib.dll" (MyPtr as ???) |
You can declare: (ByVal MyPtr As Long)
|
And depending on what you pass from vb you might need to use VarPtr or StrPtr for passing your argument to your .dll then.
Greetnx The Mad Guy |
| All times are GMT +8. The time now is 16:25. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX