Solved

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

Posted on 1997-05-07
7
696 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

729 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