devxlogo

Free System Resources

Free System Resources

Question:
Is there an API call to find the amount of free system resources in Windows 95?

Answer:
Good news and bad news, here. Yes, there is. But, no, you can’t call it from a 32-bit program.

The simple truth is, FSRs are a relic of another era. They have no meaning whatsoever under 32-bit Windows. But, you say, “Windows displays them!” Well, Win95 is a real mess under the hood. It’s full of 16-bit code that really louses up the whole system, and makes FSRs still an issue, albeit less of one than before.

You can write a 16-bit OLE server with VB4, which makes the same old traditional Win16 calls to retrieve FSRs, if you find that you really need to. Below is a class module I wrote several years ago to do just that. Of course, if you’re using VB3 you can still make the same API call, but you won’t be able to wrap it up in a class like this.

Once you build this critter, just to show what I say above isn’t a hoax, try querying FSRs in NT. You’ll see that no matter what, all values are returned at 90%. The problem was, far too many programs wouldn’t have known what to do if the OS told them the truth (100%). 🙂

=== BOF: CFSR.CLS ===

VERSION 1.0 CLASSBEGIN  MultiUse = -1  'TrueENDAttribute VB_Name = "CFreeSystemResources"Attribute VB_Creatable = TrueAttribute VB_Exposed = True'' Copyright (C)Karl E. Peterson, 1996' All Rights Reserved.'Option Explicit'' Win16 declarations for FSR calls into ToolHelp'Private Type SYSHEAPINFO   dwSize As Long   wUserFreePercent As Integer   wGDIFreePercent As Integer   hUserSegment As Integer   hGDISegment As IntegerEnd TypePrivate Declare Function SystemHeapInfo Lib "toolhelp.dll" _                          (shi As SYSHEAPINFO) As IntegerPrivate m_shi As SYSHEAPINFOPrivate Sub Class_Initialize()   '   ' Initialize SYSHEAPINFO structure   '   m_shi.dwSize = Len(m_shi)End SubPublic Property Get UserFreePercent() As Integer   '   ' Retrieve FSR stats, and return User percent   '   Call SystemHeapInfo(m_shi)   UserFreePercent = m_shi.wUserFreePercentEnd PropertyPublic Property Get GdiFreePercent() As Integer   '   ' Retrieve FSR stats, and return GDI percent   '   Call SystemHeapInfo(m_shi)   GdiFreePercent = m_shi.wGDIFreePercentEnd PropertyPublic Property Get FSRPercent() As Integer   '   ' Retrieve FSR stats, and return lowest value   '   Call SystemHeapInfo(m_shi)   If m_shi.wUserFreePercent < m_shi.wGDIFreePercent Then      FSRPercent = m_shi.wUserFreePercent   Else      FSRPercent = m_shi.wGDIFreePercent   End IfEnd Property

=== EOF: CFSR.CLS ===

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist