这段代码写在DLL中竟然不能编译,郁闷
begin
    with  TStringList.Create   do   try
      Text :=  Clipboard.AsText ;
    finally
    Free;
end;在FORM中可以编译,为什么呀?
我想做的是调用Dll读取剪切板的内容,求高手帮忙怎么改才能实现这个功能?

解决方案 »

  1.   

    有什么异常提示,是不是没有uses Clipbrd?
      

  2.   

      [错误] Unit1.pas(30): Undeclared identifier: 'TStringList'
      [错误] Unit1.pas(30): 'DO' expected but identifier 'Create' found
      [错误] Unit1.pas(31): '(' expected but ':=' found
      [错误] Unit1.pas(31): Missing operator or semicolon就是不能编译
      

  3.   

    uses Classes;begin 
        with  TStringList.Create   do   try 
          Text :=  Clipboard.AsText ; 
        finally 
          Free; 
        end;
    end; 
      

  4.   

    对对~ 
    我刚刚自己也发现了,谢谢楼上!感觉自己太粗心了现在又有新问题出现了,怎么样在dll打开保存对话框?先前的一个SaveDialog在dll中不能用
      [错误] Unit1.pas(40): Undeclared identifier: 'SaveDialog1'
      [错误] Unit1.pas(42): Undeclared identifier: 'FileName'
      [错误] Unit1.pas(43): Undeclared identifier: 'DefaultExt'
      [错误] Unit1.pas(44): Undeclared identifier: 'Filter'
      

  5.   

    unit Unit1;{$WARN SYMBOL_PLATFORM OFF}interfaceuses
      ComObj, ActiveX, Project1_TLB, StdVcl,
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls,Clipbrd;type
      Tlinnk = class(TAutoObject, Ilinnk)
      protected
        procedure HtoT; safecall;
        procedure Method1; safecall;
        procedure Copytotxt; safecall;  end;implementationuses ComServ;procedure Tlinnk.Copytotxt;
    var
      F: TextFile;
      txt_Name : String;
      begin
        with  TStringList.Create   do   try
                Text :=  Clipboard.AsText ;
                txt_Name := Strings[0];      finally
              Free;
          end;    With  SaveDialog do
           Begin
            FileName := txt_Name ;
            DefaultExt := '.txt';
            Filter := '.txt|.txt'
          end;    if  SaveDialog1.execute   then
        begin
        AssignFile(F,SaveDialog1.FileName);
          with  TStringList.Create   do   try
                Text :=  Clipboard.AsText ;
                SaveToFile(SaveDialog1.FileName);
          finally
              Free;
          end;
        end;
      end;initialization
      TAutoObjectFactory.Create(ComServer, Tlinnk, Class_linnk,
        ciMultiInstance, tmFree);
    end.
      

  6.   

    晕!
    SaveDialog1 还没有被定义啊,然后在使用之前还要 Create 的。type
      Tlinnk = class(TAutoObject, Ilinnk)
      private
        SaveDialog1: TSaveDialog;   //这里定义
      protected
        procedure HtoT; safecall;
        procedure Method1; safecall;
        procedure Copytotxt; safecall;
      

  7.   

    牛B,OK啦,谢谢你哦~ 不知道可不可私下聊聊,