How getObject Function internally works?

前端 未结 2 492
悲哀的现实
悲哀的现实 2020-12-17 02:41

I\'m Automating Inventor 2013 using UFT as follows:-

Set oApp = GetObject(,\"Inventor.Application\") Set oDoc = oApp.ActiveDocument

Here I

2条回答
  •  死守一世寂寞
    2020-12-17 03:32

    You turn off error checking, attempt a GetObject and then test err.number <> 0. If inventor is running the call will succeed and err.number will be 0, else it will be 424 error (I think).

    The API calls made for each variant of the GetObject are detailed at https://msdn.microsoft.com/en-us/library/windows/desktop/ms221192(v=vs.85).aspx.

    From above link.

    GetObject (filename, ProgID)

    CLSIDFromProgID 
    
    CoCreateInstance 
    
    QueryInterface for IPersistFile interface.
    
    Load on IPersistFile interface.
    
    QueryInterface to get IDispatch interface. 
    

    GetObject (filename)

    CreateBindCtx creates the bind context for the subsequent functions.
    
    MkParseDisplayName returns a moniker handle for BindMoniker.
    
    BindMoniker returns a pointer to the IDispatch interface.
    
    Release on moniker handle.
    
    Release on context.
    

    GetObject (ProgID)

    CLSIDFromProgID 
    
    GetActiveObject on class ID.
    
    QueryInterface to get IDispatch interface. 
    

    You can look up each individual function call here

    https://msdn.microsoft.com/en-us/library/windows/desktop/ms680586(v=vs.85).aspx

    EG

    CLSIDFromProgID function

    Looks up a CLSID in the registry, given a ProgID.

    Syntax

    HRESULT CLSIDFromProgID(
      _In_  LPCOLESTR lpszProgID,
      _Out_ LPCLSID   lpclsid
    );
    

提交回复
热议问题