Marco Cantù 1998, Mastering Delphi 4
Project: APPSERV1.DPR
Project Structure
APPSERV1.DPR
program AppServ1;
uses
Forms,
ServForm in 'ServForm.pas' {Form1},
AppServ1_TLB in 'AppServ1_TLB.pas',
FirstRM in 'FirstRM.pas' {MdFirstRM: TDataModule} {MdFirstRM: CoClass};
{$R *.RES}
{$R *.TLB}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
SERVFORM.PAS
unit ServForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, Grids, DBGrids, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses FirstRM;
{$R *.DFM}
end.
APPSERV1_TLB.PAS
unit AppServ1_TLB;
// ************************************************************************ //
// WARNING //
// ------- //
// The types declared in this file were generated from data read from a //
// Type Library. If this type library is explicitly or indirectly (via //
// another type library referring to this type library) re-imported, or the //
// 'Refresh' command of the Type Library Editor activated while editing the //
// Type Library, the contents of this file will be regenerated and all //
// manual modifications will be lost. //
// ************************************************************************ //
// PASTLWTR : $Revision: 1.11.1.63 $
// File generated on 7/14/98 3:34:47 PM from Type Library described below.
// ************************************************************************ //
// Type Lib: C:\md4code\Part5\25\AppServ1\AppServ1.tlb
// IID\LCID: {AE857760-2114-11D1-98D0-444553540000}\0
// Helpfile:
// HelpString: AppServ1 Library
// Version: 1.0
// ************************************************************************ //
interface
uses Windows, ActiveX, Classes, Graphics, OleCtrls, StdVCL;
// *********************************************************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used: //
// Type Libraries : LIBID_xxxx //
// CoClasses : CLASS_xxxx //
// DISPInterfaces : DIID_xxxx //
// Non-DISP interfaces: IID_xxxx //
// *********************************************************************//
const
LIBID_AppServ1: TGUID = '{AE857760-2114-11D1-98D0-444553540000}';
IID_IMdFirstRM: TGUID = '{AE857761-2114-11D1-98D0-444553540000}';
CLASS_MdFirstRM: TGUID = '{AE857762-2114-11D1-98D0-444553540000}';
type
// *********************************************************************//
// Forward declaration of interfaces defined in Type Library //
// *********************************************************************//
IMdFirstRM = interface;
IMdFirstRMDisp = dispinterface;
// *********************************************************************//
// Declaration of CoClasses defined in Type Library //
// (NOTE: Here we map each CoClass to its Default Interface) //
// *********************************************************************//
MdFirstRM = IMdFirstRM;
// *********************************************************************//
// Interface: IMdFirstRM
// Flags: (4432) Hidden Dual OleAutomation Dispatchable
// GUID: {AE857761-2114-11D1-98D0-444553540000}
// *********************************************************************//
IMdFirstRM = interface(IDataBroker)
['{AE857761-2114-11D1-98D0-444553540000}']
function Get_Table1: IProvider; safecall;
property Table1: IProvider read Get_Table1;
end;
// *********************************************************************//
// DispIntf: IMdFirstRMDisp
// Flags: (4432) Hidden Dual OleAutomation Dispatchable
// GUID: {AE857761-2114-11D1-98D0-444553540000}
// *********************************************************************//
IMdFirstRMDisp = dispinterface
['{AE857761-2114-11D1-98D0-444553540000}']
property Table1: IProvider readonly dispid 1;
function GetProviderNames: OleVariant; dispid 22929905;
end;
CoMdFirstRM = class
class function Create: IMdFirstRM;
class function CreateRemote(const MachineName: string): IMdFirstRM;
end;
implementation
uses ComObj;
class function CoMdFirstRM.Create: IMdFirstRM;
begin
Result := CreateComObject(CLASS_MdFirstRM) as IMdFirstRM;
end;
class function CoMdFirstRM.CreateRemote(const MachineName: string): IMdFirstRM;
begin
Result := CreateRemoteComObject(MachineName, CLASS_MdFirstRM) as IMdFirstRM;
end;
end.
FIRSTRM.PAS
unit FirstRM;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComServ, ComObj, VCLCom, StdVcl, BdeProv, DataBkr, AppServ1_TLB, Db,
DBTables;
type
TMdFirstRM = class(TDataModule, IMdFirstRM)
Table1: TTable;
private
{ Private declarations }
public
{ Public declarations }
protected
function Get_Table1: IProvider; safecall;
end;
var
MdFirstRM: TMdFirstRM;
implementation
{$R *.DFM}
function TMdFirstRM.Get_Table1: IProvider;
begin
Result := Table1.Provider;
end;
initialization
TComponentFactory.Create(ComServer, TMdFirstRM,
Class_MdFirstRM, ciMultiInstance);
end.
SERVFORM.DFM
object Form1: TForm1
Left = 194
Top = 108
Width = 323
Height = 93
Caption = 'AppServ1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 24
Top = 16
Width = 264
Height = 24
Caption = 'Remote Data Module Server (1)'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -19
Font.Name = 'MS Sans Serif'
Font.Style = []
ParentFont = False
end
end
FIRSTRM.DFM
object MdFirstRM: TMdFirstRM
OldCreateOrder = True
Left = 206
Top = 190
Height = 315
Width = 314
object Table1: TTable
DatabaseName = 'DBDEMOS'
TableName = 'employee.db'
Left = 32
Top = 32
end
end
Copyright Marco Cantù 1998