try form1.show;
except form1:=tform1.create(nil);
form1.show;
end;

解决方案 »

  1.   

    if form1=nil then
    ShowMessage('空');
      

  2.   

    用Free方法释放一个对象后并不会把对象赋为nil, 必须手工赋值,如:
      form1.free
      form1 := nil
    之后就可以用assigned函数了
      

  3.   

    在Delphi中help提到
    Note:Assigned can't detect a dangling pointer--that is, one that isn't nil but no longer points to valid data. For example, in the code example for Assigned, Assigned won't detect the fact that P isn't valid.
    被free掉的from的指针不为nil,但是它的data is not valid.
    如果人工调用form1 := nil。
    那样使用assigned(P)就不会出错。
    我在程序中也遇到这样的问题。但是通常搂主的问题是不会发生的。程序员有义务保证自己写的东西在逻辑上保持一致。如果free了,还要调用诸如show之类的函数,说明自己也不知道自己在干什么。
      

  4.   

    Note: Assigned can't detect a dangling pointer--that is, one that isn't nil but no longer points to valid data. For example, in the code example for Assigned, Assigned won't detect the fact that P isn't valid.