Click here to Skip to main content
11,642,855 members (71,345 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ATL COM COM+
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 27-Jan-11 19:38pm
Comments
SAKryukov at 28-Jan-11 1:42am
   
Show you code.
Ganesamoorthy.S at 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 at 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.
SAKryukov at 28-Jan-11 12:04pm
   
What a relief! Thank you for the note. :-)
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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. Poke tongue | ;-P
  Permalink  

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

  Print Answers RSS
0 DamithSL 328
1 OriginalGriff 280
2 Sergey Alexandrovich Kryukov 270
3 Afzaal Ahmad Zeeshan 195
4 jyo.net 190
0 DamithSL 541
1 OriginalGriff 495
2 Mika Wendelius 469
3 Sergey Alexandrovich Kryukov 330
4 Afzaal Ahmad Zeeshan 324


Advertise | Privacy | Mobile
Web03 | 2.8.150731.1 | Last Updated 28 Jan 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100