Solved

Getting Free System Resources in Win32 (VC++ v4)

Posted on 1997-05-07
7
682 Views
Last Modified: 2013-12-04
We would like to determine the amount of free "System Resources" under Windows 95 and Windows NT (32 bit Windows under Visual C++ 4).

Under 16 bit Windows (Visual C++ 1.52) we use the function "GetFreeSystemResources" with the "GFSR_SYSTEMRESOURCES" paramater, however this function is not supported in Win32.

We tried using the "GlobalMemoryStatus" function and retrieved the dwMemoryLoad variable, however it is not the same as the System Resources (as displayed under Control Panel -> System -> Perfomance, or the Resource Meter "rsrcmtr.exe") and is not the information that we require.
0
Comment
Question by:spearhead
  • 4
  • 3
7 Comments
 

Accepted Solution

by:
seg earned 100 total points
ID: 1397170
from the MSDN (keywod TOOLHELP or GetFreeSystemResources):
SystemHeapInfo in the 16-bit TOOLHELP.DLL is useful for getting the free system resources in the USER and GDI heaps as well as the 16-bit global heap handles for the respective heaps. The SystemHeapInfo function is actually a functional superset of the 16-bit GetFreeSystemResources function. Alas, there’s no way in Win32 to get any of this information. If you want to know the free system resources in a Win32-based program, you’ll need to thunk down to a 16-bit DLL and call SystemHeapInfo or GetFreeSystemResources. This is what SHELL32.DLL does to display the free system resources in the About boxes of all the standard Windows 95 utilities.

0
 

Author Comment

by:spearhead
ID: 1397171
Ok, So that means that SystemHeapInfo will only return the User resources (GetFreeSystemResources(GFSR_USERRESOURCES)) and GDI resources (GetFreeSystemResources(GFSR_GDIRESOURCES)) to us, with the third value for System Resources (GetFreeSystemResources(GFSR_SYSTEMRESOURCES)) coming directly from the GetFreeSystemResources function itself.  We are most interested in the third of these values so the SystemHeapInfo will not help us in this case.

Given that, exactly which DLL do we need to access and what is the procedure for thunking down to it.  What changes will we need to make to our code (Visual C++ version 4.0) to get a successful Win32 compilation.  As it is, GetFreeSystemResources is an "undeclared identifier" as are the three parameters passed to it (GFSR_...).  There is obviously an additional header file somewhere and a thunk DLL.  What files are these and what procedure do we need to follow to link them into our project?
0
 

Expert Comment

by:seg
ID: 1397172
as my blurb stated, you can call either SystemHeapInfo or GetFreeSystemResources once you thunk down so you should be able to get exactly the information you want.

TOOLHELP.H contains the function prototypes.

Windows doesn't come with an official thunking DLL. in most cases it is simply an interface between your app and the 16-bit DLL and has to be created yourself. see KB article Q155763. it gives an example of how to go about creating the thunking layer.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:spearhead
ID: 1397173
In NT there it appears there is no facility to thunk down to a 16 bit DLL and we have another application that uses thunking for Windows 95 but their thunk DLL is not required for NT.  Does this mean that we can do the same and if so how do we access the 16 bit DLL under NT (Workstation 3.51).

We are unable to create a thunk DLL for Windows 95 at this stage as we do not have THUNK.EXE (thunk compiler) nor do we have a copy of MASM so as far as Windows '95 goes we will have to abandon these calls but can you provide any further help for accessing these calls from Windows NT?
0
 

Expert Comment

by:seg
ID: 1397174
in that same KB article, thunk.exe is said to be included with the Win32 SDK so it has to be around someplace (maybe Microsoft's ftp site). although another article states that it is also included with Win95, i couldn't find it anywhere on my machine nor on the setup CD.
other than that, you might want to play around with Shl3216_ThunkData32 which is a function in SHELL32.DLL. according to the original MSDN article, this guy is used by Win95's Resource Meter (System Tools) to display the free resources so there has to be a way to do it.
0
 

Author Comment

by:spearhead
ID: 1397175
How can I access the Shl3216_ThunkData32 function in SHELL32.DLL?   Also, where can I find the original MSDN article that you mention?  I don't have (or at least I don't think I do) a header file or corresponding .lib file for the SHELL32 DLL so do not know how I can link the DLL into my application or even then, how to call the function or which parameters it takes.

0
 

Expert Comment

by:seg
ID: 1397176
you're just going to have to find thunk.exe - not sure what else i can tell you.

PS- MSDN stands for Microsoft Developers Network. it's a reference CD you should be able to get at any Egghead or CompUSA. if not then order it from MS.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now