How To Remove An Instance of Access From the Running Objects Table

  • Thread starter Thread starter Stewart Berman
  • Start date Start date
S

Stewart Berman

We want to prevent another application from using GetObject to connect to
the instance of Access that our application is running it.

It is my understanding that it should be possible to do that by calling
RevokeActiveObject. The problem that I have is that RevokeActiveObject
requires the handle that was returned by the original call to
RegisterActiveObject.

Now the documentation for GetCurrentProcess says it will return a psuedo
handle for the current process that can be used anywhere a real handle is
needed. However, using the value returned by GetCurrentProcess as input to
RevokeActiveObject does not work.

How do I get the correct handle to call RevokeActiveObject with?

Or is there some other way to remove an instance of Access from the Running
Objects Table?
 
You can call DuplicateHandle to create a real handle. But I am afraid that
it may not be same as the handle required in RevokeActiveObject. As far as
I know, this handle can be only retrieved from the
RegisterActiveObject.However since Office Excel, Word and Access are single
use (multiple instances) servers and that they automatically register their
instances in ROT, you could not retrieve the object handle in your
application. Though you can iterate ROT
(http://support.microsoft.com/kb/190985/EN-US/), there is no interface that
can help retrieve the handle.

If you do not want other process to read/write your Access file, I think
that you can use OPENFILE function to open your file execlusively. More
infomration can be found here,
http://msdn.microsoft.com/en-us/library/aa365430(VS.85).aspx.

Best regards,
Charles Wang
 
You can call DuplicateHandle to create a real handle. But I am afraid that
it may not be same as the handle required in RevokeActiveObject. As far as
I know, this handle can be only retrieved from the
RegisterActiveObject.However since Office Excel, Word and Access are single
use (multiple instances) servers and that they automatically register their
instances in ROT, you could not retrieve the object handle in your
application. Though you can iterate ROT
(http://support.microsoft.com/kb/190985/EN-US/), there is no interface that
can help retrieve the handle.

If you do not want other process to read/write your Access file, I think
that you can use OPENFILE function to open your file execlusively. More
infomration can be found here,
http://msdn.microsoft.com/en-us/library/aa365430(VS.85).aspx.

Best regards,
Charles Wang


You can call DuplicateHandle to create a real handle. But I am afraid that
it may not be same as the handle required in RevokeActiveObject.

I've already tried that and it isn't.
If you do not want other process to read/write your Access file, I think
that you can use OPENFILE function to open your file execlusively.

The problem is not another process opening the Access file. The problem is
another process using the instance of Access that has the database open.
 
Hey--I am facing the same issue.I would like to remove an existing entry for
excel from the ROT but cannot get dwRegister value to revoke.
Did you find any solution for that ?

There was just some discussion on the ROT in the
m.p.vb.general.discussion newsgroup. Those folks had a reasonable
clue about the ROT. Whereas I'd never heard about it before. So I'd
suggest asking in there for some assistance.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
 
Back
Top