在asp object中不得有任何UI地操作。否则它执行了ShowMessage,将隐式的显示对话框。由于你看不见,无法关闭,导致程序实际。
如果生成文件很简单,试试下列代码:
var
  a: TStrings;a := TStringList.Create;
a.Text := 'hello, world';
a.SaveToFile('d:\test.txt');
a.Free;

解决方案 »

  1.   

    我试了你的代码,但是有错误,代码是这样的
    unit Unit1;{$WARN SYMBOL_PLATFORM OFF}interfaceuses
      ComObj, ActiveX, AspTlb, Project1_TLB, StdVcl;type
      Tcreate = class(TASPObject, Icreate)
      protected
        procedure OnEndPage; safecall;
        procedure OnStartPage(const AScriptingContext: IUnknown); safecall;
        procedure create; safecall;
      end;implementationuses ComServ;procedure Tcreate.OnEndPage;
    begin
      inherited OnEndPage;
    end;procedure Tcreate.OnStartPage(const AScriptingContext: IUnknown);
    begin
      inherited OnStartPage(AScriptingContext);
    end;procedure Tcreate.create;
    var
      a: TStrings;
    begin
    a := TStringList.Create;
    a.Text := 'hello, world';
    a.SaveToFile('d:\test.txt');
    a.Free;end;initialization
      TAutoObjectFactory.Create(ComServer, Tcreate, Class_create,
        ciMultiInstance, tmApartment);
    end.
    错误是这样的
    [Error] Unit1.pas(34): Undeclared identifier: 'TStrings'
    [Error] Unit1.pas(36): Undeclared identifier: 'TStringList'
    [Error] Unit1.pas(36): Missing operator or semicolon
    [Error] Unit1.pas(37): Missing operator or semicolon
    [Error] Unit1.pas(37): Statement expected, but expression of type 'String' found
    [Error] Unit1.pas(38): Missing operator or semicolon
    [Error] Unit1.pas(39): Missing operator or semicolon
    [Fatal Error] Project1.dpr(8): Could not compile used unit 'Unit1.pas'
    请你指点
      

  2.   

    Please use Delphi Help to find more information.