Buen día amigos,
Les comento tengo una .dll c# de la cual quiero usar unos procedimientos de ella, pero he tenido complicaciones al momento de implimentarla en delphi.
he importado la .dll pero no encuentro la forma de usar el procedimiento, soy nuevo en este tipo de implementación y necesito su ayuda.
Código Delphi
[-]unit FXML_TLB;
{$TYPEDADDRESS OFF} {$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
{$ALIGN 4}
interface
uses Winapi.Windows, mscorlib_TLB, System.Classes, System.Variants, System.Win.StdVCL, Vcl.Graphics, Vcl.OleServer, Winapi.ActiveX;
const
FXMLMajorVersion = 1;
FXMLMinorVersion = 0;
LIBID_FXML: TGUID = '{BDAD580F-3986-4941-B00F-BED3DAABE135}';
IID__CFXML: TGUID = '{F363CEDB-6C8C-393B-B124-5B785E445D2A}';
IID_IFXML: TGUID = '{143763CA-C3D3-4F93-863F-63DD2CA1228C}';
CLASS_CFXML: TGUID = '{B00E8B03-B374-42C7-A76A-4D51545027E0}';
type
_CFXML = interface;
_CFXMLDisp = dispinterface;
IFXML = interface;
IFXMLDisp = dispinterface;
CFXML = _CFXML;
_CFXML = interface(IDispatch)
['{F363CEDB-6C8C-393B-B124-5B785E445D2A}']
function Get_ToString: WideString; safecall;
function Equals(obj: OleVariant): WordBool; safecall;
function GetHashCode: Integer; safecall;
function GetType: _Type; safecall;
property ToString: WideString read Get_ToString;
end;
_CFXMLDisp = dispinterface
['{F363CEDB-6C8C-393B-B124-5B785E445D2A}']
property ToString: WideString readonly dispid 0;
function Equals(obj: OleVariant): WordBool; dispid 1610743809;
function GetHashCode: Integer; dispid 1610743810;
function GetType: _Type; dispid 1610743811;
end;
IFXML = interface(IDispatch)
['{143763CA-C3D3-4F93-863F-63DD2CA1228C}']
procedure FirmaXML(const path_cert: WideString; const pass_cert: WideString;
const path_xml: WideString; const path_guardar: WideString); safecall;
end;
IFXMLDisp = dispinterface
['{143763CA-C3D3-4F93-863F-63DD2CA1228C}']
procedure FirmaXML(const path_cert: WideString; const pass_cert: WideString;
const path_xml: WideString; const path_guardar: WideString); dispid 1610743808;
end;
CoCFXML = class
class function Create: _CFXML;
class function CreateRemote(const MachineName: string): _CFXML;
class function Create: IFXML;
class function CreateRemote(const MachineName: string): IFXML;
end;
TCFXML = class(TOleServer)
private
FIntf: _CFXML;
function GetDefaultInterface: _CFXML;
protected
procedure InitServerData; override;
function Get_ToString: WideString;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Connect; override;
procedure ConnectTo(svrIntf: _CFXML);
procedure Disconnect; override;
function Equals(obj: OleVariant): WordBool;
function GetHashCode: Integer;
function GetType: _Type;
property DefaultInterface: _CFXML read GetDefaultInterface;
property ToString: WideString read Get_ToString;
published
end;
procedure Register;
resourcestring
dtlServerPage = 'ActiveX';
dtlOcxPage = 'ActiveX';
implementation
uses System.Win.ComObj;
class function CoCFXML.Create: _CFXML;
begin
Result := CreateComObject(CLASS_CFXML) as _CFXML;
end;
class function CoCFXML.CreateRemote(const MachineName: string): _CFXML;
begin
Result := CreateRemoteComObject(MachineName, CLASS_CFXML) as _CFXML;
end;
procedure TCFXML.InitServerData;
const
CServerData: TServerData = (
ClassID: '{B00E8B03-B374-42C7-A76A-4D51545027E0}';
IntfIID: '{F363CEDB-6C8C-393B-B124-5B785E445D2A}';
EventIID: '';
LicenseKey: nil;
Version: 500);
begin
ServerData := @CServerData;
end;
procedure TCFXML.Connect;
var
punk: IUnknown;
begin
if FIntf = nil then
begin
punk := GetServer;
Fintf:= punk as _CFXML;
end;
end;
procedure TCFXML.ConnectTo(svrIntf: _CFXML);
begin
Disconnect;
FIntf := svrIntf;
end;
procedure TCFXML.DisConnect;
begin
if Fintf <> nil then
begin
FIntf := nil;
end;
end;
function TCFXML.GetDefaultInterface: _CFXML;
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 TCFXML.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
destructor TCFXML.Destroy;
begin
inherited Destroy;
end;
function TCFXML.Get_ToString: WideString;
begin
Result := DefaultInterface.ToString;
end;
function TCFXML.Equals(obj: OleVariant): WordBool;
begin
Result := DefaultInterface.Equals(obj);
end;
function TCFXML.GetHashCode: Integer;
begin
Result := DefaultInterface.GetHashCode;
end;
function TCFXML.GetType: _Type;
begin
Result := DefaultInterface.GetType;
end;
procedure Register;
begin
RegisterComponents(dtlServerPage, [TCFXML]);
end;
end.
Este es el procedimiento que deseo usar
Código Delphi
[-] IFXML = interface(IDispatch)
['{143763CA-C3D3-4F93-863F-63DD2CA1228C}']
procedure FirmaXML(const path_cert: WideString; const pass_cert: WideString;
const path_xml: WideString; const path_guardar: WideString); safecall;
end;