简体   繁体   中英

What is the best way to create a COM component today?

I want to create a deskband COM object for my pet project. I don't have any experience with COM and a quick search revealed that ATL will simplify things. I was wondering if there are any better ways to create a COM component today. Better in the sense less boiler plate, use of C# instead of C++ and any other things you may think of.

If deploying or relying on a .NET framework installation on the client machine is not an issue for you, than C# is much easier than C++ (although you will probably have to redeclare interfaces, IID, etc... in C#, using P/Invoke ). If reducing dependencies is an issue, than C++ with ATL is better.

Just create it in C# and expose as a COM component, see this guide:

http://msdn.microsoft.com/en-us/library/zsfww439.aspx

The only reason I would consider C++/ATL is if I were connecting to any C/C++ libraries. Other than than I can't think of a strong reason to use C++ over C# (assuming your skill level is equivalent in both).

I can only recommend C++ in conjunction with Microsoft's ATL library.

I used some code generation tool written in C++ that helped me to get rid of quite a lot of boilerplate code. This tool generated code that produced more C++ friendly interfaces (like the code that gets generated in the tlh/tli files when you #import a type library in Visual Studio. My code generator produces similar code, only for COM servers.

If you are interested, send a mail to DerTopper at web dot de. Put something like "COM code generator" in the subject line, so that you won't fall through my spam filter.

Regards, Stuart

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM