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);
OleInitialize(nil);
finalization
OleUninitialize;
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.
- 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).
- 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.
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
