COM programming

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

COM programming

Postby DEC9 » Mon Feb 22, 2010 5:01 pm

Some years ago I managed to scrounge enough information on using COM in C++Builder to get pieces of our sim to talk to each other, and to be callable from Matlab.

At least for Builder 6 in Windows XP 32 bit.

Now we've upgraded (if that's the right word) to Builder 2007 and Vista has come along and we're having ever more difficulties. I need to get up-to-date on COM (including ActiveX -- our Excel interface doesn't work any more either). Can anyone suggest resources for COM/ActiveX programming in Builder 2007? I have a number of COM books ("COM Programming by Example", "Essential COM", etc.) I picked up way back when but as I recall little of it is applicable to C++Builder.

TIA for any suggestions!
DEC9
 
Posts: 5
Joined: Mon Feb 22, 2010 4:43 pm

Re: COM programming

Postby 2ffat » Tue Feb 23, 2010 11:07 am

Look at the articles at C++Builder Developer's Journal. There are several articles on COM.
James P. Cottingham
There's no place like 127.0.0.1
There's no place like 127.0.0.1
User avatar
2ffat
Forum Mod
Forum Mod
 
Posts: 260
Joined: Wed Jun 23, 2004 7:07 am
Location: South Hill, VA

Re: COM programming

Postby arisme » Tue Feb 23, 2010 12:59 pm

DEC9 wrote:At least for Builder 6 in Windows XP 32 bit.

If you have C++Builder 6 Help available, hang on to it, or copy it back on to your system. The coverage of COM was about as reasonable and extensive as Borland/Codegear Help ever got. It should be useful for refreshing yourself with COM.

