Link to home
Start Free TrialLog in
Avatar of Gareth_Hastings
Gareth_Hastings

asked on

DCOM problems

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
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Is there Delphi installed on client's machine?? whats the error message?
ziolko.
..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.
Avatar of Gareth_Hastings
Gareth_Hastings

ASKER

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.
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.
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.
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?
sure post here Your email I'll send You something.
ziolko.
great thanks

gareth@netgs.co.uk
ASKER CERTIFIED SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sure np
excellent help, thanks loads