I was reading Mastering Delphi 2005 the other day (I'm working my way through it - from what I understand there arn't any good D2006 books as yet). Anyway there was a discussion on how initialize and finalize operate under .Net. Given the very non-object orientatedness of initialize and finalize it's pretty impressive how the Borland (DevCo) team were able to get so much of the Delphi functionality into .Net. I say this not having written a Delphi.net app however.

I've certainly learnt quite a bit from reading it as I've gone from D6/7 -> D2006 (even though I'm less than a third of the way through it).

Alister

Paul A Norman wrote:
Point of interest - something basic for me and possibly others to learn.
I've only ever used unit 'initialization and finalization' "blindly" since Delphi 3 days for Activex / OLE type stuff, as just someting that you have to do - without understanding. initialization
  OleInitialize(nil);
finalization
  OleUninitialize;
Otherwise I've used the *onFormComplete* and *onDestroy* to set intial stuff up and then release stuff. But I am guessing that *Finailization* is a better place to release stuff (*help avoid memoery leakage under certain circumstances*?), but *Initialization* would have to be used for *Finalization* to be acceptable.. I've read the Delphi 2005 help and googled a bit, but am not yet sure just what sorts of code can be put in the Initialization and Finalization.

   1. Can anything declared as a unit *VAR* or *CONST* be dealt with
      or used in Initialization ? it appears so to me from what I see
      (below).
   2. Could I safely .*create* and .*free* objects respectively?

I was reading through a *Unit* the other day and saw all sorts of things in *Initialization* there that surprised me. Can any one please point me to a good reference on this, or in our new learning sharing attitude, explain it for every ones benefit here? initialization
  FillChar(BrowserData,SizeOf(BrowserData),#0);
  OleInitialize(nil);
  New(PtrWGUID);
  New(PtrMGUID);
  New(PtrDGUID);
  PtrWGUID^:=CGID_WebBrowser;
  PtrMGUID^:=CGID_MSHTML;
  PtrDGuid:=PGUID(nil);
  GetBrowserData(BrowserData);
  IEStr:=IEVerStr;
  OnMessageCompNo:=0;

finalization
  Dispose(PtrWGUID);
  Dispose(PtrMGUID);
  Dispose(PtrDGUID);
  OleUninitialize;

end.
------------------------------------------------------------------------

_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi


--
Alister Christie
Computers for People
Ph: 04 471 1849 Fax: 04 471 1266
http://www.salespartner.co.nz
PO Box 13085
Johnsonville
Wellington
_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to