📄 typecomserver_tlb.pas
字号:
unit TypeComServer_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.130 $
// File generated on 2001-8-17 21:39:21 from Type Library described below.
// ************************************************************************ //
// Type Lib: G:\book_delphi\Delphi6组件开发\第二章 COM组件\S2_4\dll\TypeComServer.dll (1)
// LIBID: {BB8900A7-AC2D-437C-96BF-C747EEA14918}
// LCID: 0
// Helpfile:
// DepndLst:
// (1) v2.0 stdole, (C:\WINNT\System32\stdole2.tlb)
// (2) v4.0 StdVCL, (C:\WINNT\System32\stdvcl40.dll)
// ************************************************************************ //
// *************************************************************************//
// NOTE:
// Items guarded by $IFDEF_LIVE_SERVER_AT_DESIGN_TIME are used by properties
// which return objects that may need to be explicitly created via a function
// call prior to any access via the property. These items have been disabled
// in order to prevent accidental use from within the object inspector. You
// may enable them by defining LIVE_SERVER_AT_DESIGN_TIME or by selectively
// removing them from the $IFDEF blocks. However, such items must still be
// programmatically created via a method of the appropriate CoClass before
// they can be used.
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
interface
uses ActiveX, Classes, Graphics, OleServer, StdVCL, Variants, Windows;
// *********************************************************************//
// 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
// TypeLibrary Major and minor versions
TypeComServerMajorVersion = 1;
TypeComServerMinorVersion = 0;
LIBID_TypeComServer: TGUID = '{BB8900A7-AC2D-437C-96BF-C747EEA14918}';
IID_ITypeDllServer: TGUID = '{56F87051-CD43-49C5-94BE-465DA804F9AE}';
CLASS_TypeDllServer: TGUID = '{1AC0EEE3-D599-45A5-9D29-5AE87029812E}';
type
// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
ITypeDllServer = interface;
// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
TypeDllServer = ITypeDllServer;
// *********************************************************************//
// Interface: ITypeDllServer
// Flags: (256) OleAutomation
// GUID: {56F87051-CD43-49C5-94BE-465DA804F9AE}
// *********************************************************************//
ITypeDllServer = interface(IUnknown)
['{56F87051-CD43-49C5-94BE-465DA804F9AE}']
procedure SetName(const NewName: WideString); stdcall;
function GetName: WideString; stdcall;
function GetSalary(Rate: Single; BaseSalary: Single): Single; stdcall;
end;
// *********************************************************************//
// The Class CoTypeDllServer provides a Create and CreateRemote method to
// create instances of the default interface ITypeDllServer exposed by
// the CoClass TypeDllServer. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
CoTypeDllServer = class
class function Create: ITypeDllServer;
class function CreateRemote(const MachineName: string): ITypeDllServer;
end;
// *********************************************************************//
// OLE Server Proxy class declaration
// Server Object : TTypeDllServer
// Help String : TypeDllServer
// Default Interface: ITypeDllServer
// Def. Intf. DISP? : No
// Event Interface:
// TypeFlags : (2) CanCreate
// *********************************************************************//
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
TTypeDllServerProperties= class;
{$ENDIF}
TTypeDllServer = class(TOleServer)
private
FIntf: ITypeDllServer;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
FProps: TTypeDllServerProperties;
function GetServerProperties: TTypeDllServerProperties;
{$ENDIF}
function GetDefaultInterface: ITypeDllServer;
protected
procedure InitServerData; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Connect; override;
procedure ConnectTo(svrIntf: ITypeDllServer);
procedure Disconnect; override;
procedure SetName(const NewName: WideString);
function GetName: WideString;
function GetSalary(Rate: Single; BaseSalary: Single): Single;
property DefaultInterface: ITypeDllServer read GetDefaultInterface;
published
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
property Server: TTypeDllServerProperties read GetServerProperties;
{$ENDIF}
end;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
// *********************************************************************//
// OLE Server Properties Proxy Class
// Server Object : TTypeDllServer
// (This object is used by the IDE's Property Inspector to allow editing
// of the properties of this server)
// *********************************************************************//
TTypeDllServerProperties = class(TPersistent)
private
FServer: TTypeDllServer;
function GetDefaultInterface: ITypeDllServer;
constructor Create(AServer: TTypeDllServer);
protected
public
property DefaultInterface: ITypeDllServer read GetDefaultInterface;
published
end;
{$ENDIF}
procedure Register;
resourcestring
dtlServerPage = 'ActiveX';
implementation
uses ComObj;
class function CoTypeDllServer.Create: ITypeDllServer;
begin
Result := CreateComObject(CLASS_TypeDllServer) as ITypeDllServer;
end;
class function CoTypeDllServer.CreateRemote(const MachineName: string): ITypeDllServer;
begin
Result := CreateRemoteComObject(MachineName, CLASS_TypeDllServer) as ITypeDllServer;
end;
procedure TTypeDllServer.InitServerData;
const
CServerData: TServerData = (
ClassID: '{1AC0EEE3-D599-45A5-9D29-5AE87029812E}';
IntfIID: '{56F87051-CD43-49C5-94BE-465DA804F9AE}';
EventIID: '';
LicenseKey: nil;
Version: 500);
begin
ServerData := @CServerData;
end;
procedure TTypeDllServer.Connect;
var
punk: IUnknown;
begin
if FIntf = nil then
begin
punk := GetServer;
Fintf:= punk as ITypeDllServer;
end;
end;
procedure TTypeDllServer.ConnectTo(svrIntf: ITypeDllServer);
begin
Disconnect;
FIntf := svrIntf;
end;
procedure TTypeDllServer.DisConnect;
begin
if Fintf <> nil then
begin
FIntf := nil;
end;
end;
function TTypeDllServer.GetDefaultInterface: ITypeDllServer;
begin
if FIntf = nil then
Connect;
Assert(FIntf <> nil, 'DefaultInterface is NULL. Component is not connected to Server. You must call ''Connect'' or ''ConnectTo'' before this operation');
Result := FIntf;
end;
constructor TTypeDllServer.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
FProps := TTypeDllServerProperties.Create(Self);
{$ENDIF}
end;
destructor TTypeDllServer.Destroy;
begin
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
FProps.Free;
{$ENDIF}
inherited Destroy;
end;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
function TTypeDllServer.GetServerProperties: TTypeDllServerProperties;
begin
Result := FProps;
end;
{$ENDIF}
procedure TTypeDllServer.SetName(const NewName: WideString);
begin
DefaultInterface.SetName(NewName);
end;
function TTypeDllServer.GetName: WideString;
begin
DefaultInterface.GetName;
end;
function TTypeDllServer.GetSalary(Rate: Single; BaseSalary: Single): Single;
begin
DefaultInterface.GetSalary(Rate, BaseSalary);
end;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
constructor TTypeDllServerProperties.Create(AServer: TTypeDllServer);
begin
inherited Create;
FServer := AServer;
end;
function TTypeDllServerProperties.GetDefaultInterface: ITypeDllServer;
begin
Result := FServer.DefaultInterface;
end;
{$ENDIF}
procedure Register;
begin
RegisterComponents(dtlServerPage, [TTypeDllServer]);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -