?
Solved

DCOM problems

Posted on 2003-03-03
11
Medium Priority
?
244 Views
Last Modified: 2010-04-04
I've been trying to learn how to do DCOM and have run into a problem.

Current I made a server app that just sends a windows message to another program I made. these both run on the same pc.

I then made a client which calls the method from the server app and this all works fine.

I then tried to run the client on another machine (after running the server app so as to register it) and it don't work :/ I ran dcomcnfg and found my dcom class thingy and changed it so it tried to run from the server computer but that don't work either. Here's the code for the server and client. (This works fine when both run on the local machine)


Server
---------------------------------------

interface

uses
  ComObj, ActiveX, srv3_TLB, StdVcl, messages, windows;

Const
   EX_START = WM_USER + 100;

type
  Tgdh = class(TAutoObject, Igdh)
  protected
    procedure startexo; safecall;
    { Protected declarations }
  end;

implementation

uses ComServ;

procedure Tgdh.startexo;
var
   hwnd  : THandle;
begin
   hwnd := FindWindow(Nil, pchar('gdhServer'));
   if hwnd <> 0 then
      SendMessage(hwnd, EX_START, 0, 0);

end;

initialization
  TAutoObjectFactory.Create(ComServer, Tgdh, Class_gdh,
    ciMultiInstance, tmApartment);
end.
---------------------------------------


client
---------------------------------------
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, srv3_TLB, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
   srv: Igdh;
begin
   srv := Cogdh.CreateRemote('172.24.201.10');
   srv.startexo;
   srv := nil;
end;

end.
----------------------------------------------------


Thanks for any help :)

Gareth
0
Comment
Question by:Gareth_Hastings
[X]
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
  • 6
  • 5
11 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 8060458
Is there Delphi installed on client's machine?? whats the error message?
ziolko.
0
 
LVL 21

Expert Comment

by:ziolko
ID: 8060483
..one more thing add TDCOMConnection and try connect to server in design mode (set computername and servername/serverGUID). more info on http://www.distribucon.com/dcom.html
ziolko.
0
 
LVL 1

Author Comment

by:Gareth_Hastings
ID: 8063442
There is no error message when the client is compiled on the remote machine. Adding a TDCOMConnection and setting it to connect to the remote machine and adding the GUID and then setting connect to true doesn't give any errors either.
0
Technology Partners: 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!

 
LVL 21

Expert Comment

by:ziolko
ID: 8063491
If theres no error with TDCOMConnection in design time, try same thing in runtime after setting DCOMConnection's Connected propoerty to True call remote method
DCOMConnection.AppServer.yuormethod, some error must be thrown out :-)
ziolko.
0
 
LVL 1

Author Comment

by:Gareth_Hastings
ID: 8063524
right I have these 2 lines


DCOMConnection1.Connected := true;
DCOMConnection1.AppServer.startexo;


these cause no errors when run, but what happens now is I run the client the server opens and then doesn't appear to execute the "startexo" method. But when run from the remote machine the server app doesn't even appear to start or at least the form didn't pop up on the server computer like it did when run locally.
0
 
LVL 1

Author Comment

by:Gareth_Hastings
ID: 8063562
ok this is probably something simple but its annoying!! I don't suppose I could get a small example off you please? of a client/server app?
0
 
LVL 21

Expert Comment

by:ziolko
ID: 8063622
sure post here Your email I'll send You something.
ziolko.
0
 
LVL 1

Author Comment

by:Gareth_Hastings
ID: 8063713
great thanks

gareth@netgs.co.uk
0
 
LVL 21

Accepted Solution

by:
ziolko earned 1600 total points
ID: 8063725
I'll send You samoething later in the evening, Hope You dont mind.
ziolko.
0
 
LVL 1

Author Comment

by:Gareth_Hastings
ID: 8063747
sure np
0
 
LVL 1

Author Comment

by:Gareth_Hastings
ID: 8083541
excellent help, thanks loads
0

Featured Post

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.

Question has a verified solution.

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

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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

800 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