Connecting to COM Servers


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...
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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);

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.


warheat001Author Commented:
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...
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

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.
warheat001Author Commented:
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...
warheat001Author Commented:
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 !!!
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
warheat001Author Commented:

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

Thanks to others who helped me too.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.