Solved

Connecting to COM Servers

Posted on 2003-11-22
8
1,262 Views
Last Modified: 2007-12-19
Hi,

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...
0
Comment
Question by:warheat001
  • 4
  • 3
8 Comments
 
LVL 3

Expert Comment

by:Peter_
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;
...
var
  WordApp  : _Application;
  VarFalse : OleVariant;
begin
  WordApp := CoApplication.Create;
 // Now do something... Then exit!
 VarFalse:=False;
  WordApp.Quit(VarFalse,
               EmptyParam, EmptyParam);
end;
0
 
LVL 5

Expert Comment

by:DeerBear
ID: 9810074
Hi,

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.

HTH,

Andrew
0
 

Author Comment

by:warheat001
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...

WinFiol.XXXXX

How can I get the other functions and features...
0
 
LVL 3

Expert Comment

by:Peter_
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:

var
 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.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:warheat001
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...
0
 

Author Comment

by:warheat001
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 !!!
0
 
LVL 3

Accepted Solution

by:
Peter_ earned 50 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 http://pub9.ezboard.com/fsunnybeachproductsupportfrm6.showMessage?topicID=3.topic):

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;
begin
Result := CreateComObject(CLASS_Generator) as IGenerator;
end;

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;

var
  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:

var
  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.
0
 

Author Comment

by:warheat001
ID: 11464079
Hi,

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

Thanks to others who helped me too.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now