我在Dll中写:
function Ms(s: string):string;stdcall;
var str : string;
begin
  Application.MessageBox('ss','aa',MB_OK);
end;在程序中是这样调用的:
procedure TForm.Button2Click(Sender: TObject);
begin
  Ms(Edit.Text);
end;可是我在关闭MessageBox时,屏幕会闪。
是什么原因?请问:xiaoxiaobai(小白.net),80分够吗?不够再加!谢谢

解决方案 »

  1.   

    你DLl里的Result呢?
    另在Dll中不要用String,改为PChar
      

  2.   

    不好意思写错了:
    function Ms(s: string):string;stdcall;
    begin
      Application.MessageBox(pchar(s),'aa',MB_OK);
    end;在程序中是这样调用的:
    procedure TForm.Button2Click(Sender: TObject);
    begin
      Ms(Edit.Text);
    end;
      

  3.   

    这样就没有问题了~function Ms(hApp:THandle; s: string):string;stdcall;
    begin
       Application.Handle := hApp;
       Application.MessageBox(pchar(s),'aa',MB_OK);
    end;在程序中是这样调用的:
    procedure TForm.Button2Click(Sender: TObject);
    begin
      Ms(Handle, Edit.Text);
    end;
      

  4.   

    在DLL中要传入字符串,最好用PCHAR()
    否则要引用一个单元,文件加大.
      

  5.   

    谢谢大家解答!
    xiaoxiaobai(小白.net)可不可以告诉我为什么要这样写?