es funzt! keine ahnung ob des professionell gelöst ist, aber es geht erstmal
Delphi-Quellcode:
UNIT UContainer;
INTERFACE
USES
SysUtils;
VAR
pSelf:Pointer;
TYPE
TContainer=Class
Private
FFileName:
String;
//pLevel:Arary Of ^TLevel;
//Procedure HandleFile;
//..
Public
Class Function Alive:Boolean;
Constructor Create;
Destructor Destroy;
override;
Procedure Assign(
const FName:
String;AsReadOnly:Boolean);
Property FileName:
String Read FFileName;
//..
End;
IMPLEMENTATION
Class Function TContainer.Alive:Boolean;
Begin
Result:=pSelf<>
NIL
End;
Constructor TContainer.Create;
Begin
inherited Create;
pSelf:=Pointer(Self);
//..
End;
Destructor TContainer.Destroy;
Begin
//..
pSelf:=NIL;
inherited Destroy
End;
Procedure TContainer.Assign(
const FName:
String;AsReadOnly:Boolean);
Begin
If Not FileExists(FName)
Then Begin
//Destroy
Free
End
End;
END.
Delphi-Quellcode:
var
P:Pointer;
Begin
P:=TContainer.Create;
TContainer(P).Assign('C:\Non-Existing-File.txt',False);
If NOT TContainer(P).Alive Then Begin
ShowMessage('Klasse existiert nicht mehr!');
P:=NIL
End
End;
Danke an alle!
und gute n8