Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Avoiding "Out Of Memory" 1

Status
Not open for further replies.

CassandraR

Programmer
Aug 10, 2001
346
CA
Hi:

I am looking for a way to determine how much Windows resource is remaining. This information is needed to avoid having my program open so many forms (MDI parent and children) that Windows almost comes to a halt.

I have looked at GlobalMemoryStatus, but it does not provide adequate information, like the 16-bit Windows GetFreeSystemResources used to do.

VB6 SP5, Win98SE, MDI parent and children.

Any suggestions or recommendations?

Many thanks,
Cassie
[bigears]
 
Const GFSR_SYSTEMRESOURCES = 0
Const GFSR_GDIRESOURCES = 1
Const GFSR_USERRESOURCES = 2
Private Declare Function GetFreeResources Lib "RSRC32" Alias "_MyGetFreeSystemResources32@4" (ByVal lWhat As Long) As Long
Private Sub Form_Load()
Me.AutoRedraw = True
'get resource information
Me.Print "Free System Resources: " + CStr(GetFreeResources(GFSR_SYSTEMRESOURCES)) + "%"
Me.Print "Free GDI Resources: " + CStr(GetFreeResources(GFSR_GDIRESOURCES)) + "%"
Me.Print "Free User Resources: " + CStr(GetFreeResources(GFSR_USERRESOURCES)) + "%"
End Sub


peterguhl@yahoo.de
 
Hi Peter:

Many, many thanks!! Precisely what I needed! Here's a star for you. [2thumbsup]

Cassie

 
Peter and Cassie,

Sorry I can't seem to get Peter's code working on my system, although Damn useful as it is!!! :-(

Win XP Pro
VB6 SP5

Regards
 
Oh, I suppose I should explain why:

1) NT4/W2000/XP/2003 don't have RSRC32.DLL, which is the DLL that supports W9x's Resource Monitor utility

2) They don't need it, as they don't have the same resources issues as the W9x family
 
Hi:

I used the code that Peter so kindly provided and it worked first time and worked perfectly.

Cassie
[noevil]
 
Strongm,

Well that explains that!

Thanx for the info.

Regards
 

There is a little problem with using RSRC32.DLL. It may or may not be installed on the user's computer prior to using your own installation package. I haven't checked, but RSRC32.DLL may or may not be licensed for redistribution.

RSRC32.DLL is installed IF the user chose, during the installation of Windows, to install the Resource Meter application. No Resource Meter? Then no RSRC32.DLL installed.

Cassie
(-:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top