home *** CD-ROM | disk | FTP | other *** search
/ BUG 4 / BUGCD1997_05.BIN / aplic / clip4win / clip4win.exe / C4W30E.HUF / SOURCE / DLLFREE.PRG < prev    next >
Text File  |  1996-01-10  |  837b  |  42 lines

  1. //    DLLFree.prg - free a DLL
  2. //
  3. //    Written by:    John M. Skelton,  Apr-95.
  4. //
  5. //    Copyright (C) 1995 Skelton Software, Kendal Cottage, Hillam, Leeds LS25 5HP, UK.
  6. //    All Rights Reserved.
  7. //
  8. //    Part of Clip-4-Win.
  9.  
  10. #include "dll.ch"
  11.  
  12. function main(cDLL)
  13. local    hLib, c, n
  14. local    hWnd := WinSetup("DLLFree", "DLLFree")
  15.  
  16. if (hLib := LoadLibrary(cDLL)) < 32
  17.     ? "DLL ", cDLL, " not found!!"
  18.     wait
  19.     quit
  20. endif
  21.  
  22. n = GetModuleUsage(hLib) - 1
  23. ? "Usage count =", n
  24.  
  25. wait "Do not abuse this!  Free it (Y/N) ? " to c
  26.  
  27. if lower(c) == "y"
  28.     do while n-- != 0
  29.         FreeLibrary(hLib)
  30.     enddo
  31.     if (n := GetModuleUsage(hLib) - 1) != 0
  32.         ? "ERROR - not freed correctly.  Final usage count =", n
  33.         wait
  34.     endif
  35. endif
  36. FreeLibrary(hLib)
  37. return nil
  38.  
  39.  
  40. _DLL function GetModuleUsage(hInst as int) as int Pascal:KERNEL.GetModuleUsage
  41.  
  42.