We have had success using the NetFileClose API. This has the effect
of unlocking the file. But it doesn't tell you if the MDB is in use.
We have a time window and anybody on after that time window can be
disconnected from the MDB at any time.
We have only run it when the mdb is on a server (w2000 but the docs
say it will work on an NT server) and the account running the
NetFileClose is an "operator" on the server.
Notice that the API expects a Unicode string for the servername so the
normal call of (byval str as string) did not work for us.
Public Declare Function NetFileClose lib "netapi32.dll" _
(bvay lpstr as long, byval dword as long) as long
We call it this way
lngreturned = NetFileClose(StrPtr(filename),fileId)
Now the fileid must be obtained from NetFileEenum API and that is not
for the faint of heart.
Before I try to post some code ( I'll have to trim it some since we
have some misc debugging code in here)... Is this something that you
want to get into? I don't know of any other way to kick users out of
a file.
In order to check on whether or not users are really using the MDB
file, I guess you would have to watch the file and check to see if it
was modified in the past X minutes (or set up a FileSystemWatcher
rahter than use the API calls) !!
You can not disconnect the users. They have to close the file.
bceggersATcomcastDOTnet