In respect of any problems with applications that worked previously, but fail under Builder 2007 and Vista, I would be inclined to suspect Vista first and eliminate any possible causes from the way it approaches process management and security. (This is from reading about other people's problems - I am C++Builder 2007 and XP SP2, and planning to stay there for a while yet...) COM itself has been around long enough to have reached a level that would only need technology changes where they are forced on it by a radically new OS.

Incidentally, I read somewhere that Windows 7 will be using virtualization to provide an XP virtual machine as an option - so maybe all your legacy applications could be housed there.

Aris
arisme
BCBJ Master
BCBJ Master
 
Posts: 357
Joined: Thu Jun 07, 2007 9:35 pm
Location: UK

Re: COM programming

Postby gambit47 » Tue Feb 23, 2010 8:59 pm

arisme wrote:In respect of any problems with applications that worked previously, but fail under Builder 2007 and Vista, I would be inclined to suspect Vista first and eliminate any possible causes from the way it approaches process management and security.


Agreed. BCB's COM support hasn't changed much (at least not until 2009 where TLB files were replaced with RIDL files), but the OS's support for COM has changed over the years. Vista's Registry Virtualization feature, for instance, might wreak some havon on legacy COM products that require their COM object registrations to work a particular way. Microsoft tried to exclude COM from the virtualization, but who knows if they actually got it right.
Remy Lebeau (TeamB)
http://www.lebeausoftware.org
User avatar
gambit47
BCBJ Author
BCBJ Author
 
Posts: 472
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: COM programming

Postby DEC9 » Thu Feb 25, 2010 6:36 pm

arisme wrote:If you have C++Builder 6 Help available, hang on to it, or copy it back on to your system. The coverage of COM was about as reasonable and extensive as Borland/Codegear Help ever got.


Agreed. Help in Builder 2007 was a huge step backwards.

arisme wrote:...COM itself has been around long enough to have reached a level that would only need technology changes where they are forced on it by a radically new OS.


Hence my surprise that our COM apps fails on Vista (and XP 64 it turns out). The maturity of COM in Windows is what leads me to suspect that C++Builder's implementation is somehow at fault.
DEC9
 
Posts: 5
Joined: Mon Feb 22, 2010 4:43 pm

Re: COM programming

Postby arisme » Thu Feb 25, 2010 9:24 pm

DEC9 wrote:The maturity of COM in Windows is what leads me to suspect that C++Builder's implementation is somehow at fault.

That conclusion will only hold true if there have been no material changes in Windows code, and there have been adverse changes in the application code. Don't forget that every successful execution of a program is the result of a cooperative effort by the application code and the OS code as they stand at that point in time.

I still have executables that were compiled with BCB 3 under Win98 running successfully on a daily basis. They have been fortunate that the OS code they call has not changed in any functionally significant way since the 1990's. There are other executables that have had to be modified with every change of OS.

What was the first cause of failure - upgrade to Vista, or application conversion to BCB 2007? Or did you upgrade to Vista and convert to 2007 at the same time?

Aris
arisme
BCBJ Master
BCBJ Master
 
Posts: 357
Joined: Thu Jun 07, 2007 9:35 pm
Location: UK

Re: COM programming

Postby DEC9 » Mon Mar 01, 2010 8:20 pm

I appreciate everyone's ideas and suggestions. The original question remains:

What sources are available to learn to use the Builder interfaces to COM? Years ago I took the elementary examples from what C++Builder books and manuals and articles I could find (and after 24 years of using Turbo/Borland/CodeGear compilers, I think I've seen them all) and made something work. It no longer does. I can search the Help system for TEventDispatcher and ComObjectRootEx and all of that, or I can try "un-COM-ing" the objects in question, then "re-COM-ing" them (like we've learned to do when we migrate projects to new Builder releases), but I don't learn anything new.

In the end it doesn't matter if Builder changed or if Vista / XP64 changed. Bottom line is the two don't work together, and there's not a lot we can do about Vista; we only have control over our own code.

If you have a success story building COM exe's that can spawn and link to each other, including events and sinks, that work reliably on 32- and 64-bit XP and Vista (and Win 7 perhaps) using Builder 2007 or later, I really really really want to talk to you.

Thanks again for all your input. So glad there's a community like this available!

-Dean
DEC9
 
Posts: 5
Joined: Mon Feb 22, 2010 4:43 pm

Re: COM programming

Postby arisme » Thu Mar 04, 2010 1:58 am

DEC9 wrote:The original question remains:
What sources are available to learn to use the Builder interfaces to COM?

A book with a number of recommendations for getting to grips with C++Builder COM is "Borland C++Builder 4 Unleashed" by Kent Reisdorph et al., ISBN 0-672-31510-6. I do not know whether it is still in print, or whether second user copies might be available somewhere. A Google search for the title or ISBN may lead to a copy somewhere.

In case you are not aware of it, www.deja.com takes you to the Google newsgroup archive. For specifics, a search there can produce surprisingly good results, often with useful code snippets. Include cppbuilder as a search term - e.g.

    "COM interface" cppbuilder
As suggested by 2ffat, apart from the subject matter, the Journal articles often contain references which may lead to something useful.

Also of course, MSDN. I appreciate this is not C++Builder stuff, but a lot of the VCL and BCB methods are wrappers around Windows API calls.

---oOo---

Thinking about your project, the picture I have is of a number of BCB coded modules using COM for IPC at least, and probably more. The question that raises itself is "Could the IPC be replaced by an alternative such as sockets or memory mapped files, and the other logic of COM relocated and modified to work with a more straightforward IPC?".

Another thought that occurs is the possibility of investing in some Virtual Machine software (without upgrading to Windows 7 for a while), and running BCB 6 and the legacy software in its own little corner. This previous topic touches on this.

Aris
arisme
BCBJ Master
BCBJ Master
 
Posts: 357
Joined: Thu Jun 07, 2007 9:35 pm
Location: UK

Re: COM programming

Postby DEC9 » Wed Mar 10, 2010 12:57 pm

arisme wrote:A book with a number of recommendations for getting to grips with C++Builder COM is "Borland C++Builder 4 Unleashed" by Kent Reisdorph et al., ISBN 0-672-31510-6. ...


I used to have that book, not sure where it went. "The C++Builder 6 Developers Guide" by Hollingworth, et.al., is a good reference. Much of the COM info I found originally came from there. So far as I can tell there are no resources like them for Builder 2007 or later.

The Microsoft COM references are of limited benefit, since (and this may have changed) you MUST use the VCL classes for COM.

As far as coming up with an alternative approach (e.g., sockets), sure, there's always another way to skin the cat when it comes to software. As we speak I'm furiously turning our image analysis application into a DLL so we can attach it to the main simulation in time for a demo tomorrow. Another alternative is to simply abandon a capability, such as running our sim from Matlab.

I've been programming for nearly 30 years and I see the same thing over and over; the one technology we continue to fail to master is communication. No doubt the VCL approach to COM/COM+/DCOM is elegant, feature-rich, all the things the VCL promised us originally re. Windows GUI programming. Unfortunately it's all hidden under a cone of silence. We can't use something if the developers can't figure out a way to tell us about it. Microsoft learned this early, hence MSDN, Microsoft Press, etc. CodeGear ignores it at their peril -- and our own as well, I fear.

Thanks again for all the input.
DEC9
 
Posts: 5
Joined: Mon Feb 22, 2010 4:43 pm

Re: COM programming

Postby DEC9 » Thu Mar 11, 2010 8:47 pm

BTW, one error message we get is:

'Create(intfObj)': No such interface supported
@ c:\program files\codegear\rad studio\5.0\include\vcl\utilcls.h/2635
Press [Y]es to ...

-Dean
DEC9
 
Posts: 5
Joined: Mon Feb 22, 2010 4:43 pm

Re: COM programming

Postby gambit47 » Fri Mar 12, 2010 4:56 pm

DEC9 wrote:BTW, one error message we get is:

'Create(intfObj)': No such interface supported
@ c:\program files\codegear\rad studio\5.0\include\vcl\utilcls.h/2635
Press [Y]es to ...

-Dean


The error means that the COM object you instantiated does not support the interface you are trying to use. This usually happens if you do not have the COM object installed correctly, or if you have an older version of the COM object installed and the CoClass of the COM object uses a different default interface than the code is expecting.
Remy Lebeau (TeamB)
http://www.lebeausoftware.org
User avatar
gambit47
BCBJ Author
BCBJ Author
 
Posts: 472
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA


Return to Technical

Who is online

Users browsing this forum: Google [Bot] and 1 guest