Free System Resources

Free System Resources

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

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 ===

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as