H
hyxic
Unregistered / Unconfirmed
GUEST, unregistred user!
Dll代码如下:
type
arg=array of array of PChar;
{$R *.res}
function GetInsObject:arg;stdcall;
var
i,n:integer;
cmp:TComponent;
cmpChk:TCheckBox;
cmpCbx:TComboBox;
CurVar:arg;
begin
n:=0;
Result:=Null;
Try
fInsObject:=fInsObject.Create(Application);
Try
//检查是否存在所选的组件
for i:=1 to 21 do
begin
cmp:=cmpChk.FindComponent('c'+IntToStr(i));
If (not Assigned(cmp)) or (not (cmp is TCheckBox)) then
begin
Result:=Null;
SysUtils.Abort
end
else
begin
cmpChk:=TCheckBox(cmp);
if cmpChk.Checked then
inc;
end;
end;
SetLength(CurVar,n,1);
if fInsObject.ShowModal=mrOK then
begin
for i:=1 to 21 do
begin
//cmp:=cmpCbx.FindComponent('c'+IntToStr(i));
cmpChk:=TCheckBox(cmp);
if cmpChk.Checked then
CurVar[i-1][0]:=PChar(cmpChk.Caption);
cmp:=cmpCbx.FindComponent('m'+IntToStr(i));
If (not Assigned(cmp)) or (not (cmp is TComboBox)) then
begin
Result:=Null;
SysUtils.Abort
end
else
begin
cmpCbx:=TComboBox(cmp);
CurVar[i-1][1]:=PChar(cmpCbx.Text);
end;
end;
Result:=CurVar;
end;
finally
fInsObject.Free;
end;
Except
On E:Exception Do
MessageDlg('动态链接库DLL发生错误:'+E.Message,mtError,[mbOK],0);
End;
end;
exports
GetInsObject name 'GetInsObject' resident;
调用代码如下:
type
arg=array of array of PChar;
var
myHandle:THandle;
Func:TFarProc;
FuncStr:function ():arg;stdcall;
dd:arg;
begin
inherited;
myHandle:=LoadLibrary('SysDll/InsObject.dll');
If myHandle>0 then
try
Func:=GetProcAddress(myHandle,PChar('GetInsObject'));
if Func<>nil then
begin
FuncStr:=Func;
dd:=FuncStr();
End;
finally
FreeLibrary(myHandle);
end;
end;
type
arg=array of array of PChar;
{$R *.res}
function GetInsObject:arg;stdcall;
var
i,n:integer;
cmp:TComponent;
cmpChk:TCheckBox;
cmpCbx:TComboBox;
CurVar:arg;
begin
n:=0;
Result:=Null;
Try
fInsObject:=fInsObject.Create(Application);
Try
//检查是否存在所选的组件
for i:=1 to 21 do
begin
cmp:=cmpChk.FindComponent('c'+IntToStr(i));
If (not Assigned(cmp)) or (not (cmp is TCheckBox)) then
begin
Result:=Null;
SysUtils.Abort
end
else
begin
cmpChk:=TCheckBox(cmp);
if cmpChk.Checked then
inc;
end;
end;
SetLength(CurVar,n,1);
if fInsObject.ShowModal=mrOK then
begin
for i:=1 to 21 do
begin
//cmp:=cmpCbx.FindComponent('c'+IntToStr(i));
cmpChk:=TCheckBox(cmp);
if cmpChk.Checked then
CurVar[i-1][0]:=PChar(cmpChk.Caption);
cmp:=cmpCbx.FindComponent('m'+IntToStr(i));
If (not Assigned(cmp)) or (not (cmp is TComboBox)) then
begin
Result:=Null;
SysUtils.Abort
end
else
begin
cmpCbx:=TComboBox(cmp);
CurVar[i-1][1]:=PChar(cmpCbx.Text);
end;
end;
Result:=CurVar;
end;
finally
fInsObject.Free;
end;
Except
On E:Exception Do
MessageDlg('动态链接库DLL发生错误:'+E.Message,mtError,[mbOK],0);
End;
end;
exports
GetInsObject name 'GetInsObject' resident;
调用代码如下:
type
arg=array of array of PChar;
var
myHandle:THandle;
Func:TFarProc;
FuncStr:function ():arg;stdcall;
dd:arg;
begin
inherited;
myHandle:=LoadLibrary('SysDll/InsObject.dll');
If myHandle>0 then
try
Func:=GetProcAddress(myHandle,PChar('GetInsObject'));
if Func<>nil then
begin
FuncStr:=Func;
dd:=FuncStr();
End;
finally
FreeLibrary(myHandle);
end;
end;