Re: FindConnectionPoints returns invalid access to memory location
- From: "Alexander Nickolov" <agnickolov@xxxxxxxx>
- Date: Fri, 16 Nov 2007 12:49:41 -0800
Is there marshaling support for IOPCShutdown? What is the returned
HRESULT from the failed FindConnectionPoint?
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"BIllyBob10000" <BIllyBob10000@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:28D05D10-7BB3-4405-94D5-D7637DD9B5D6@xxxxxxxxxxxxxxxx
Here is the client side
it will crash here (if I don't check for NULL) cause pConnPt is returned
null
if (pConnPt != NULL) pConnPt->Release();
please excuse the lack of error checking - quick test program - server is
the work
int main(int argc, char* argv[])
{
HRESULT hr;
LPWSTR sz;
CoInitialize(NULL); // Init COM.
// Here are the interfaces I want.
MULTI_QI qi[2] = {0};
qi[0].pIID = &IID_IOPCCommon;
qi[1].pIID = &IID_IConnectionPointContainer;
// Create the Server.
hr = CoCreateInstanceEx(CLSID_CoOPCServer, NULL,
CLSCTX_LOCAL_SERVER, NULL, 2, qi);
// Assign interface pointers to fetched results.
IOPCCommon *pOPCCommon = (IOPCCommon*)qi[0].pItf;
IConnectionPointContainer *pConnPtCtnr =
(IConnectionPointContainer*)qi[1].pItf;
// Find the connection point.
IConnectionPoint *pConnPt = NULL;
hr = pConnPtCtnr->FindConnectionPoint(IID_IOPCShutdown, &pConnPt);
sz = L"AISOPCClient (AIS Test Client)";
pOPCCommon->SetClientName(sz);
pOPCCommon->GetErrorString(S_OK, &sz);
showError(sz);
CoTaskMemFree(sz); // Free the server memory
if (pConnPt != NULL) pConnPt->Release();
pConnPtCtnr->Release();
pOPCCommon->Release();
CoUninitialize(); // Terminate COM.
return 0;
}
Ths is snipped out of server.
STDMETHODIMP CoOPCServer::FindConnectionPoint(REFIID riid,
IConnectionPoint
**ppCP)
{
// Which CP do you want?
if(riid == IID_IOPCShutdown)
{
*ppCP = m_pConnPt;
}
else
{
*ppCP = NULL;
return E_FAIL;
}
(*ppCP)->AddRef();
return S_OK;
}
class CoOPCServer : public IOPCCommon, public IConnectionPointContainer
{
public:
CoOPCServer();
virtual ~CoOPCServer();
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid, void** pIFace);
STDMETHODIMP_(DWORD)AddRef();
STDMETHODIMP_(DWORD)Release();
// IConnectionPointContainer
STDMETHODIMP EnumConnectionPoints(IEnumConnectionPoints **ppEnum);
STDMETHODIMP FindConnectionPoint(REFIID riid, IConnectionPoint **ppCP);
// IOPCCommon
STDMETHODIMP SetClientName(LPCWSTR sz);
STDMETHODIMP GetErrorString(HRESULT dwError, LPWSTR *psz);
// Helpers
void CreateConnPt();
private:
DWORD m_dwRefCount;
CConnectionPt *m_pConnPt;
};
"René König" wrote:
Hello!
BIllyBob10000 schrieb:
h = IConnectionPoint* p->FindConnectionPoints(IID, &pp)
First of all, IConnectionPoint does not provide a method
FindConnectionPoints, so I think you mean IConnectionPointContainer and
FindConnectionPoint instead.
The problem is most likely related to your second parameter, pp. So what
is it and where does it come from? Does 'pp' mean '**'? If so, this
should work:
HRESULT hr = p->FindConnectionPoint(IID, pp);
Rene
.
- Follow-Ups:
- Re: FindConnectionPoints returns invalid access to memory location
- From: BIllyBob10000
- Re: FindConnectionPoints returns invalid access to memory location
- References:
- Re: FindConnectionPoints returns invalid access to memory location
- From: René König
- Re: FindConnectionPoints returns invalid access to memory location
- From: BIllyBob10000
- Re: FindConnectionPoints returns invalid access to memory location
- Prev by Date: Re: FindConnectionPoints returns invalid access to memory location
- Next by Date: Re: Data delivery to ActiveX controls hosted by Internet Explorer
- Previous by thread: Re: FindConnectionPoints returns invalid access to memory location
- Next by thread: Re: FindConnectionPoints returns invalid access to memory location
- Index(es):
Relevant Pages
|
Loading