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