contents   index   previous   next



Release

 

f90VB Modules

 

f90VBDefs, f90VBVariants, f90VBAutomation

Summary

 

Releases the interface to an object, and unloads the object from memory if the reference-counter of the object reaches zero. This is the standard method to destroy objects created with subroutine CreateOleObject, CreateRemoteOleObject, CreateComObject and CreateRemoteComObject.

Syntax

 

subroutine Release (VarObj)

type(VARIANT),intent(inout)::  VarObj

Arguments

 

VarObj [Input]

A variant containing a reference to the IUnknown or IDispatch interface of an object.

Comments

 

If the reference-counter of the object reaches zero after a call to subroutine Release, the object is destroyed and unloaded from memory. An object can have more than one reference (for example, calling VariantCopy for a source variant containing an object reference, will increase by one the reference-counter of the object). To remove the object from memory, you must call Release on each variant containing an interface to the object. Calling subroutine VariantClear on a Variant variable containing a reference to an object has the same effect as calling Release.

Examples

 

program ReleaseExample

 

!Illustrates the use of Release subroutine

!Copyright 1999-2000, Canaima Software

!All rights reserved

 

!load f90VBModules

use f90VBDefs

use f90VBVariants

use f90VBAutomation

implicit none

 

type(VARIANT)::Conn1, Conn2

type(VARIANT)::ConnStr,TmpVar

integer(HRESULT_KIND)::iRet

 

!Initialize COM/OLE

call OleInitialize()

 

!Create an ADO Connection Object

Conn1 = CreateOleObject('ADODB.Connection')

 

!Now, Conn2 holds another reference to the

!IDispatch interface of the Connection object

call VariantCopy(Conn1,Conn2)

 

!You can check that the Connection object is

!still loaded after this Release statement

call Release(Conn1)

 

!This release sets the reference counter of

!the connection object to zero, the object

!is unloaded from memory

call Release(Conn2)

 

!UnInitialize COM/OLE

call OleUnInitialize()

 

stop

end

Related Topics

 

For information about: See:
Increasing the reference-counter of an object AddRef

 


StrToGUID