How can I add a function to COM?
-
I am a learner and I ve got a COM. I try to learn the structure of the COM, and then did three steps to add a function to the COM and its Interface: 1. In DECLARE_INTERFACE_(ITest4, IUnknown), I added a fuction like this: STDMETHOD(ChangeTest) (THIS_ int nToBeChanged ) PURE; 2. In the CTest4 declaration I added: STDMETHODIMP ChangeTest(int nToBeChanged); 3. In the CTest implement I appended : HRESULT CNvRender::ChangeTest(int nToBeChanged) { m_nChangeNo = nToBeChanged; ::MessageBox(NULL, "fasdf", "hehe",MB_OK); return 0; } 4. register it and get the interface pointer in my file: ITest4 *p; ......(get the pointer p and check it whether it is valid) p->ChangeTest(2); and here the problem arise: Access Violation What's wrong with it ? I need your help.