[OT] DLL Handles

Huisingh, Larry R Larry_R_Huisingh at rl.gov
Tue Jul 15 14:27:00 EDT 2003


> Howdy List:
> 
> Can someone experienced in Windows DLLs offer a response to the
> following?...
> 
> (I'm off in the weeds here since I don't typically do this 
> kind of stuff.)
> 
> I've got an installer script that calls a DLL repeatedly within a repeat
> loop to grab current system information (processes). What is the proper
> point to call closeHandle: within the script's repeat loop, at the end,
and
> then get a new handle from the DLL at the beginning of the loop, or should
I
> call closeHandle outside the repeat loop once the script has finished
> running? 

Is this an installer script written in MetaCard or some other language?
Even if you are using an external it doesn't mean you can't have a build up
of handles.  My MC app uses an external DLL and I need to close handles
properly.

As for closing handles, it depends on what you do with the handles and if
you get a new handle each time in the repeat loop.  If you get a new handle
during each loop iteration then you should close that particular handle at
the end of each loop (assuming you don't need the handle for some other task
later).  If you don't close the handle you will incur a buildup of open
handles which could theoretically crash your app.  [If you invoke the Task
Manager in 2000/XP you can ask that it show you the handle count for all
processes on the "Processes" tab.  I had an app or two that didn't close
handles properly and that "handle count" just kept skyrocketing the longer
the program ran.]

If you have more questions or details feel free to write me off-line.

Larry Huisingh
> 
> Thanks for any suggestions.
> 
> Regards,
> 
> Scott Rossi



More information about the metacard mailing list