客戶端通過AppServer 調用服務器端函數, 出錯??? ( 积分: 50 )

  • 主题发起人 主题发起人 xyyct
  • 开始时间 开始时间
X

xyyct

Unregistered / Unconfirmed
GUEST, unregistred user!
客戶端通過AppServer 調用服務器端函數, 怎么都通不過.
出錯信息: ACCESS VIOLATION AT ADDRESS 00480A7B IN MODULE 'LIFTCLIENT.EXE'. READ OF ADDRESS 00000058
大家幫忙看一看吧!

unit LiftServer_TLB;

{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
interface

uses Windows, ActiveX, Classes, Graphics, Midas, StdVCL, Variants;


// *********************************************************************//
// 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
LiftServerMajorVersion = 1;
LiftServerMinorVersion = 0;

LIBID_LiftServer: TGUID = '{EE200467-089E-44FF-AFDE-C4FBC0A80C49}';

IID_IrdmServer: TGUID = '{A3BFC52B-A1D1-494A-8915-7D223AEEBC5D}';
CLASS_rdmServer: TGUID = '{949E821E-384A-473A-A28B-C9D5E377DA6C}';
CLASS_Pooler: TGUID = '{A4474DC1-A3E5-45AE-9148-FDE208553737}';
type

// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
IrdmServer = interface;
IrdmServerDisp = dispinterface;

// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
rdmServer = IrdmServer;
Pooler = IrdmServer;


// *********************************************************************//
// Interface: IrdmServer
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {A3BFC52B-A1D1-494A-8915-7D223AEEBC5D}
// *********************************************************************//
IrdmServer = interface(IAppServer)
['{A3BFC52B-A1D1-494A-8915-7D223AEEBC5D}']
function TestFunction: Integer; safecall;
end;

// *********************************************************************//
// DispIntf: IrdmServerDisp
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {A3BFC52B-A1D1-494A-8915-7D223AEEBC5D}
// *********************************************************************//
IrdmServerDisp = dispinterface
['{A3BFC52B-A1D1-494A-8915-7D223AEEBC5D}']
function TestFunction: Integer; dispid 301;
function AS_ApplyUpdates(const ProviderName: WideString; Delta: OleVariant; MaxErrors: Integer;
out ErrorCount: Integer; var OwnerData: OleVariant): OleVariant; dispid 20000000;
function AS_GetRecords(const ProviderName: WideString; Count: Integer; out RecsOut: Integer;
Options: Integer; const CommandText: WideString; var Params: OleVariant;
var OwnerData: OleVariant): OleVariant; dispid 20000001;
function AS_DataRequest(const ProviderName: WideString; Data: OleVariant): OleVariant; dispid 20000002;
function AS_GetProviderNames: OleVariant; dispid 20000003;
function AS_GetParams(const ProviderName: WideString; var OwnerData: OleVariant): OleVariant; dispid 20000004;
function AS_RowRequest(const ProviderName: WideString; Row: OleVariant; RequestType: Integer;
var OwnerData: OleVariant): OleVariant; dispid 20000005;
procedure AS_Execute(const ProviderName: WideString; const CommandText: WideString;
var Params: OleVariant; var OwnerData: OleVariant); dispid 20000006;
end;

// *********************************************************************//
// The Class CordmServer provides a Create and CreateRemote method to
// create instances of the default interface IrdmServer exposed by
// the CoClass rdmServer. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
CordmServer = class
class function Create: IrdmServer;
class function CreateRemote(const MachineName: string): IrdmServer;
end;

// *********************************************************************//
// The Class CoPooler provides a Create and CreateRemote method to
// create instances of the default interface IrdmServer exposed by
// the CoClass Pooler. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
CoPooler = class
class function Create: IrdmServer;
class function CreateRemote(const MachineName: string): IrdmServer;
end;

implementation

uses ComObj;

class function CordmServer.Create: IrdmServer;
begin
Result := CreateComObject(CLASS_rdmServer) as IrdmServer;
end;

class function CordmServer.CreateRemote(const MachineName: string): IrdmServer;
begin
Result := CreateRemoteComObject(MachineName, CLASS_rdmServer) as IrdmServer;
end;

class function CoPooler.Create: IrdmServer;
begin
Result := CreateComObject(CLASS_Pooler) as IrdmServer;
end;

class function CoPooler.CreateRemote(const MachineName: string): IrdmServer;
begin
Result := CreateRemoteComObject(MachineName, CLASS_Pooler) as IrdmServer;
end;

rdmServer 中:

function TrdmServer.TestFunction: Integer;
begin
result := frmMain.TestFunction;
end;

Pooler 中:

function TPooler.TestFunction: Integer;
var
RDM: IrdmServer;
begin
RDM := LockRDM;

try
Result := RDM.TestFunction;
finally
UnlockRDM(RDM);
end;
end;
 
客戶端通過AppServer 調用服務器端函數, 怎么都通不過.
出錯信息: ACCESS VIOLATION AT ADDRESS 00480A7B IN MODULE 'LIFTCLIENT.EXE'. READ OF ADDRESS 00000058
大家幫忙看一看吧!

unit LiftServer_TLB;

{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
interface

uses Windows, ActiveX, Classes, Graphics, Midas, StdVCL, Variants;


// *********************************************************************//
// 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
LiftServerMajorVersion = 1;
LiftServerMinorVersion = 0;

LIBID_LiftServer: TGUID = '{EE200467-089E-44FF-AFDE-C4FBC0A80C49}';

IID_IrdmServer: TGUID = '{A3BFC52B-A1D1-494A-8915-7D223AEEBC5D}';
CLASS_rdmServer: TGUID = '{949E821E-384A-473A-A28B-C9D5E377DA6C}';
CLASS_Pooler: TGUID = '{A4474DC1-A3E5-45AE-9148-FDE208553737}';
type

// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
IrdmServer = interface;
IrdmServerDisp = dispinterface;

// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
rdmServer = IrdmServer;
Pooler = IrdmServer;


// *********************************************************************//
// Interface: IrdmServer
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {A3BFC52B-A1D1-494A-8915-7D223AEEBC5D}
// *********************************************************************//
IrdmServer = interface(IAppServer)
['{A3BFC52B-A1D1-494A-8915-7D223AEEBC5D}']
function TestFunction: Integer; safecall;
end;

// *********************************************************************//
// DispIntf: IrdmServerDisp
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {A3BFC52B-A1D1-494A-8915-7D223AEEBC5D}
// *********************************************************************//
IrdmServerDisp = dispinterface
['{A3BFC52B-A1D1-494A-8915-7D223AEEBC5D}']
function TestFunction: Integer; dispid 301;
function AS_ApplyUpdates(const ProviderName: WideString; Delta: OleVariant; MaxErrors: Integer;
out ErrorCount: Integer; var OwnerData: OleVariant): OleVariant; dispid 20000000;
function AS_GetRecords(const ProviderName: WideString; Count: Integer; out RecsOut: Integer;
Options: Integer; const CommandText: WideString; var Params: OleVariant;
var OwnerData: OleVariant): OleVariant; dispid 20000001;
function AS_DataRequest(const ProviderName: WideString; Data: OleVariant): OleVariant; dispid 20000002;
function AS_GetProviderNames: OleVariant; dispid 20000003;
function AS_GetParams(const ProviderName: WideString; var OwnerData: OleVariant): OleVariant; dispid 20000004;
function AS_RowRequest(const ProviderName: WideString; Row: OleVariant; RequestType: Integer;
var OwnerData: OleVariant): OleVariant; dispid 20000005;
procedure AS_Execute(const ProviderName: WideString; const CommandText: WideString;
var Params: OleVariant; var OwnerData: OleVariant); dispid 20000006;
end;

// *********************************************************************//
// The Class CordmServer provides a Create and CreateRemote method to
// create instances of the default interface IrdmServer exposed by
// the CoClass rdmServer. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
CordmServer = class
class function Create: IrdmServer;
class function CreateRemote(const MachineName: string): IrdmServer;
end;

// *********************************************************************//
// The Class CoPooler provides a Create and CreateRemote method to
// create instances of the default interface IrdmServer exposed by
// the CoClass Pooler. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
CoPooler = class
class function Create: IrdmServer;
class function CreateRemote(const MachineName: string): IrdmServer;
end;

implementation

uses ComObj;

class function CordmServer.Create: IrdmServer;
begin
Result := CreateComObject(CLASS_rdmServer) as IrdmServer;
end;

class function CordmServer.CreateRemote(const MachineName: string): IrdmServer;
begin
Result := CreateRemoteComObject(MachineName, CLASS_rdmServer) as IrdmServer;
end;

class function CoPooler.Create: IrdmServer;
begin
Result := CreateComObject(CLASS_Pooler) as IrdmServer;
end;

class function CoPooler.CreateRemote(const MachineName: string): IrdmServer;
begin
Result := CreateRemoteComObject(MachineName, CLASS_Pooler) as IrdmServer;
end;

rdmServer 中:

function TrdmServer.TestFunction: Integer;
begin
result := frmMain.TestFunction;
end;

Pooler 中:

function TPooler.TestFunction: Integer;
var
RDM: IrdmServer;
begin
RDM := LockRDM;

try
Result := RDM.TestFunction;
finally
UnlockRDM(RDM);
end;
end;
 
后退
顶部