home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol10n20.zip / WVSP.PAS < prev   
Pascal/Delphi Source File  |  1991-10-21  |  1KB  |  51 lines

  1. WVSP.PAS
  2.  
  3.  
  4.  
  5. PROGRAM wVsp;
  6. USES WinCRT, Strings, WinProcs;
  7.  
  8. VAR
  9.   Data : Record
  10.     CASE Boolean OF
  11.       TRUE  : (L : LongInt);
  12.       FALSE : (Free, Avail, Pct : Word);
  13.   END;
  14.   DatStr : ARRAY[0..255] OF Char;
  15. CONST
  16.   PC : PChar = 'Turbo Pascal';
  17.  
  18.   {Undocumented Kernel function #138}
  19.   FUNCTION GetHeapSpaces(hModule : Word) : LongInt; FAR;
  20.   External 'KERNEL' Index 138;
  21.  
  22. BEGIN
  23.   Data.L := GetHeapSpaces(GetModuleHandle('GDI'));
  24.   Data.Pct := (LongInt(Data.Free) * 100) DIV Data.Avail;
  25.   wvsprintf(DatStr,'GDI has %u heap bytes free out of '+
  26.                    '%u - %u%% free.', Data);
  27.   WriteLn(DatStr);
  28.   Data.L := GetHeapSpaces(GetModuleHandle('USER'));
  29.   Data.Pct := (LongInt(Data.Free) * 100) DIV Data.Avail;
  30.   wvsprintf(DatStr,'USER has %Xh heap bytes free out of '+
  31.                    '%Xh - %u%% free.', Data);
  32.   WriteLn(DatStr);
  33.   wvsprintf(DatStr,'Again, that''s %u%%', Data.Pct);
  34.   WriteLn(DatStr);
  35.   WriteLn;
  36.   wvsprintf(DatStr,'The PChar, padded to 20 chars with '+
  37.                    'zeroes, is "%020s"', PC);
  38.   WriteLn(DatStr);
  39.   wvsprintf(DatStr,'Its address, treated as a hex '+
  40.                    'LongInt, is %08lx', PC);
  41.   WriteLN(DatStr);
  42.   wvsprintf(DatStr,'The offset is %04X and the segment '+
  43.                    'is %04X',PC);
  44.   WriteLn(DatStr);
  45. END.
  46.  
  47.  
  48.  
  49.  
  50.  
  51.