COM_connectRunningServer_()

Synopsis

Connects to the running COM server. If the COM server is running, and is acquired, then its IDispatch is returned. If the call succeeds, the object reference count of the COM server is incremented.

This is equivalent to the VB GetObject() call.

Syntax

COM_connectRunningServer_ ( serverName As String, _
                             Optional reuseID As String = "", _
                             Optional onExitProperty As String = "", _
                             Optional autoRelease? As Boolean = True ) As User
Argument Type Description
serverName String ProgID string . Examples of some ProgIDs are: "Excel.Application" "Inventor.Application" Please see the relevant documentation on the COM model for your specific COM server.
reuseID String Optional; obsolete; default is "".
onExitProperty String Optional; obsolete; default is "".
autoRelease? Boolean Optional; if True this decrements the server's reference count when the COM server is released; default is True .

Example 1

Connects to running Inventor and retrieves the version string:
Method getInventorVersion() As String 
    Dim inventor As User = COM_connectRunningServer_("Inventor.Application") 
    Dim softwareVersion As User = COM_getProperty_( inventor, "SoftwareVersion") 
    Dim displayName As String = COM_getProperty_( softwareVersion, "DisplayName") 
    COM_releaseDispatch_( inventor) 
    Return displayName 
End Method
Output:
--> "2009 (Build 130236001, 236)"