用CreateOleObject创建的对象是否需要显式地释放?怎样释放?

解决方案 »

  1.   

    procedure tbutton1clicek(sendor.tobject); 
    var
    myexcel:variant;
    begin
      myexcel:=createoleobject('excel.application');
      myexcel.visible:=false;
      ...
      //释放时用以下语句
      myexcel:=unassigned;
    end;
      

  2.   

    楼上的老兄:myexcel.visible :=false;我的好象不行,不定要true。
      

  3.   

    直接给myexcel :=nil就可以了
      

  4.   

    谢谢各位!“you can release the interface by assigning the Unassigned constant to that Variant”--Delphi在线帮助本来是有说明的,我没注意到。