|
If I try and create an interface called IInternet as part of my COM server, I get the following compiler error:
Error C2440: 'static_cast' : cannot convert from 'class CInternet *' to 'struct IDispatch *' - Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
I guess this means I can't just use any name I please for an interface - and I thought only IUnknown wasn't to be used!
Is there some way round this and is there also a definitive list of what interface names would cause a clash?
Thanks.
|
|
|
|
|
Heh, bad luck . There is no such a list of "Interface names you cannot use". For the system the name is actually represented by the IID - some big ugly number. For the system itself is no problem to have ten or whatever number of IInternet interfaces, as long as they will have different IID .(see OLE/COM object viewer, in the tree is a branch Interfaces, I'm sure you'll find here some duplicate interface names, but not IIDs).
Problem what you have, is in your compiler - because one IInternet is included in header urlmon.h (this is included through ATL as well as through MFC headers) and one is in header generated from your IDL file. Then, your compiler have 2 different IInternet definitions. But he doesn't care about some IID , for him it is simply the collision, but it is the same collision as having say two base classes with the same name.
Solution - you can simply rename your IInternet to something else, or you have to avoid the urlmon header. For this Microsoft guys use #define __urlmon_h__ . But don't know the dependencies in your code, so cannot say if the second option will work.
Maybe after some elaboration, there will be some possibility to place the names to different namespaces. But I am normally not using the namespace thingie, so I cannot help you here much.
Hope this helps
|
|
|
|
|
Hi, thanks for the reply
I totally see that now. Sure enough, it is clashing with IInternet declared in urlmon.h. Trouble is, in my COM server which is going to be providing internet services, it will definitely have to use the IInterent services (wrapping some of them up I suppose). I guess I'll just have to use a more specific name as you suggest.
Interestingly, I was led down the wrong path by the error I reported above. I tried creating another COM server with an interface defined in it called "IModule" and got the same error. I then wondered if there's an IModule interface declared in some header like IInterface, but I haven't found one. I then wondered if it's because I'd created another COM server with an IModule interface but as you correctly point out (and as I also believed) the system differentiates by CLSID (and IID) not interface name. Anyway, I then tried creating three COM servers as Effect objects (from my other post above) and defined a "IMyEffect" interface on each. The first one built with no problems but when I was building the second one, I got a dialog box saying that it was already defined in the registry and did I want to use the existing CLSID or not. I replied no of course. I thought then that yes, the system was aware of interface names and not just IIDs then! Stranger still was that when I repeated the creation of yet another effect COM server and created another ATL object declaring the same interface "IMyEffect" I didn't get a repeat of the message asking if I wanted to use the existing CLSID! Hope you followed all that!
The namespace idea is interesting, I'll follow this up, thanks.
|
|
|
|
|
I guess you probably have the same IID for the interfaces here. But why the compiler did not ask for the second time, I have no idea.
But anyway it made me unsure a bit so I duplicate a interface name I have surely registered from some of my older projects and create a new project containing that interface name, but with different IID and compiler had no complains. In OLE/COM view I saw both are registered...
So I think you simply copied the interface definitions, including the uuid . But when this number is equal, for the system the interfaces are equal too.
Maybe would be helpfull to state, that the interface is a independent on the CLSID - the system have no link between them. Then the comparing is not based on CLSID/IID comparsion, but only on the IID!
For the solution for your problem, I think my previous reply below (above?) will help you...
|
|
|
|
|
Dear Erik...
I have seen yout article abt plugging the controls in IE toolbar.
In that I have some doubt.Because I'm new to VC++ development concern.
My first task is to create an Active X control(like one listbox and image) and I plug in to I.E 5.5 tool bar with out using the ATL COM APPWizard.
U have given this link...
http://www.codeproject.com/atl/ietoolbartutorial.asp
It asks to install
1)RBDeskBand ATL object Wizard(version 2.0)
2)CWindowImplATL Object Wizard.
Really I don't know what are these two things.If I install the CWindowTempATL Object Wizard,it shows the message like that service is already available.
After that I searched and I found in the Visual Studio .NET folder.What to do now?.
And anotherone is In my Insert menu,New ATL wizard is not enabiling.
But my superior told me that Without installing these,I need to create..Could you help me?.I should finish within TWO DAYS.my mail id(if possible send to here also) : vcarivu@indiatimes.com
After all tries,I have hope only with our peoples in this site....Otherwise I can't survive here..
If this mail disturbs you,please forgive me...
If you wish ,give me your id also.I'm in very bad and critical situation without any help.
Thanks for viewing this.Please help me.
Bye,
Arivu
|
|
|
|
|
hi all,
I'm new to VC++ development company.I need to create an Active X control(like one listbox and image) and I plug in to I.E 5.5 tool bar with out using the ATL COM APPWizard.After searching in our website ,they gave the link
http://www.codeproject.com/atl/ietoolbartutorial.asp
It asks to install
1)RBDeskBand ATL object Wizard(version 2.0)
2)CWindowImplATL Object Wizard.
Without installing these,I need to create..Please send me the steps quickly.
I should finish within TWO DAYS.my mail id(if possible send to here also) : vcarivu@indiatimes.com
After all tries,I have hope only with our peoples in this site....Otherwise I can't survive here..
Expecting u're replies..
Thanks for viewing this.Please help me.
Everfriendly,
Arivu
|
|
|
|
|
I am confuse... can anyone tell me is OLE object also is called COM????
And does anyone know how to create OLE object in Visual C++??? thanks!!!
|
|
|
|
|
These are the Microsoft's naming standards :P. In general way, as it is understand now, I can say, yes, OLE object = COM.
What is correct I guess is:
COM = Component Object Model - some general way how to write modules and comunicate between them, even if they are written in different language.
OLE = Object Linking and Embedding - some features, founded I guess in times of old plain Win 3.1(?). This was intended for Word & other Microsoft products to embedd or link e.g. Excel table to the say Word document. On 32bit OS the COM was introduced, so since then the OLE uses COM as an underlying technology.
|
|
|
|
|
Does anyone know if its safe to have a map of _variant_t like the one below?
std::map<DWORD, _variant_t> VAPMAP;
Thanks.
|
|
|
|
|
I believe it is safe. I used it in few projects here around and I had no problem with.
|
|
|
|
|
Hello,
I have an ATL COM Server with one dual interface. I can instantiate
the interface via Javascript, VBScript, no problem. If one
instance of the interface exists, it registers into the ROT (Running Object Table). So far I could not figure out if I am doing the registration wrong
or my Javascript knowledge is too small to get my hands on the already running
interface via the ROT in JScript oder VBScript.
<br />
Var server;<br />
<br />
server = WScript.GetObject("","COMTest.Application");<br />
It always instantiates a new interface leading to two ROT entries!
The only method I know is:
<br />
Var server;<br />
<br />
server = WScript.GetObject(,"COMTest.Application");<br />
But this gives syntax error, but may work in Visual Basic (not script).
Which always useses the existing instance of the interface.
Any suggestions ?
Yours,
Alois Kraus
|
|
|
|
|
Hi,
I want to delete all the bvs and exe files as the come into exchanger server and before user can get those emails. How can i do that?
This is urgent and response will be very much appreciated.
Thank you!
Ammad
We learn by sharing knowledge
Ammad
|
|
|
|
|
sorry this is COM section....
u want to send mail when u click some button/something?
http://www.codeproject.com/staticctrl/CMyHyperLink.asp
~~~~Code the Dreams~~~~~
|
|
|
|
|
Please don't cross-post (post in multible forums), it makes people kinda mad, and then you don't get any answers.
BTW, I did answer your question in the ATL/WTL forum.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I design a COM object by ATL, which has two IDispath. Default dispatch is IPlot2D, and the second is IMIDraw.
IMIDraw has a method Plot(), how do I launch Plot() method?
|
|
|
|
|
Define some method of default IPlot2D interface which will return the IMIDraw interface.
<br />
In idl:<br />
[propget] HRESULT DrawManager([out,retval]IMIDraw ** ppDraw)
In C++:<br />
STDMETHODIMP HRESULT CPlot2D::DrawManager(IMIDraw ** ppDraw)<br />
{<br />
return QueryInterface(IID_IMIDraw,(void**)ppDraw);<br />
}
<br />
In VB:<br />
Dim o As Plot2D, o2 As IMIDraw<br />
Set o = CreateObject("PlotLib.Plot2D") ' or = New Plot2D<br />
Set o2 = o.DrawManager<br />
o2.Plot<br />
' Or<br />
o.DrawManager.Plot
<br />
In VBScript:<br />
Dim o, o2<br />
Set o = CreateObject("PlotLib.Plot2D")<br />
Set o2 = o.DrawManager <br />
o2.Plot<br />
' Or<br />
o.DrawManager.Plot
With best wishes,
Vita
|
|
|
|
|
You can't have 2 IDispatch interface on one COM object.
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
QueryInterface
~~~~Code the Dreams~~~~~
|
|
|
|
|
As the title, how can I perform that with programmatically?
My Com+ plus is inherited from ServicedComponent and implements
an interface(dual) defining by myself. Thanks ahead!
|
|
|
|
|
You can do it either by hand ( open Component Sevices console, etc) or programatically , using COMAdminCatalog component.
|
|
|
|
|
I know some of COMAdminCatalog, but i have no idea of those properties which are the correct ones to set. I set RemoteServerName and it really be set on the Com+ database but does not effect somewhat.
|
|
|
|
|
I have never ever worked with a SafeArray, and I have a few problems using it
I have this line in my code:
SAFEARRAY *sa = kvset->GetKVSetArray(L"results");
where kvset is a COM Object.
My problem is that I know that the SafeArray sa contains IDispatch* interfaces.
But I cannot get a interface, and make a successfull QueryInterface on it...
Anuone have a couple of lines of code that does the trick?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
If that's a IDispatch*, then you might just as well end up with an Invoke method call. At least, that's what the IDispatch interface is for.
|
|
|
|
|
But how... Please...
Sorry to ask, but I have used the last 6 hours trying to get this stuff to work, and right now my brain has almost stopped working
This is the first time I have ever worked with a SafeArray, and it really baffles me
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
if anyone is interested, this did the trick
SAFEARRAY *pSafeArray = kvset->GetKVSetArray(L"results");
IDispatch** pIDispatch;
SafeArrayAccessData(pSafeArray, (void**)&pIDispatch);
IKVSet *test;
pIDispatch[0]->QueryInterface(__uuidof(IKVSet), (void**)&test);
SafeArrayUnaccessData(pSafeArray);
test->Release();
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|