Chris_Graham@f344.n632.z3.fidonet.org (Chris Graham) (05/30/91)
Somewhere in the docs, the formula is given. Have a look, sorry I don't know where it is. -Chris
James_Bell@f6.n3601.z1.fidonet.org (James Bell) (05/30/91)
> Does anyone know whether it's possible for a program to find out > the percentage of remaining free resources, as it is posted in The on-disk doc files w/the SDK tell how progman computes the system resources, but I don't think they give a function for it. If you discover/write one, let me know and/or post it! JB
risto@tuura.UUCP (Risto Lankinen) (06/06/91)
James_Bell@f6.n3601.z1.fidonet.org (James Bell) writes: >> Does anyone know whether it's possible for a program to find out >> the percentage of remaining free resources, as it is posted in >The on-disk doc files w/the SDK tell how progman computes the system resources, >but I don't think they give a function for it. If you >discover/write one, let me know and/or post it! >JB Hi! I've got an (evidently *DANGEROUS!*, but probably working) idea: Use EnumWindows() (for USER-module) or EnumObjects() (for GDI-module). Make the call-back procedure save the DS before doing *anything* else - either by using .ASM for the call-back procedure or compiling the source containing it without the '-Gw' switch so, that the DS is not destroyed before you had a chance to read it. Basic assumption: The DS upon invocation of the call-back procedure = DGROUP of the calling-back module, which can be used to calculate the calling-back module's local heap size and other relevant information. Disclaimer: Hack it out, but don't make any use of it unless you agree that doing so is at your own risk only. Terveisin: Risto Lankinen P.S. Anyone know, how the 'Luke HeapWalker' enumerates the segments and retrieves the information it displays on its window? Must be difficult and a bit non-standard, because Microsoft had to rewrite it between SDK versions 2.0 and 3.0 . -- Risto Lankinen / product specialist *************************************** Nokia Data Systems, Technology Dept * 2 3 * THIS SPACE INTENTIONALLY LEFT BLANK * 2 +1 is PRIME! Now working on 2 -1 * replies: risto@yj.data.nokia.fi ***************************************
ih@ecs.soton.ac.uk (Ian Heath) (06/07/91)
In <1195@tuura.UUCP> risto@tuura.UUCP (Risto Lankinen) writes: >James_Bell@f6.n3601.z1.fidonet.org (James Bell) writes: >>> Does anyone know whether it's possible for a program to find out >>> the percentage of remaining free resources, as it is posted in >>The on-disk doc files w/the SDK tell how progman computes the system resources, >>but I don't think they give a function for it. If you >>discover/write one, let me know and/or post it! OK, here we go. This the the "official" way of calculating the free system resources (at least it's the way Program Manager does it) :-> DWORD FAR PASCAL GetHeapSpaces(HANDLE h) ; int GetFreeSystemResources(void) { DWORD dwHeapSize ; int nUserPercent,nGdiPercent ; dwHeapSize = GetHeapSpaces(GetModuleHandle("user")) ; nUserPercent = 100*(LOWORD(dwHeapSize)/1024)/ (HIWORD(dwHeapSize)/1024) ; dwHeapSize = GetHeapSpaces(GetModuleHandle("gdi")) ; nGdiPercent = 100*(LOWORD(dwHeapSize)/1024)/ (HIWORD(dwHeapSize)/1024) ; return (min(nUserPercent,nGdiPercent)) ; } I got this from reverse engineering the program manager program (with apologies to Microsoft). It uses a non-documented function call (GetHeapSpaces whose prototype is given above) and gives the same results as File/Program manager. *** DISCLAIMER *** I don't guarantee this will work for any other version of windows other than 3.0. As it uses an undocumented function call there's no reason the function'll remain the same across versions. However, if Microsoft use it, it must be right B-> While we're on the subject of Windows Hacking, has anyone else found any good undocumented functions within Windows that they might want to share??? Cheers, Ian -- Ian Heath, email: ih@ecs.soton.ac.uk (BITNET) or ih@uk.ac.soton.ecs (JANET) "And now you are alone my friend and I must set you free And you must face the world outside and find your destiny" - Freudiana