From: jeroenp@rulfc1.LeidenUniv.nl (Jeroen W. Pluimers)
Newsgroups: comp.os.ms-windows.programmer.misc
Subject: Re: Books published disclosing undocumented features of Windows.
Date: 29 Sep 92 22:50:03 GMT
Organization: Dept. FMC, Gorlaeus Labs, Leiden University, The Netherlands

In article <1992Sep28.234946.8912@PacBell.COM> jcwasik@srv.PacBell.COM (Joe Wasik) writes:
>
>Could someone please post an example of a so called "feature" that I can
>take home and try out?  Or are these undocumented things mainly programmer
>hooks that MS expects to disappear in future releases?
>
Nope, here is something that both books document:

  {---------------------------------------------------------------------------
    ROUTINE :      GetHeapSpaces
    DESCRIPTION :  Get the amount of heap space from a module.
 
    IN :           Module: THandle - handle of the module to get info from
    RETURNS :              Longint - information on heap usage of module.
                           low word: number of bytes free in the modules heap
                           high word:size in bytes of the modules heap
 
    FROM :         Eric Lapaille (WINDOWS.PROG echo)
    ADDRESS :      2:295/27.2721
    DATE :         06 Jun 91  01:13:00
 
    MESSAGE :      This is an undocumented function that works for Windows 3.0.
   ---------------------------------------------------------------------------}
  function  GetHeapSpaces   (Module: THandle): longint;
                                                    External 'KERNEL' index 138;
 
  {---------------------------------------------------------------------------
    ROUTINE :      GetSystemRecources
    DESCRIPTION :  Get percentage free system resources just like the
                   program manager shows in it's 'about' dialog.
 
                   It follows the guidelines of the windows 3.0
                   SDK in the file TIPS.TXT:
 
                   1.8.3   Calculating Free System Resources
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                   The Free System Resources figure in Program Manager's
                   About dialog box is calculated as follows:
 
                   The calculation is the same for all modes (although
                   not done for real mode).
 
                   % free = min (% free of USER's heap, % free of GDI's heap)
 
                                              (Max heap size - heap used)
                   % free USER or GDI heap =  --------------------------- * 100
                                                     Max heap size
 
                   The maximum heap size is 64K less the sum of the size
                   of the static variables and the stack.
 
                   There is no external API defined to calculate these
                   values.
 
    RETURNS :      Word - percentage free heap space
 
    FROM :         Eric Lapaille (WINDOWS.PROG ECHO)
    ADDRESS :      2:295/27.2721
    DATE :         06 Jun 91  01:13:00
 
    MESSAGE :      I suppose this function will be very
                   different/obsolete in version 3.1 because each 3.1
                   app will have its own 64 K resource heap !
   ---------------------------------------------------------------------------}
   function GetSystemResources: Word;
   var
     wFree : word   ;
     wGDI  : word   ;
     wSize : word   ;
     wUser : word   ;
     dwInfo: longint;
   begin
     { get the information on the GDI module }
     dwInfo := GetHeapSpaces(GetModuleHandle('GDI'));
     wSize  := LongRec(dwInfo).Hi;
     wFree  := LongRec(dwInfo).Lo;
     wGDI   := (Longint(wFree) * 100) div wSize;
     { get the information on the User module }
     dwInfo := GetHeapSpaces(GetModuleHandle('User'));
     wSize  := LongRec(dwInfo).Hi;
     wFree  := LongRec(dwInfo).Lo;
     wUser  := (Longint(wFree) * 100) div wSize;
     If wGDI < wUser then
       GetSystemResources := wGDI
     else
       GetSystemResources := wUser;
   end;
 

--
    o _   _  _   _   _             voice: +31-2522-20908 (19:00-24:00 UTC)
   / (_' |  (_) (_' | |            snail: P.S.O.
__/                                       attn. Jeroen W. Pluimers
                                          P.O. Box 266
jeroenp@rulfc1.LeidenUniv.nl              2170 AG Sassenheim
jeroen_pluimers@f256.n281.z2.fidonet.org  The Netherlands