Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have created a COM DLL Server Project and accessed it by creating a clinet having CoCreateInstance().

Then i have modified the COM server project by adding one more interface.

In order to obtain the object for the second interface, i have called the QueryInterface function.

But QueryInterface always returns "E_NOINTERFACE".

What is the mistake i am making, please clarify.

What are the points we need to keep in mind while creating the second interface?

Kindly Advise.

Thanks,
Ganesamoorthy
Posted
Comments
Sergey Alexandrovich Kryukov 28-Jan-11 1:42am    
Show you code.
Ganesamoorthy.S 28-Jan-11 2:20am    
<pre>HRESULT hr;
IGreet *greetObject;
IGreet2 *greetObject2;
CString strTemp;
hr = CoInitialize(NULL);
if (FAILED(hr) )
return ;
hr = CoCreateInstance(CLSID_Greet,NULL,CLSCTX_INPROC_SERVER, IID_IGreet,(void **)&greetObject);
if (FAILED(hr) )
{
CoUninitialize();
return ;
}
cout << greetObject->Sayhello("Ganesh") << endl;

hr = greetObject->QueryInterface(IID_IGreet2,(void **)&greetObject2);
if (FAILED(hr) )
{
CoUninitialize();
return ;
} </pre>
Ganesamoorthy.S 28-Jan-11 7:00am    
Accept Answer Reject Answer
.I have completed this on my own.

Adding interface to a COM, is as usual but if we suppose to use QUERYINTERFACE then it has to be implemented(implement interface option must be chosen).

I did it and got the expected result.
Sergey Alexandrovich Kryukov 28-Jan-11 12:04pm    
What a relief! Thank you for the note. :-)
--SA

I have completed this on my own.

Adding interface to a COM, is as usual but if we suppose to use QUERYINTERFACE then it has to be implemented.

I did it and got the expected result.
 
Share this answer
 
Have you updated the .idl file?
If not then update it.

Use the midl tool to compile your .idl file.
Add the changed files (stub and client) in your project.

Then use your COM object.
Hope this have helped you. ;P
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900