|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to get current free physical memory ?Using VS 2003 and Windows XP
How can I get free physical memory ?? Where is a full documentation for WMI and so an managementobjects ? Peter TOP A:
To get FreePhysicalMemory via "Select FreePhysicalMemory from win32_operatingsystem" we need 600ms . That's a long time. TOP B: A full select "Select * from win32_operatingsystem" needs 10 seconds !!!!! Is there any quicker/other possibility to get amount of free memory ?? Peter Show quoteHide quote "Peter Stojkovic" <Peter.Stojko***@gmx.net> wrote in message news:uqBA4lpOFHA.3856@TK2MSFTNGP10.phx.gbl... > Using VS 2003 and Windows XP > > How can I get free physical memory ?? > > Where is a full documentation for WMI and so an managementobjects ? > > > Peter > > > Add reference to 'System.Management' DLL
Add the following Import statement Imports System.Management Add this function: Private Function GetFreePhysicalMemory() As String Dim objMgmt As ManagementObject Dim objOs As ManagementObjectSearcher = _ New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem") Dim strResult As String For Each objMgmt In objOs.Get strResult = objMgmt("freephysicalmemory").ToString() Next objOs.Dispose() objMgmt.Dispose() Return strResult End Function Usage: MessageBox.Show(GetFreePhysicalMemory) I hope this helps Crouchie1998 BA (HONS) MCP MCSE Thanks,
but this needs so much time to execute as described in my last mail ! Peter Show quoteHide quote "Crouchie1998" <crouchie1998@spamcop.net> wrote in message news:O44Ru3qOFHA.2136@TK2MSFTNGP14.phx.gbl... > Add reference to 'System.Management' DLL > > Add the following Import statement > > Imports System.Management > > Add this function: > > Private Function GetFreePhysicalMemory() As String > Dim objMgmt As ManagementObject > Dim objOs As ManagementObjectSearcher = _ > New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem") > Dim strResult As String > For Each objMgmt In objOs.Get > strResult = objMgmt("freephysicalmemory").ToString() > Next > objOs.Dispose() > objMgmt.Dispose() > Return strResult > End Function > > Usage: > > MessageBox.Show(GetFreePhysicalMemory) > > I hope this helps > > Crouchie1998 > BA (HONS) MCP MCSE > > "Peter Stojkovic" <Peter.Stojko***@gmx.net> schrieb: <URL:http://dotnet.mvps.org/dotnet/samples/operatingsystem/MemoryStatus.zip>> Using VS 2003 and Windows XP > > How can I get free physical memory ?? -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Thanks a lot.
That is much qicker than, "SELECT * from win32_...." Peter Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:ekeLNZsOFHA.3704@TK2MSFTNGP12.phx.gbl... > "Peter Stojkovic" <Peter.Stojko***@gmx.net> schrieb: >> Using VS 2003 and Windows XP >> >> How can I get free physical memory ?? > > <URL:http://dotnet.mvps.org/dotnet/samples/operatingsystem/MemoryStatus.zip> > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> "Peter Stojkovic" <Peter.Stojko***@gmx.net> schrieb: WMI was primarily designed to to /management/ operations easily, so > That is much qicker than, > "SELECT * from win32_...." performance was not that important. In addition to my previous reply, you may want to take a look at the 'MemoryStatusEx' function, which is more evolved than the 'MemoryStatus' function I use in the sample. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Microsoft not content with "dissing" just the Classic VB Developer Army....
Where to find good icons? In-place Updating in Datagrid not working Why doesn't timer tick Accessing Through Newsreader modify HTML in code behind How to expose a structure to VB6 from VB.NET? Datagrid problem Multiselect List Box How to convert a Byte array to a String |
|||||||||||||||||||||||