Need some help converting Delphi interface definitions into C++ for VS 2008
I'm curious if there're any Delphi developers here, and also people who know COM better than I do? Yeah, I know, quite a mix hah
Anyway, my goal is to call a Shell interface described here, which unfortunately is written in Delphi. I need to convert it to run in my Visual Studio 2008 C++/MFC project.
Re: Need some help converting Delphi interface definitions into C++ for VS 2008
Since it is a COM object, can't you already use and call it from any C++ program? Or are you rewritting it because you need to modify its behaviour? You could always do the mods in Delphi, it's nice and easy to learn.
Re: Need some help converting Delphi interface definitions into C++ for VS 2008
I can't remember the details offhand but if you read up about COM in windows/Visual Studio it will have the details. As long as the COM object is registered on the PC you can access it through its interfaces. Perhaps someone else more familiar can provide the details?
Re: Need some help converting Delphi interface definitions into C++ for VS 2008
Originally Posted by moffy
I can't remember the details offhand but if you read up about COM in windows/Visual Studio it will have the details. As long as the COM object is registered on the PC you can access it through its interfaces. Perhaps someone else more familiar can provide the details?
if it's in C++, it doesn't have to be registered, you can access/use non-registered COM objects in C++ easily, other languages typically don't support this at all.
Possible ways to access COM in C++ (from easier to harder):
- For Vc++, the easy way out is to use #import to "load" the COM dll/exe and (hidden) create the appropriate include files for the compiler.
- Creating the class wrappers explicitely with ATL or MFC (or one of the many support libraries that do this as well)
- A bit harder is using the raw COM interfaces for which you'll need a c++ header.
- And of course, if the COM object supports IDispatch, use the "scripting approach" to access the COM interfaces.
Re: Need some help converting Delphi interface definitions into C++ for VS 2008
Originally Posted by Arjay
You can easily create COM wrapper with ATL.
I guess our definition of 'easy' differs somewhat!
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
Re: Need some help converting Delphi interface definitions into C++ for VS 2008
creating an explicit wrapper is just as easy with ATL as it is with MFC (and just as easy as FlexCOM)
USING the wrappers, dpends on the situation
if you already have an MFC project, the MFC wrapper will integrate easier. If you're not already using MFC, then going the MFC route is not advised.
setting up the ATL wrappers takes a bit of pushing and prodding in the project properties.
But it's still easier to do it this way than doign COM with the raw interfaces.
Re: Need some help converting Delphi interface definitions into C++ for VS 2008
Originally Posted by OReubens
If you're not already using MFC, then going the MFC route is not advised.
setting up the ATL wrappers takes a bit of pushing and prodding in the project properties.
It's even easier than that. Just open the new class dialog, select ATL under Visual C++ and choose "Add ATL Support To MFC". That sets up the MFC project for using ATL, then you can import and or create object.s
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.