Can I use .Create(Nil) instead of .Create(Application)

Viewed 2068

I have a unit which has a variable of TComponent, I create this component on Initialization of the unit like following :

var
  XComp: TComponent;
.
.
.
.

initialization
begin
  XCom := TComponent.Create(Application);
end;

after installing the unit when I close Delphi it gives me an Access Violation error message (EAccessViolation)

but when I changed my creator to be as following

initialization
begin
  XCom := TComponent.Create(nil);
end;

everything went fine...I would like to know the difference? and what is the better?

note : the error only appears when closing the delphi (means at design time).

Thanks.

2 Answers
Related