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!

Trying to get an IConnectionPoint pointer

Status
Not open for further replies.

Prattaratt

Technical User
Aug 6, 2000
291
US
I've been working with Borland C++ Builder 5.0 on a TAPI project. Right now I'm trying to figure out the event registration system. I've been able to get a valid (I think it's valid, anyway) IConnectionPointContainer pointer from my CoClass object, but when I use it to try and get an IConnectionPoint pointer, it fails with a E_POINTER error.
Question 1: Do I need to provide the IConnectionPointContainer->FindConnectionPoint function a pointer to an already initialized IConnectionPoint Object?
Question 2: If the answer to question 1 is yes, I'm not real clear on how to Init said pointer, so How to do so?

Here's the code Snippet:

void __fastcall RegTAPIEvents()
{
IConnectionPointContainer * pCPC;
IConnectionPoint * pCP;
IUnknown * pUnk;
HRESULT hr;
// Get the connection point container interface pointer from the TAPI object.
// This works
hr = Form1->MyTAPI1->QueryInterface(
IID_IConnectionPointContainer,
(void **)&pCPC
);
// Get the ITTAPIEventNotification interface pointer from the container.
// this fails with E_POINTER
hr = pCPC->FindConnectionPoint(
IID_ITTAPIEventNotification,
&pCP
);
pCPC->Release();
};
 
Prattaratt,

Doesnt look like anything is wrong with your code. I would make sure that the TAPI is correctly installed and initialised in the application using the Initialize() function.

 
Just to bring evryone up to date, I managed to solve the problem. Here's my solution (I'm using BCB 5.0, BTW):

(void*)pCPC = malloc(100);
//not exactly sure on size of interface object, make it 100 bytes to be safe.
unsigned char *tmp = (byte *)pCPC;
for (int i =0;i<99;i++)
{
*tmp=0;
tmp++;
};
//zero out memory space
HRESULT hr;
// Get the connection point container interface pointer from the TAPI object. TAPI1 is of type TTAPI, imported from TAPI Type libray. Key to solution is in red
hr = TAPI1->GetDefaultInterface()->[/color red]QueryInterface(
IID_IConnectionPointContainer,
(void**)&pCPC);
// If ( hr != S_OK O) process the error here.

// Get the ITTAPIEventNotification interface
// pointer from the container.
hr = pCPC->FindConnectionPoint(
IID_ITTAPIEventNotification,
&pCP
);
// If ( hr != S_OK O) process the error here.

pCPC->Release();
free(pCPC);

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top