WoodyJ007
asked on
Automation Object Connection
Hi Guys,
Can VB connect to a running instance of an automation object registered with RegisterActiveObject.
Here is some delphi code that I wrote that does what I want. I need to convert this to VB but most of the calls are not supported. I know about GetObject but that creates an instance instead of connects to a running one.
Many Thanks
Woody.
Delphi Code
-----------
GetActiveObject(Class_Debu ggerPro, Nil, AttachDebuggerProUnknown);
If Assigned(AttachDebuggerPro Unknown) Then
Begin
AttachDebuggerProUnknown.Q ueryInterf ace(IDebug gerPro, AttachDebuggerPro);
If Assigned(AttachDebuggerPro ) Then
Begin
AttachDebuggerPro.DoSomeMe thod;
End;
End;
Can VB connect to a running instance of an automation object registered with RegisterActiveObject.
Here is some delphi code that I wrote that does what I want. I need to convert this to VB but most of the calls are not supported. I know about GetObject but that creates an instance instead of connects to a running one.
Many Thanks
Woody.
Delphi Code
-----------
GetActiveObject(Class_Debu
If Assigned(AttachDebuggerPro
Begin
AttachDebuggerProUnknown.Q
If Assigned(AttachDebuggerPro
Begin
AttachDebuggerPro.DoSomeMe
End;
End;
ASKER
I've tried that before. Calling that function creates a new instance if one is not running.
Dim mydebug As DebuggerPro
Set mydebug = GetObject("", "DebuggerX.DebuggerPro")
I need to connect to an running instance. If one is not running then do nothing.
Cheers
Woody.
Dim mydebug As DebuggerPro
Set mydebug = GetObject("", "DebuggerX.DebuggerPro")
I need to connect to an running instance. If one is not running then do nothing.
Cheers
Woody.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, how sdm295 means you can use the GetObject function to
receive a running automation instance:
There are to possibilities:
1) Late binding:
Dim MyObject As Object
Set MyObject = GetObject([pathname] [, class])
Where:
pathname Optional; String. Full path and name of the file containing the object to retrieve. If pathname is omitted, class is required.
class Optional; String. Class of the object.
The class argument uses the syntax appname.objectype and has these parts:
appname Required; String. Name of the application providing the object.
objectype Required; String. Type or class of object to create.
In your case perhaps:
GetObject("","DebuggerPro. AttachDebu ggerPro")
2) Early binding:
Therefore you must link the your OLE Automation class in
your VB project at the menu item "Project/References ..."
That links the type lib of your Automation server to VB.
And now you find you Class appears after you typed:
"Dim MyObject As"
Now you can write something like this:
Dim MyObject As DebuggerPro.AttachDebugger Pro
Set MyObject = New DebuggerPro.AttachDebugger Pro
or
Set MyObject = GetObject("","DebuggerPro. AttachDebu ggerPro")
Hope this helps
WoK
receive a running automation instance:
There are to possibilities:
1) Late binding:
Dim MyObject As Object
Set MyObject = GetObject([pathname] [, class])
Where:
pathname Optional; String. Full path and name of the file containing the object to retrieve. If pathname is omitted, class is required.
class Optional; String. Class of the object.
The class argument uses the syntax appname.objectype and has these parts:
appname Required; String. Name of the application providing the object.
objectype Required; String. Type or class of object to create.
In your case perhaps:
GetObject("","DebuggerPro.
2) Early binding:
Therefore you must link the your OLE Automation class in
your VB project at the menu item "Project/References ..."
That links the type lib of your Automation server to VB.
And now you find you Class appears after you typed:
"Dim MyObject As"
Now you can write something like this:
Dim MyObject As DebuggerPro.AttachDebugger
Set MyObject = New DebuggerPro.AttachDebugger
or
Set MyObject = GetObject("","DebuggerPro.
Hope this helps
WoK
Yes, how sdm295 means you can use the GetObject function to
receive a running automation instance:
There are to possibilities:
1) Late binding:
Dim MyObject As Object
Set MyObject = GetObject([pathname] [, class])
Where:
pathname Optional; String. Full path and name of the file containing the object to retrieve. If pathname is omitted, class is required.
class Optional; String. Class of the object.
The class argument uses the syntax appname.objectype and has these parts:
appname Required; String. Name of the application providing the object.
objectype Required; String. Type or class of object to create.
In your case perhaps:
GetObject("","DebuggerPro. AttachDebu ggerPro")
2) Early binding:
Therefore you must link the your OLE Automation class in
your VB project at the menu item "Project/References ..."
That links the type lib of your Automation server to VB.
And now you find you Class appears after you typed:
"Dim MyObject As"
Now you can write something like this:
Dim MyObject As DebuggerPro.AttachDebugger Pro
Set MyObject = New DebuggerPro.AttachDebugger Pro
or
Set MyObject = GetObject("","DebuggerPro. AttachDebu ggerPro")
Hope this helps
WoK
receive a running automation instance:
There are to possibilities:
1) Late binding:
Dim MyObject As Object
Set MyObject = GetObject([pathname] [, class])
Where:
pathname Optional; String. Full path and name of the file containing the object to retrieve. If pathname is omitted, class is required.
class Optional; String. Class of the object.
The class argument uses the syntax appname.objectype and has these parts:
appname Required; String. Name of the application providing the object.
objectype Required; String. Type or class of object to create.
In your case perhaps:
GetObject("","DebuggerPro.
2) Early binding:
Therefore you must link the your OLE Automation class in
your VB project at the menu item "Project/References ..."
That links the type lib of your Automation server to VB.
And now you find you Class appears after you typed:
"Dim MyObject As"
Now you can write something like this:
Dim MyObject As DebuggerPro.AttachDebugger
Set MyObject = New DebuggerPro.AttachDebugger
or
Set MyObject = GetObject("","DebuggerPro.
Hope this helps
WoK
ASKER
Ah!! I see. I Didn't know you could just not pass anything in.
Thanks
Woody.
Thanks
Woody.
Here's a bit from MSDN
If pathname is a zero-length string (""), GetObject returns a new object instance of the specified type. If the pathname argument is omitted, GetObject returns a currently active object of the specified type. If no object of the specified type exists, an error occurs.