WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Memory and System Resources

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WinResources, Current Memory Utilization, and Total Physical Memory Issues

Keywords:  WinResources	 virtual memory	 BinaryIndex mem  swap file size

WinResources in Win3.X and Total Physical Memory:

WinResources returns the total available memory, in bytes, for 16 bit versions of Windows. There are no WinBatch functions to return the total physical memory (not including the swap file size) from the system. However, you could get a close approximation of the total physical memory, by getting the value returned from WinResources, and then subtracting out the virtual memory (swap file size), which is set in the \WINDOWS\SYSTEM.INI file: MaxPagingFileSize. You may have to play around with this a bit to get it to work.

Another possibility, under Windows 3.X, is to do something like:

In a DOS window, you could do a:


	MEM > filename

Then use BinaryIndexNC to look for the Extended (XMS) size in a file buffer, and then extract that value with BinaryPeekStr. But it will not be your real dos memory, just an emulation.

It's going to be tricky. By the time windows starts and WinBatch can run, you don't get a real DOS Box anymore, merely an emulation.

Similarly, if you added a line in the autoexec.bat file like:


	MEM /C > c:\mem.chk
then the WinBatch script could read the mem.chk file and decide what to do.

OR running it from WinBatch


	RunWait("command.com","/c mem /c > c:\mem.chk")
and read that file instead. But again, it will not be your real dos memory, just an emulation.

Question on WinResouces(10) in NT:

Winresources(10) under Win95 produces a number as advertised (between 60 and 85 so far, depending on what I have open).

However, under NT, the number is always 0. Suggestions? Thanks.

Answer:

Looks like this is a bug in the Windows API, so no fix from Winbatch is available.

Here are the request code numbers for WinResources:


Req#	Return value

0	Total available memory, in bytes
1	Theoretical maximum available memory, in bytes
2	Percent of free system resources (lower of GDI and USER)
3	Percent of free GDI resources
4	Percent of free USER resources

(32-bit only):


Req#	Return value

10	returns a number between 0 and 100 giving a 
	general idea of current memory utilization, 
	in which 0 indicates no memory use and 
	100 indicates full memory use.

11	total number of bytes of physical memory.

12	number of bytes of physical memory available.

13	total number of bytes that can be stored in 
	the paging file.  Note that this number does 
	not represent the actual physical size of the 
	paging file on disk.

14	number of bytes available in the paging file.

15	total number of bytes that can be described 
	in the user mode portion of the virtual address 
	space of the calling process.

16	number of bytes of unreserved and uncommitted 
	memory in the user mode portion of the virtual 
	address space of the calling process.

Article ID:   W13437
Filename:   WinResources and Physical Memory.txt
File Created: 2001:01:26:14:48:34
Last Updated: 2001:01:26:14:48:34