动态链接库返回字符串的问题,有程序.
function GetSysParamEx(ParamKey:PChar):PChar;stdcall;
var
cnn:TAdoConnection;
ads:TAdoDataSet;
begin
cnn:=TADOConnection.Create(Application);
cnn.ConnectionString:= GetConnectionString;
cnn.LoginPrompt:=false;
cnn.Open;
ads:=TAdoDataSet.Create(Application);
ads.Connection:=cnn;
ads.Close;
ads.CommandText:='select * from SSysParams where ParamKey=''MaxConsumption''';
ads.Open;
if ads.RecordCount>0 then
begin
result:=PChar(ads.FieldByName('ParamValue').AsString);
end
else
result:='';
ads.Free;
cnn.Free;
end;
为什么调用的时候返回值都是为空?