Jon Robertson
2005-02-16 16:52:08 UTC
I just came across this in the Delphi 6 Help for the Unassigned
constant. I feel like I'm missing something, because this disputes
something I thought I understood about Variants and Automation for a
long time...
"You can make a variant unassigned by assigning the Unassigned constant
to it. *This is useful with variants referencing OLE Automation Objects
that you want to keep "alive" until another value is assigned to the
variant.*"
Given the following code:
var
WordApp: OleVariant; // long lifetime, say a class field
begin
WordApp := CreateOleObject('Word.Application');
// blah blah
WordApp.Quit;
WordApp := Unassigned; // What happens here?
What's the difference between
WordApp := Unassigned;
and
WordApp := Null;
I know the difference between a Null value and Unassigned. But what's
the difference to OLE Automation? Does one hold onto resources where
the other doesn't?
I feel like a 1st grader all over again...
constant. I feel like I'm missing something, because this disputes
something I thought I understood about Variants and Automation for a
long time...
"You can make a variant unassigned by assigning the Unassigned constant
to it. *This is useful with variants referencing OLE Automation Objects
that you want to keep "alive" until another value is assigned to the
variant.*"
Given the following code:
var
WordApp: OleVariant; // long lifetime, say a class field
begin
WordApp := CreateOleObject('Word.Application');
// blah blah
WordApp.Quit;
WordApp := Unassigned; // What happens here?
What's the difference between
WordApp := Unassigned;
and
WordApp := Null;
I know the difference between a Null value and Unassigned. But what's
the difference to OLE Automation? Does one hold onto resources where
the other doesn't?
I feel like a 1st grader all over again...
--
Jon Robertson
Borland Certified Advanced Delphi 7 Developer
MedEvolve, Inc
http://www.medevolve.com
Jon Robertson
Borland Certified Advanced Delphi 7 Developer
MedEvolve, Inc
http://www.medevolve.com