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

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.
spearheadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

segCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
spearheadAuthor Commented:
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
segCommented:
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

spearheadAuthor Commented:
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
segCommented:
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
spearheadAuthor Commented:
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
segCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.