Access violation error using smart pointer stored in GIT
- From: "Alex" <korygin@xxxxxxx>
- Date: 30 Aug 2005 09:25:01 -0700
Hello,
I am getting the access violation error while trying to access a smart
pointer stored in GIT. I have a simple configuration class, that
registers a pointer in Global Interface Table in the constructor as
follow:
CConfig::CConfig()
{
// COM smart interface pointer
_CommunicationPtr pConfig;
HRESULT hRes = pConfig.CreateInstance(__uuidof(Communication));
_ASSERT(SUCCEEDED(hRes));
_id = pConfig.GetIID();
// create Global Interface Table(GIT)
hRes = CoCreateInstance(CLSID_StdGlobalInterfaceTable,
NULL,
CLSCTX_INPROC_SERVER,
IID_IGlobalInterfaceTable, (LPVOID*)&_pGIT);
_ASSERT(SUCCEEDED(hRes) && _pGIT);
// store interface in GIT
hRes = _pGIT->RegisterInterfaceInGlobal(
pConfig.GetInterfacePtr(),
_id,
&_gdwCookie);
_ASSERT(SUCCEEDED(hRes));
pConfig = NULL;
}
When in the method I retreive this pointer from GIT and try to use it.
That is where I am getting "Access violation" error.
char *CConfig::CustomerID(void)
{
CoInitialize(NULL);
// COM smart interface pointer
_CommunicationPtr *pConfig = NULL;
// get proxy to interface from GIT
HRESULT hRes = _pGIT->GetInterfaceFromGlobal(_gdwCookie,
_id,
(LPVOID*)&pConfig);
_ASSERT(SUCCEEDED(hRes) && pConfig);
char* value = NULL;
// THIS IS WHERE ERROR OCCURS
value = (*pConfig)->CustomerID;
pConfig = NULL;
CoUninitialize();
return value;
}
Please advice.
Thanks in advance,
Alex.
.
- Follow-Ups:
- Re: Access violation error using smart pointer stored in GIT
- From: Alexander Nickolov
- Re: Access violation error using smart pointer stored in GIT
- From: Kim Gräsman
- Re: Access violation error using smart pointer stored in GIT
- Prev by Date: Re: Multithreading in COM?
- Next by Date: Re: IPersistStreamInit and object persistence
- Previous by thread: Create proxy/stand-in ATL COM server?
- Next by thread: Re: Access violation error using smart pointer stored in GIT
- Index(es):
Relevant Pages
|