I think I know what the answer will be already but maybe someone knows alternatives.
What I would like to do is prevent the user of a library from calling the destructor of a certain classes. The use case is when the ownership is not on the user's end at all or when the user should not destroy the instance themselves but only mark it for deletion. In both cases it would be possible to at least give appropriate run time errors but better would be to have compiler errors.
You can't. Even if you'd manage to "hide"
Destroy for your class simply calling
Free will result in the correct virtual method to be called. At worst you'll have memory leaks (e.g. if you used
reintroduce and thus the normal, virtual
Destroy won't call your destructor).
If you want better control over the lifetime of your instances use interfaces as
eljo suggested. You can then make sure that the instance isn't destroyed until you want it to. Though you must only pass out the interface then! And you might want to override
QueryInterface as otherwise a user can do
IntfVar as TMyClass to get the class instance again (though to be fair, doing that would be "shooting oneself in the foot" and why would one do that?).