E
eselk
I've got an out-of-process COM server (EXE) that I want to be able to
control from Visual Basic. I can already control it from a C/C++ app
without any issues. Under VBA in MS Access 2000, which I think is
similar to VB6, I'm able to get things to work, but now under VB 2005
(Visual Studio 2005) I can't get the same to work. Here is what I'm
doing:
1. Because the COM server only registers with the running object
table, but doesn't create class ID and prog ID registry settings (or
anything in the registry) I can use the normal GetObject function to
get the running object because VB wants to translate the class ID by
looking in the registry, and my COM server doesn't even have a class
ID. I just registers with the running object table when it is
running, using an item moniker.
2. So to get around this fact I wrote a simple DLL in C to get the
object from the running object table and return a pointer to the
object. The function is delcared as returning IDispatch* (pointer to
IDispatch).
3. Under MS Access 2000 VBA I'm able to call the DLL like this:
dim app as object
set app = GetApp()
Then I can call whatever IDispatch functions I want on "app". All
works well.
Under VB 2005, I get an error at the GetApp() line saying that a
function cannot return a variant. I don't have the exact error right
now, because I'm actually posting this for a 3rd party, but I'll try
to get it if needed.
Am I going about this the wrong way, is there an easier way, maybe one
without using a DLL? I can't change the way the COM server (EXE)
registers itself, or very much else about the server.
control from Visual Basic. I can already control it from a C/C++ app
without any issues. Under VBA in MS Access 2000, which I think is
similar to VB6, I'm able to get things to work, but now under VB 2005
(Visual Studio 2005) I can't get the same to work. Here is what I'm
doing:
1. Because the COM server only registers with the running object
table, but doesn't create class ID and prog ID registry settings (or
anything in the registry) I can use the normal GetObject function to
get the running object because VB wants to translate the class ID by
looking in the registry, and my COM server doesn't even have a class
ID. I just registers with the running object table when it is
running, using an item moniker.
2. So to get around this fact I wrote a simple DLL in C to get the
object from the running object table and return a pointer to the
object. The function is delcared as returning IDispatch* (pointer to
IDispatch).
3. Under MS Access 2000 VBA I'm able to call the DLL like this:
dim app as object
set app = GetApp()
Then I can call whatever IDispatch functions I want on "app". All
works well.
Under VB 2005, I get an error at the GetApp() line saying that a
function cannot return a variant. I don't have the exact error right
now, because I'm actually posting this for a 3rd party, but I'll try
to get it if needed.
Am I going about this the wrong way, is there an easier way, maybe one
without using a DLL? I can't change the way the COM server (EXE)
registers itself, or very much else about the server.