contents   index   previous   next



COMReleaseObject()

syntax:

COMReleaseObject(COMObject)

where:

COMObject - An object returned with COMCreateObject() or COMGetObject().

 

return:

none

 

description:

Release all internal locks on a COM object created with COMCreateObject() or COMGetObject().

 

In most cases a lock is held on a COMObject until the script is no longer using the object and the internal script-engine garbage collector has run and freed the object. Sometimes you will want the COM object to be releases earlier, such as if the COM object can only work with a limited number of clients--in this case calling COMReleaseObject will force all locks on the COM object to be released. After COMReleaseObject and calls using the COMObject will throw an exception.

 

see:

#link <comobj>, COM object, COMCreateObject, COMGetObject

 

example:

   /*

      This is similar to the example shown above

      for COMCreateObject.  In this case the

      object will be released..

   */

 

#link "comobj"

 

var wd;

wd = COMCreateObject("Word.Application");

wd.visible = true;

 

COMReleaseObject(wd);

 

try {

   wd.visible = false; // this will fail because

                       // the object is released

}

catch(e)

{

   // this will be caught because the wd object

   // was used after it was released

}