Link to home
Start Free TrialLog in
Avatar of spearhead
spearhead

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of seg
seg

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of spearhead
spearhead

ASKER

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?
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.
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?
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.
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.

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.