M
msglzcx
Unregistered / Unconfirmed
GUEST, unregistred user!
library TEST;<br><br>uses<br> adodb,db,ActiveX;<br><br>var<br> AdoCon: TADOConnection;<br> AdoQry: TADOQuery;<br><br>{$R *.res}<br><br>procedure DllExit(Reason: integer);<br>begin<br> case Reason of<br> 1 : begin<br> end; <br> 0 : begin<br> AdoQry.Close;<br> AdoQry.Free; //这里报错 用AdoQry := nil;就没事<br> //AdoCon.Close;<br> //AdoCon.Free;<br> CoUninitialize;<br> end;<br> end;<br>end;<br><br>procedure LoadShow(aInput: pchar;var aOutPut: pchar);stdcall;<br>begin<br> AdoQry.Close;<br> AdoQry.SQL.Clear;<br> AdoQry.SQL.Add('declare @out varchar(1000)');<br> AdoQry.SQL.Add('EXEC RRC_TEST '''+ aInput +''',@out output');<br> AdoQry.SQL.Add('select @out as Out');<br> AdoQry.Open;<br> aOutPut := PChar(AdoQry.Fields[0].Text);<br>end;<br><br>exports<br> LoadShow;<br><br>begin<br> CoInitialize(nil);<br> AdoCon := TADOConnection.Create(nil);<br> AdoQry := TADOQuery.Create(nil);<br> try<br> AdoCon.ConnectionString := 'Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=sa;Initial Catalog=rainrest;Data Source=10.1.18.56';<br> AdoCon.LoginPrompt := False;<br> AdoCon.Connected := True;<br> AdoQry.Connection := AdoCon;<br> except<br> AdoQry.Free;<br> AdoCon.Free;<br> end;<br> DllProc := @DllExit;<br> DllExit(1);<br>end.