Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1279
  • Last Modified:

Connecting to COM Servers

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
warheat001
Asked:
warheat001
  • 4
  • 3
1 Solution
 
Peter_Commented:
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
 
DeerBearCommented:
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
 
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...

WinFiol.XXXXX

How can I get the other functions and features...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now