应该是可以的,我做过类似的工作,我那时是把一个session作为参数传入DLL,
同时应该把主窗体的HANDLE也要传入,或其他要用的HANDLE传入,DLL设定一个PARENT,   这个需要好好研究一下

解决方案 »

  1.   

    可以把form1的指针作为参数传进去
    然后遍历该form上的控件 如果是TEdit 则读出其text值个人认为还是把dll的通用性做的强一些的好
      

  2.   

    我做了一个测试代码,是这样写的,但是程序运行时出错,请大家帮忙看看DllDemo.dpr代码library DllDemo;
    uses
      SysUtils,
      Classes,
      DllUnit in 'DllUnit.pas';exports
        ShowEdit;{$R *.res}begin
    end.
    ---------------------------
    DllUnit.pas代码unit DllUnit;interface
    uses
       Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;procedure ShowEdit(Form:TForm);export;
    implementation
    procedure ShowEdit(Form:TForm);
    var i:integer;
        CmpTemp:TComponent;
    begin
        for i:=0 to Form.ComponentCount-1 do
        begin
            CmpTemp:=Form.Components[i];
            //showmessage(CmpTemp.Name);
            if (CmpTemp.ClassName='TEdit') then
                Showmessage((CmpTemp as TEdit).Text);
        end;
    end;
    end.-------------------------------------
    调用程序的代码
    unit ClientFrm;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Edit1: TEdit;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation
    procedure ShowEdit(Form:TForm);external 'DllDemo.dll'
    {$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
        ShowEdit(Form1);
    end;end.运行调用程序的时候,出现错误:Exception EInvalidCast in module DllDemo.dll at 00058A88.
    请大家帮忙解决啊
      

  3.   

    我的代码和你有些类似,我是传的paintbox,dll画图
    可时关闭的时候,内存地址错,
    留下你的email,我发给你,看看我们一不一样
      

  4.   

    [email protected]
    谢谢,非常感谢
      

  5.   

    把Showmessage((CmpTemp as TEdit).Text);
    改为Showmessage(TEdit(CmpTemp).Text);
      

  6.   

    dll中不能用as操作
    不能调用非虚方法