Click here to Skip to main content
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 20: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 OriginalGriff 341
1 Marcin Kozub 225
2 Sergey Alexandrovich Kryukov 220
3 Praneet Nadkar 197
4 Shweta N Mishra 161
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 28 Jan 2011
Copyright © CodeProject, 1999-2014
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