Which is "better": COM DLL or Standard DLL with a Typelib? - dll

I put "better" in quotes because it's a qualitative question. I've been writing COM DLLs for a couple of years now and have only recently come upon, and successfully used, the standard DLL with Typelib concept.
Are there any compelling reasons to use COM DLLs instead of DLL+Typelib? Granted, you can't do DCOM with a DLL+Typelib, but is that the only reason?
EDIT I've written COM DLLs in Visual C/C++ 6, Compaq Visual Fortran, Delphi, Visual BASIC 6, ActiveState Perl and a few others. I've written standard DLLs in Visual C/C++ 6, Delphi, Ada and a few others. I've written typelibs for some of my own standard DLLs and also for third party DLLs. The question was originally written in the context of a Delphi DLL+Typelib reimplementation of a VB6 original.

TypeLib's are also important if you ever wish to migrate COM components to managed code in the future. Or have managed code interact with the COM components.
With a typelib there are lots of tools which will automagically translate your COM signatures into .Net interfaces and types. This can be done by hand but with a large project it's certainly a huge time saver.

It really depends on the clients of the component I would think.

Related

Do COM or CORBA bring forward compatibility of compiler or of standard library?

This question follows the previous one below:
Easy way to guarantee binary compatibility for C++ library, C linkage?
I wondered if making interface functions of C++ DLL or shared library with C linkage brings forward compatibility of Compiler and of standard library.
extern "C" someAPI();
The most voted answer was saying that I am wrong. The answer recommended making it open-source. And never mentioned about COM or CORBA. Making it open-source is not always possible.
But recently I am reading books about Windows COM. And I think COM maybe brings the compatibility I wanted. And there is another thing CORBA.
So I wonder if these things, COM and CORBA, really brings forward compatibity of compiler and standard library?
I think network library ACE uses CORBA. And that is only one I know about CORBA.
Isn't CORBA popular nowadays?
What about COM? ActiveX is maybe disappearing but WDF(Windows Driver Foundation) depends on COM.
Thank you very much!
Yes, COM was created, among other reasons, to overcome source code (and .obj, static lib, etc.) reuse issues, whether that source is C/C++ or anything else.
The essence of COM (v-table layout + IUnknown, forget about registration, OLE, Automation, marshaling, and other additional stuff) is very simple (in fact, it's hard to make it more simple). Since it only relies on binary contracts, you can write COM client and/or server code using any language (and any platform, but in reality, only Windows uses it). So you can have a 32-bit COM client written in python talk to a 64-bit COM server written in C++ for example (well, this example in fact requires some cross process marshaling, so it's not pure lightweight COM).
COM is very far from being dead or disappearing (because it's, again, quite simple). "ActiveX" was a marketing / tech mix name, but it's basically COM, and is massively used in Windows, by Windows and 3rd parties.
COM over the physical network (DCOM) is indeed disappearing (in favor of other technologies, like Web, sockets, HTTP, REST, or in general technologies more simple than COM), and what's still used today is basically in-process and out-process COM (out-process is somehow DCOM on the same machine).
I know that CORBA was once upon a time a strong COM competitor (especially because it was available on multiple platforms, including Windows), but it seems to be seriously declining, also in favor of the same more simple technologies (web, etc.).

Unmanaged language or library to write shell extension?

I need to write a cascading shell extension à la 7Zip. It appears that only the .Net 4 framework supports this, but even in March 2012, MS still advises against using a managed language for this purpose.
So what unmanaged languages are available to write shell extensions for Windows (XP, Vista, 7)?
I read that writing a COM DLL is not easy even for seasoned C++ developpers, so it's probably a dead-end for non-pros. VB6 has been deadware for a decade. I looked at PureBasic and PowerBasic but they don't seem good candidates either.
So is there simply no reasonably easy language to write a cascading shell extension?
As a work-around, is there a library that I could call from VB.Net that would handle the hard part?
Thank you.
There is not a lot you can do if you're not willing to go into the unmanaged world. There is a series of articles on codeproject. This is the first of such articles. They helped me quite a bit. It is written in unmanaged c++ using visual studios ATL project which takes care of some other classes that you would otherwise have to deal with.
COM objects may not be the easiest thing to understand but once they're working they are fairly solid. If anything just treat it as a learning experience.

Use of MFC in a COM server - what are my options?

Visual C++. I have to implement some drawing and printing functionality that will be incorporated into (other developers') COM dll. Firstly I thought of doing everything using pure GDI and nothing more, but it seems that printing and print previewing is hell of a job to be done in GDI compared to the MFC implementation. So I decided to focus on MFC. Quick side question here: Is my choice right? I mean, are any easy ways of implementing printing (and print-preview) without MFC?
Now that I need MFC (assuming if you also agree with this), I have two questions about how to do it:
1) I believe the COM dll is the ATL project (it's not my code, some other developers independently develop it). Can I enable MFC support in that dll? What are the risks/limitations/drawbacks of having MFC runtime in the COM server? And if you advice doing this, how can I do it?
2) As much as I want to affect the third-party COM server's code as little as possible, I thought it might be the better approach to implement my code as a separate MFC-based DLL, and load and use that DLL from COM server. Do you advice doing this? What are the risks/limitations/drawbacks in this situation?
Shortly, I want to use MFC's drawing and especially printing capabilities in my code, which itself should be integrated in another developers' COM dll (which itself is utilized in a large corporate application). I'm no expert in COM technology so I'm a little bit confused. What are my best options?
You can use MFC in your own dll internally, and expose functionality to your users with non MFC intruded function: for example if you need to pass a point from/to ypur caller, use the GDI standard POINT structure, then convert it to a CPoint to use internally. In this case you don't need to enamble use of MFC in the ATL project ( that is possible anyway ) but of course you need to distribute or link with the MFC dll. If you want mantain the caller com dll as clean as possible, you can definitely create your own ATL+MFC dll and expose your functions via com interfaces too, but keep in mynd to avoid put MFC related objects in the interface.
Printing and print preview is a hell of a job unless you're using MFC Document/View Architecture. Will your COM expose such advanced UI?
If your COM must be independent of .NET then MFC is the way to go, otherwise I would use .NET. If you choose MFC, make sure you link to it statically. Otherwise you will most likely end up with runtime errors on machines where the necessary MFC version is missing.
Except for this, I wouldn't worry about compatibility since the idea of COM is to let the underlying magic do the marshaling of integers, strings and other objects.

Interfacing 32-bit and 64-bit code with VB.Net

I have a 64-bit project(which has to be 64-bit as it is an Outlook 2010/64 bit addin) that needs to interface with another Dll of mine, whose job it is to scrape file metadata out of files using the windows Shell32 dll. Now, as you may of guessed, this is posing compatibility problems as I am crossing that 64/32 bit boundary.
I read an article (ok skimmed it, whatever) and from what I understand, it suggested that I use COM as an intermediary and to bridge this gap. So, My question is, can I build a shim DLL in say VB6 (i know, i know) that would act as my com reference and pass the calls on to my 32-bit dll from my 64-bit addin? Can I do this? Has anyone done this? and most importantly, can someone SHOW me how to do this.
Do I create a VB6 COM Dll, reference my .NET assembly and pass all Public functions out via a similar interface, then reference the VB6 dll in my 64-bit addin? is it just that easy?
Thanks for the sanity check..
Andrew

Does Mono support visual basic (not .NET)?

Someone asked me today if it was possible to port a visual basic application to Linux or similar platform, I assumed it was .NET so I suggested to use Mono, but noticed that on their vb support page they only talk about vb 8 (.NET)
Does mono support non-.NET vb? In fact I'm not sure what he is using, I think vb6, I'm not sure of the versioning at all though.
No, VB6 is an entirely different beast from VB.NET. Mono is basically there to run (via JITting, interpreting or AOT-compiling) IL - the Intermediate Language that VB.NET and C# compile down to. (Of course it also provides the libraries and compilers.)
Running VB6 requires an entirely different execution environment, basically.
No, but you could take a look at gambas
Gambas is a free development
environment based on a Basic
interpreter with object extensions, a
bit like Visual Basic™