How to using the second IDispatch of a COM object in VBScript
-
I design a COM object by ATL, which has two IDispath. Default dispatch is IPlot2D, and the second is IMIDraw. IMIDraw has a method Plot(), how do I launch Plot() method?
Define some method of default IPlot2D interface which will return the IMIDraw interface.
In idl: [propget] HRESULT DrawManager([out,retval]IMIDraw ** ppDraw)
In C++: STDMETHODIMP HRESULT CPlot2D::DrawManager(/*[out,retval]*/IMIDraw ** ppDraw) { return QueryInterface(IID_IMIDraw,(void**)ppDraw); }
In VB: Dim o As Plot2D, o2 As IMIDraw Set o = CreateObject("PlotLib.Plot2D") ' or = New Plot2D Set o2 = o.**DrawManager** o2.**Plot** ' Or o.**DrawManager.Plot**
In VBScript: Dim o, o2 Set o = CreateObject("PlotLib.Plot2D") Set o2 = o.**DrawManager** o2.**Plot** ' Or o.**DrawManager.Plot**
With best wishes, Vita -
I design a COM object by ATL, which has two IDispath. Default dispatch is IPlot2D, and the second is IMIDraw. IMIDraw has a method Plot(), how do I launch Plot() method?
QueryInterface
~Code the Dreams -
Define some method of default IPlot2D interface which will return the IMIDraw interface.
In idl: [propget] HRESULT DrawManager([out,retval]IMIDraw ** ppDraw)
In C++: STDMETHODIMP HRESULT CPlot2D::DrawManager(/*[out,retval]*/IMIDraw ** ppDraw) { return QueryInterface(IID_IMIDraw,(void**)ppDraw); }
In VB: Dim o As Plot2D, o2 As IMIDraw Set o = CreateObject("PlotLib.Plot2D") ' or = New Plot2D Set o2 = o.**DrawManager** o2.**Plot** ' Or o.**DrawManager.Plot**
In VBScript: Dim o, o2 Set o = CreateObject("PlotLib.Plot2D") Set o2 = o.**DrawManager** o2.**Plot** ' Or o.**DrawManager.Plot**
With best wishes, VitaYou can't have 2 IDispatch interface on one COM object. -- Only in a world this shitty could you even try to say these were innocent people and keep a straight face.