dll问题,如何返回string

来源:互联网  时间:2016/8/26 5:45:38

关于网友提出的“ dll问题,如何返回string”问题疑问,本网通过在网上对“ dll问题,如何返回string”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: dll问题,如何返回string
描述:

//////////dll中是这样声明的:
function ReadDbInfo(section:string;databasetype:integer):string;
var
   MyIniFile: TIniFile;
   PassWord,UserID,DataSource,Defaultdb,ss:string;
begin
   MyIniFile := TIniFile.Create('C:\CJSMS\DBINFO.ini');
   if databasetype=1 then
   begin
      with MyIniFile do
      begin
       Password:=ReadString(Section, 'PassWord','000000');
       userid:=ReadString(Section, 'USERID','000000');
       DATASOURCE:=ReadString(Section, 'DATASOURCE','000000');
      end;
      result:='Provider=MSDAORA.1;Password='+PASSWORD+
        ';User ID='+USERID+';Data Source='+
        DATASOURCE+';Persist Security Info=True';
   end
   else begin
      with MyIniFile do
      begin
       Password:=ReadString(Section, 'PassWord','000000');
       userid:=ReadString(Section, 'USERID','000000');
       DATASOURCE:=ReadString(Section, 'DATASOURCE','000000');
       DEFAULTDB:= ReadString(Section, 'DATABASE','000000');
      end;
     result:='Provider=SQLOLEDB.1;Password='+PASSWORD+';Persist Security Info=True;User ID='+USERID+
       ';Initial Catalog='+DEFAULTDB+';Data Source='+DATASOURCE;
   end;
   MyIniFile.Free;
   
end;
//////////////////////unit中的声明及引出
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
Function ReadDBinfo(section:string;databasetype:integer):string;
var
  Form1: TForm1;
implementation
function ReadDBinfo; external 'sms' index 4;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
 memo1.Lines.Add(readdbinfo('Ora_48',1));
end;
end.
调用时出现错误,"Invalid pointer operation"

上一篇大哥们帮忙看看这段代码
下一篇dll的参数可以是ADO对象吗?
明星图片
相关文章
《 dll问题,如何返回string》由码蚁之家搜集整理于网络,
联系邮箱:mxgf168#qq.com(#改为@)