Algorithms
Electronics
File Formats
Games Programming
Hardware/Architecture
Humour
Java/Javascript
Link Site,Library
Linux,GNU
Magazines/Books
Networks
New/Latest Stuff
Programming Languages
Protocols
Servers/ISAPI/ IO Completion Ports
Sound and Music
Source Code
Visual Basic
Windows
Winsock

Getting Free System, GDI and USER Resources on Windows 95

This code only works on Windows 95 and not on Windows NT because it relies on a library file called "rsrc32.dll" which is used by the Resource Monitor.
#include "windows.h"
#include "stdio.h"

#define GFR_SYSTEM_RESOURCES	0
#define GFR_GDI_RESOURCES	1
#define GFR_USER_RESOURCES	2

typedef LONG (CALLBACK *GETRESOURCE)(int);

int main()
{
long FreeGdi;
long FreeSys;
long FreeUsr;
GETRESOURCE pGetResource;

HINSTANCE hInst = LoadLibrary("rsrc32.dll");
if (hInst!=NULL)
   {
   pGetResource = GetProcAddress(hInst,"_MyGetFreeSystemResources32");
      if(pGetResource)
          {
          FreeGdi = (*pGetResource)(GFR_GDI_RESOURCES);
          FreeSys = (*pGetResource)(GFR_SYSTEM_RESOURCES);
          FreeUsr = (*pGetResource)(GFR_USER_RESOURCES);
          printf("GDI Resources Used   : %d\n",FreeGdi);
          printf("System Resources Used: %d\n",FreeSys);
          printf("User Resources Used: %d\n",FreeUsr);
          }
      else
          {
          printf("Error Getting Pointer to _MyGetFreeSystemResources32\n");
	  return 0;
          }
   }
   else
   {
   printf("Couldn't Load rsrc32.dll\n");
   }
FreeLibrary(hInst);
}

Copyright Geoffrey Smith 2000