Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing VB object reference to COM

Status
Not open for further replies.

wglass

Programmer
Dec 3, 2001
1
US
Hi,

I have a COM object that generates an object for a VB app, which stores it and then passes it back to the COM object for further manipulation. I can generate it fine, but can't figure out how to pass a VB "object" back to COM. Specifically I keep getting Access Violations when I call QueryInterface.

VB CODE:
Code:
Set obj = Engine.getObject    ' works fine
EngineFactory.saveObject obj  ' doesn't work

Engine.getObject returns a VT_DISPATCH pointer to a custom IForioObject.

C++ CODE:
Code:
STDMETHODIMP CEngine::saveObject(BSTR *PathName, IDispatch *Model, VARIANT_BOOL *ReturnVal)

IForioObject *ForioObj;
HRESULT hr = Model->QueryInterface(IID_IForioObject, (void**)&ForioObj);

On this last line, my C code always crashes with a access violation. It appears that the VB code is not passing in the original object.

Any ideas out there? Help is appreciated.

Best, WILL

 
EngineFactory object should support the object being passed for further processing, i.e your QueryInterface is not returning a valid reference back.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top