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

UDF - UDS Library
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

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

Global Memory Status

 Keywords:  

#DefineFunction udfGlobalMemoryStatus(request)
   if request<1 || request>7
		Message("Error","Invalid request specified")
		return 0
	endif
	bufsize=32
	LPMEMORYSTATUS = BinaryAlloc(bufsize)
	BinaryEodSet(LPMEMORYSTATUS,bufsize)
	Dll = StrCat(DirWindows(1),"kernel32.dll")
	DllCall(Dll, void:"GlobalMemoryStatus", lpbinary:LPMEMORYSTATUS)
	member = request*4
	result = BinaryPeek4(LPMEMORYSTATUS,member)
	Return (result)
#EndFunction


MemoryLoad = 1	;Windows 2000/XP: Approximate percentage of total physical memory that is in use. 
							;Windows NT 4.0 and earlier: Percentage of approximately the last 1000 pages of 
							;physical memory that is in use.
TotalPhys = 2  	;Total size of physical memory, in bytes. 
AvailPhys = 3	;Size of physical memory available, in bytes.
TotalPageFile = 4   ;Size of the committed memory limit, in bytes.
AvailPageFile = 5   ;Size of available memory to commit, in bytes. 
TotalVirtual = 6	;Total size of the user mode portion of the virtual address space of the calling process, in bytes.
AvailVirtual = 7	;Size of unreserved and uncommitted memory in the user mode portion of the virtual address space 
							;of the calling process, in bytes.
AvailExtendedVirtual = 8 	;*****ONLY Supported by udfGlobalMemoryStatusEx*******
									;Size of unreserved and uncommitted memory in the extended portion of the 
									;virtual address space of the calling process, in bytes. 


resultbytes = udfGlobalMemoryStatus (TotalPageFile)
Message("TotalPageFile: committed memory limit (bytes)",resultbytes)
Exit

#DefineFunction udfGlobalMemoryStatusEx(request)
	;Windows NT/2000/XP: Included in Windows 2000 and later.
   ;Windows 95/98/Me: Unsupported.
   if request!=4 && request!=8 && request!=16 && request!=24 && request!=32 && request!=40 && request!=48 && request!=56
		Message("Error","Invalid request specified")
		return 0
	endif
	OS = WinVersion(4)
	if OS != 4
		Message("Error","This function is not supported on this Windows platform")
		return 0
	endif
	bufsize=64
	LPMEMORYSTATUSEX = BinaryAlloc(bufsize)
	BinaryEodSet(LPMEMORYSTATUSEX,bufsize)
	BinaryPoke4(LPMEMORYSTATUSEX,0,bufsize)
	Dll = StrCat(DirWindows(1),"kernel32.dll")
	ret = DllCall(Dll, long:"GlobalMemoryStatusEx", lpbinary:LPMEMORYSTATUSEX)
	if ret == 0
		 Message("GlobalMemoryStatusEx DllCall error",DllLastError())
	endif
	result = BinaryPeek4(LPMEMORYSTATUSEX,request)
	Return (result)
#EndFunction


MemoryLoad = 4 		;Number between 0 and 100 that gives a general idea of current memory utilization, in 
								;which 0 indicates no memory use and 100 indicates full memory use. 

TotalPhys = 8 		;Total size of physical memory, in bytes. (RAM) 

AvailPhys = 16 		;Size of physical memory available, in bytes. 

TotalPageFile = 24		;Size of the committed memory limit, in bytes. This is physical memory plus the size 
								;of the page file, minus a small overhead. 
 
AvailPageFile = 32  	;Size of available memory to commit, in bytes. The limit is TotalPageFile. 

TotalVirtual = 40	   ;Total size of the user mode portion of the virtual address space of the calling process, in bytes. 

AvailVirtual 	= 48 		;Size of unreserved and uncommitted memory in the user mode portion of the virtual address space of the 
								;calling process, in bytes. 

AvailExtendedVirtual =56 ;Size of unreserved and uncommitted memory in the extended portion of the virtual address space of 
								;the calling process, in bytes. 


ram = udfGlobalMemoryStatusEx (TotalPhys)
ram =  ram/1024/1024
Message("RAM",StrCat("Approx. ",ram," MB"))

tpf = udfGlobalMemoryStatusEx (TotalPageFile)
tpf = tpf/1024/1024
pagefilesize = tpf-ram
Message("PageFile size in MB",pagefilesize)

Article ID:   W15734
File Created: 2003:05:13:11:29:52
Last Updated: 2003:05:13:11:29:52