如果你要使用string在DLL中作参数传递,请务必在Program文件的uses子句中首先引用ShareMem单元,则可以保证DLL的代码能正确的处理string类型的参数了。

解决方案 »

  1.   

    好像跟string没关系,
    我有一个列子这样做的,我作就不行,
    再说我去掉handle,能正常运行,
    看样子,问题在handle上,
      

  2.   

    在动态库中这样定义
    library Mytest
    procedure ShowMyForm(handle:THandle;Caption:Pchar);stdcall
    var frm:TYourForm;
    begin
      frm:=TYourForm.Create(handle);
      try
        frm.Caption:=strPas(Caption);
        frm.showmodal;
      finally
        frm.free;
       end;
    end;
    exports
      ShowMyForm;
    begin
    end;
      

  3.   

    library Ickcxfx;
         
    uses
      WF_CARDU in 'WF_CARDU.pas' {WF_CARD},
      DmIckDll in 'DmIckDll.pas' {DMICK: TDataModule},
      WPREVIEW in 'WPREVIEW.pas' {WPREVIEWF};exports
      ICKYYFX;
      
    {$R *.RES}begin
    end.
    在  WF_CARDU in 'WF_CARDU.pas' {WF_CARD},中:procedure ICKYYFX(APPHAND:THANDLE;BH,PASS,PATH,BC:STRING;BBRQ:TDATE;key:string);
    begin
    //  Application.Handle := AppHAND;//去掉本行,及procdure 中APPHAND反而能行  DMICK:=TDMICK.Create(APPLICATION);
      DMICK.DB_ICKDLL.Connected:=true;
      WF_CARD :=TWF_CARD.Create(Application);
      WF_CARD.ShowModal;
      WF_CARD.Free;
    end;
      

  4.   

    我的一个程序:function ShowCalculator(mainApp:TApplication;calcForm:TForm;var calcValue:real):boolean;stdcall;
    begin
      if calcForm=Nil then
        calcForm:=TfrmCalculator.Create(mainApp);
      calcForm.ShowModal;
      calcValue:=calcResult;
      calcForm:=Nil;
      Result:=calcTransMode;
    end;
      exports ShowCalculator;
      function ShowCalculator(application:TApplication;calcForm:TForm;var calcTransValue:real):boolean;stdcall;external 'CalculatorDll.Dll';        if ShowCalculator(application,calcForm,calcTransValue) then
              Face.DisplayFocus^.Text :=FloattoStr(calcTransValue);
      

  5.   

    to xooo(xooo)参数改用TApplication试试