Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Connecting to COM Servers

Posted on 2003-11-22
Medium Priority
Last Modified: 2007-12-19

I am a beginner programmer in Delphi 6 working in telecommunications area. I have a software that is named 'WinFiol 6.0' created by ericcson company which is like a terminal that communicates to the exchange.

In this program I can see that we can connect to the program using DDE and COM. Becuase I can watch the connections and the software does say that we can connect to the COM.

Question is, how I can connect to this software and do command sending and reading and tasks like that.

Can you guys look into this program or tell me as much as you guys can how I can establish this.

Thank you...
Question by:warheat001
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3

Expert Comment

ID: 9807316
I don't know anything about that specific software, but in general when connecting to a com-server you begin by importing a type library file.

In Delphi, choose Project/Import Typelibrary. Then select "create from" and browse to find the application ( WinFiol in this case ) .exe or .dll file.

This will create an interface (TLB-file) which shows all available types/functions/properties you can access.  Browse this file carefully and then start exploring the functions.

This is an example on connecting to ms-word

uses Word_TLB;
  WordApp  : _Application;
  VarFalse : OleVariant;
  WordApp := CoApplication.Create;
 // Now do something... Then exit!
               EmptyParam, EmptyParam);

Expert Comment

ID: 9810074

I see a kind of misunderstanding here. Quoting your OP, you say:
"In this program I can see that we can connect to the program
using DDE and COM. Becuase I can watch the connections and the
software does say that we can connect to the COM."

I am unsure what kind of COM it refers to, I think the software is
saying you can connect to the COM /port/, not via COM.

As you can see from your sentence, though, it's not easy to
state if mine is a viable interpretation.

If it was, though, I'd say you can only use DDE or some
weird COM protocol, whose details should be read on the
software's manuals.

Mine is a wild guess, but if I understood right, then I
would surely vote the protocol option over the DDE one,
since you can always update a client using the COM port,
while DDE may be taken off Windows at any time, since it's
been declared "dead" by M$ a number of years ago.



Author Comment

ID: 9836533
Thanx  Peter_

But now I have another problem. I am only able to see only some of the commands/features that I am able to do with the program. How can I get to do the other jobs. I did see the .pas file and there I saw a lot of functions and procedures. But in the coding, I am getting only a limited of them after I put the dot to that object.

I mean like this...


How can I get the other functions and features...
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 9838341
COM programming have all to do with interfaces. That is the same application usually offer many different COM interfaces for different purposes. Each interface has its own GUID (That long strange looking number inside {...}), it also has a name.

To me, it sounds like perhaps you are connecting to the wrong interface? Or maybe you will need to access different interfaces to gain access to all the procedures/data you want? Think of this in much the same way as with an object, when using regular applications. If you create a button object, then you don't gain access to all the functions of a TEdit object and so on...

You could try casting your pointer, in the same way as this:

 Mydisp: IDispatch;

Mydisp := (WordApp as IDispatch);

This is a rather meaningless sample, but it might show what I mean.

Sometimes you will have to use the QueryInterface() function to get hold of the right interface (The "as" operator also makes use of this internally).

It could be though, that just a small part of the applications procedures/data can be accessed using COM? This is rather common.

Author Comment

ID: 9839466
Thanx for the info  Peter_. From what you are saying I think I am on the right track. When I look at the .pas file of the type library I see a lot of these GUID and that strange looking number inside {......}. And when I observed that, I am seeing that the functions I am seeing at the coding area is only the functions specified in one of those. But I want to know how I can access the other GUIDs.

That is where I am stuck. I am able to connect, change the client name and stuff like that. But the important part I want is inside another GUID. And I don't know how to connect to that part.

 Peter_. I want to send you the .tlb file to you. Is there anyway, I can send the file to you. Either an e-mail address or something. I prefer e-mail. I don't know how I can attach a file here (experts-exchange), if there is one.

Hope to hear a soon reply...

Author Comment

ID: 9955464
Does anyone know how I can accomplish what Peter_ is telling. So far, I have been trying to but no luck yet.
Could anyone of you help me on this. Any suggestions !!!

Accepted Solution

Peter_ earned 150 total points
ID: 9956049
I'm not sure how much I could make out of the tlb unless the solution is really obvious. Since I don't have the component, I could not run any tests.

But in short:

Somewhere in your tlb you have an interface with a GUID which have the functions you want.

The easiest case is when you can directly connect to this interface by creating an instance of an object, like in this case (a cut and paste sample from a tlb i just found on the net at

Way up in the tlb, it shows the name and guid of an interface as shown below:

CLASS_Generator: TGUID = '{D63AE28A-C818-497A-8D79-5FBC8ACDD4C9}';

Further down, it shows how to create an instance of the object on the local computer and connecting to this specific interface at the same time. This function is used by delphi if you choose to import the object as a component.

class function CoGenerator.Create: IGenerator;
Result := CreateComObject(CLASS_Generator) as IGenerator;

You don't have to import the object as a component, but rather you can just create it in your own code doing much the same like:

uses ComObj;

  MyGenerator: IGenerator;

MyGenerator := CreateComObject(CLASS_Generator) as IGenerator;

Now you should be able to call the functions included in the interface IGenerator, like this for example:

  MyRandomDouble: Double;

MyRandomDouble := MyGenerator.RandomDouble;

I havent tried running this actual sample, as I dont have this component installed I cant. But I've done this before using other components so I know the theory works.

Sometimes though, it aint that easy like I said. The interface you need may be part of a collection that can only be accessed from another interface (like the html elements for example being part of a collection belonging to a html document interface, which in turn belongs to an instance of the internet explorer webbrowser when trying to parse a webpage).

In that case you need to start by creating the first interface, then calling a function that returns an instance of the interface that you want. Remember also that interfaces can inherit in much the same way as an object (especially from the interfaces IUnknown and IDisparch).

So sometimes a function can return an inherited interface of type IDispatch instead of the one you really want. In that case you will then need to use queryInterface or the "as" operator to cast this interface.

If you read an article about COM in general, you will find this alot easier to understand. There are many good ones for free on the net. Good luck.

Author Comment

ID: 11464079

Peter, a lot of thanx to you.
Took me ages, but finally I have made it work.

Thanks to others who helped me too.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question