L
lmeagle01
Unregistered / Unconfirmed
GUEST, unregistred user!
请高手帮解决以下,问题如下:<br>~~~~~~~~~dll文件代码为:~~~~~~~~~~~~~<br>function DealErr(var errmsg:string;errNum:integer;errUnit:string;errMan:string):integer;stdcall;<br>var<br> frm_DealErr:Tfrm_DealErr;<br>begin<br> //Application.Initialize;<br> //Application.CreateForm(Tfrm_DealErr, frm_DealErr);<br><br> //frm_DealErr :=new Tfrm_DealErr(Application);<br><br> frm_DealErr:=Tfrm_DealErr.Create(Application);<br> Result:=0;<br><br> frm_DealErr.lErrNum.Caption:=IntToStr(errNum);<br> frm_DealErr.mErrText.Lines.Add(errmsg);<br><br> frm_DealErr.LogErr(errNum, errmsg, errUnit, errMan);<br> frm_DealErr.ShowModal;<br><br> Result:=frm_DealErr.frmResult;<br> DealErr:=Result;<br> frm_DealErr.Free;<br>// return Result;<br>end;<br>exports<br> DealErr;<br>begin<br>end.<br>dll文件内容主要就是那个函数<br>~~~~~~~~~~~~~~~~~下面是调用~~~~~~~~~~~~~~~~~~~~~~<br>procedure TForm1.Button1Click(Sender: TObject);<br>type<br> TDealErr=FUNCTION(errmsg:string;errNum:integer;errUnit,errMan:string):Integer;StdCall;<br>var<br> Th:THandle;<br> DealErr:TDealErr;<br>begin<br> Th:=LoadLibrary('DllUnit.dll');<br> if Th>0 then<br> begin<br> try<br> @DealErr:=GetProcAddress(Th,'DealErr');<br> if not (@DealErr=nil) then begin<br> DealErr('ASDFA', 21, trim(Form1.Caption), 'ASDF'); {调用TestC函数}<br> end else<br> ShowMessage('函数没有找到');<br> finally<br> FreeLibrary(Th); {释放DLL}<br> end;<br> end;<br>end;<br>~~~~~~~~结果报错~~~~~~~~~~~~<br>出现这种错误:尚未调用CoInitialize。<br>这是怎么回事,请高手帮助解答一下,如果觉得分不够,可再加!!!