E
eire
Unregistered / Unconfirmed
GUEST, unregistred user!
DLL中不能使用VARIANT类型作为参数传递?
---------------------------
Debugger Exception Notification
---------------------------
Project Project3.exe raised exception class EVariantBadVarTypeError with message 'Invalid variant type'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
//调用
function test(params:variant):boolean;external 'Project2.dll' name 'test';
implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
var
A:Variant;
begin
A := VarArrayCreate([0, 1], varVariant);
A[0] := '202.96.31.29';
test(a);
end;
end.
//DLL部分.
library Project2;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes,
Unit2 in 'dll/Unit2.pas';
{$R *.res}
exports
test;
begin
end.
// Unit2
function test(params:variant):boolean;stdcall;
implementation
function test(params:variant):boolean;
begin
showmessage(params[0]);
end;
---------------------------
Debugger Exception Notification
---------------------------
Project Project3.exe raised exception class EVariantBadVarTypeError with message 'Invalid variant type'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
//调用
function test(params:variant):boolean;external 'Project2.dll' name 'test';
implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
var
A:Variant;
begin
A := VarArrayCreate([0, 1], varVariant);
A[0] := '202.96.31.29';
test(a);
end;
end.
//DLL部分.
library Project2;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes,
Unit2 in 'dll/Unit2.pas';
{$R *.res}
exports
test;
begin
end.
// Unit2
function test(params:variant):boolean;stdcall;
implementation
function test(params:variant):boolean;
begin
showmessage(params[0]);
end;