Freeing OleVariant after using CreateOleObject

Here is a simple code:

procedure Test;
  V: OleVariant;
  V := CreateOleObject('ADOX.Catalog');
    // do something with V...
    V := Unassigned; // do we need this?

Do we need to use the V := Unassigned code at the end, or will V is free when it exists the scope of Test procedure? in VB you set the variable to Nothing. do we need to do the same here? ie:

function VarNothing: IDispatch;
// emulate VB function SET VarX = Nothing
  Retvar: IDispatch;
  Retvar := nil;
  Result := Retvar;

// do something with V and finally:
V := VarNothing;


OleVariant will release the interface automatically when it goes out of scope. You can assign a new value to the OleVariant if you need it to be released sooner.

Need Your Help

media queries and to adapt the ready made site

javascript html css

I am now having to adjust my current site to fit it into a smaller desktop screen size. It is viewable on all screens, only with smaller ones like 14", it creates a scrollbar on the left and is not

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.