Windows DLL and Fatal Exit Code=0x001A








  PRODUCT  :  Borland C++                            NUMBER  :  644
  VERSION  :  All
       OS  :  PC DOS
     DATE  :  September 3, 1992                        PAGE  :  1/1

    TITLE  :  Windows DLL and Fatal Exit Code=0x001A




  Fatal Exit Code=0x001A is  not  documented by the SDK but what it
  seems to mean is that an attempt has been made to FreeLibrary() a
  DLL which has registered a  GLOBALCLASS window class still in use
  by another open window.

  For  example, a window class with  the  style  CS_GLOBALCLASS  is
  registered  in order to make a  custom  control  (like  "button",
  "checkbox",  etc.).    In the main program, a LoadLibrary() and a
  CreateWindow()  are executed to create a  child  window  of  that
  custom class.

  In a WM_DESTROY message handler, a FreeLibrary() is done followed
  by a PostQuitMessage(0).    Seems like a reasonable procedure but
  results in a Fatal Exit Code=0x001A from Windows when the  DLL is
  used. Puzzled?

  A careful  reading of the SDK reference indicates that WM_DESTROY
  is sent to a parent window BEFORE its children are destroyed.

  The library freed from memory by the FreeLibrary() call contained
  the necessary class information for the child window.  Since this
  is  all  happening  inside of a WM_DESTROY  handler,  this  child
  window  isn't  closed  yet  and  the  result  is the  Fatal  Exit
  Code=0x001A.

  One solution is to trap WM_CLOSE and close  the  affected windows
  prior to the FreeLibrary() call:

    case WM_CLOSE:
      DestroyWindow(handle of main window);
      DestroyWindow(handle of first child window);
      DestroyWindow(handle of second child window);
             :
             :
      FreeLibrary(library handle);
      break;




















  PRODUCT  :  Borland C++                            NUMBER  :  644
  VERSION  :  All
       OS  :  PC DOS
     DATE  :  September 3, 1992                        PAGE  :  2/1

    TITLE  :  Windows DLL and Fatal Exit Code=0x001A




  This  effectively forces Windows to close  all  of  the  children
  BEFORE  freeing the library that they are based on.

  DISCLAIMER: You  have the right to use this technical information
  subject to the terms  of  the  No-Nonsense License Statement that
  you received with  the  Borland product to which this information
  pertains.










































Comments

Popular posts from this blog

BOTTOM LIVE script

Fawlty Towers script for "A Touch of Class"