Jump to content



Photo

Get physical memory (GetPhysicallyInstalledSystemMemory)


  • Please log in to reply
12 replies to this topic

#1 AdmiralAlkex

AdmiralAlkex

    I'm on a boat

  • MVPs
  • 4,490 posts

Posted 14 February 2011 - 10:36 PM

http://msdn.microsoft.com/en-us/library/cc300158(v=vs.85).aspx

Minimum supported client = Windows Vista with SP1
Minimum supported server = Windows Server 2008

MsgBox(0, "Title", "GetPhysicallyInstalledSystemMemory = " & _GetPhysicallyInstalledSystemMemory()) Func _GetPhysicallyInstalledSystemMemory()     $aRet = DllCall("Kernel32.dll", "int", "GetPhysicallyInstalledSystemMemory", "uint64*", "")     If @error Then Return SetError(1, 0, 0)     Return $aRet[1] EndFunc


Okay, we are not checking the return value of the function, but I don't think it's necessary.

Edited by AdmiralAlkex, 15 February 2011 - 05:50 PM.






#2 Ascend4nt

Ascend4nt

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,073 posts

Posted 15 February 2011 - 05:00 PM

Nice find. The first parameter should be of type 'uint64*' however. (64-bit integer).

#3 AdmiralAlkex

AdmiralAlkex

    I'm on a boat

  • MVPs
  • 4,490 posts

Posted 15 February 2011 - 05:50 PM

I don't know how I got that to int* :)

Code edited.

Edit: Edit

Edited by AdmiralAlkex, 15 February 2011 - 05:54 PM.


#4 guinness

guinness

    guinness

  • MVPs
  • 10,372 posts

Posted 15 February 2011 - 06:50 PM

Nice, weird why this isn't in WinAPIEx.au3 but I suppose there is _WinAPI_GetPerformanceInfo() I will add this to my Function Folder :)

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#5 AdmiralAlkex

AdmiralAlkex

    I'm on a boat

  • MVPs
  • 4,490 posts

Posted 15 February 2011 - 07:23 PM

weird why this isn't in WinAPIEx.au3

Maybe Yashied still uses Win XP? :)

but I suppose there is _WinAPI_GetPerformanceInfo()

GetPerformanceInfo is not the same, you could say that it returns what is available for Windows, GetPhysicallyInstalledSystemMemory returns what you actually have on your motherboard.

Take my computer for example, 6GB ram, but I've it limited to 4GB due to a bugged driver, so there is only 3327MB available due to graphics card and stuff hogging the upper memory range.

GetPerformanceInfo[3] = 3488706560
GetPhysicallyInstalledSystemMemory = 6291456

On older OS you can get this with GetSystemFirmwareTable or WMI. Interesting read (do a find-in-page for GetPhysicallyInstalledSystemMemory and read a little after that).

See _ComputerGetMemory from CompInfo.au3 for WMI example.

#6 guinness

guinness

    guinness

  • MVPs
  • 10,372 posts

Posted 15 February 2011 - 07:35 PM

OK, my mistake ;) It makes sense now you say and after reading. Plus thanks for the website I will have a little look around the other categories :)

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#7 AdmiralAlkex

AdmiralAlkex

    I'm on a boat

  • MVPs
  • 4,490 posts

Posted 15 February 2011 - 07:40 PM

Yeah that Geoff have some cool stuff :)

#8 hackersarchangel

hackersarchangel

    Seeker

  • Active Members
  • 21 posts

Posted 20 December 2011 - 06:29 PM

Was gonna ask how this differs from MemGetStats() but I figured it out, but just in case someone else wonders:

MemGetStats() shows the reported memory amount, after what is left through sharing. So if I have 4gb of memory, but it's sharing half a gb, then MemGetStats() reports 3.5gb.
This grabs the actual installed amount. (You can correct me if I'm mistaken.)

#9 AdmiralAlkex

AdmiralAlkex

    I'm on a boat

  • MVPs
  • 4,490 posts

Posted 21 December 2011 - 07:39 PM

I am not sure about the word "sharing", but yeah. GetPhysicallyInstalledSystemMemory() returns what is actually installed while MemGetStats(), _WinAPI_GetPerformanceInfo() and such returns what is usable to Windows (basically).

See post #5 too.

#10 AdmiralAlkex

AdmiralAlkex

    I'm on a boat

  • MVPs
  • 4,490 posts

Posted 21 December 2011 - 11:38 PM

I just noticed (again? can't remember :) ) that GetPhysicallyInstalledSystemMemory was added to WinAPIEx UDF some time ago. I recommend everyone to check that UDF if you haven't.

#11 JohnOne

JohnOne

    John

  • Active Members
  • PipPipPipPipPipPip
  • 8,865 posts

Posted 22 December 2011 - 01:02 AM

I'm curious as to what the outcome of this function would be inside a VM.
AutoIt Absolute Beginners Require a serial
Run('hh mk:@MSITStore:'&StringReplace(@AutoItExe,'.exe','.chm')&'::/html/tutorials/helloworld/helloworld.htm','',@SW_MAXIMIZE)

#12 AdmiralAlkex

AdmiralAlkex

    I'm on a boat

  • MVPs
  • 4,490 posts

Posted 22 December 2011 - 02:12 AM

I'm curious as to what the outcome of this function would be inside a VM.

If you mean whether it returns the memory of the host or the VM, then oversized screenshot (VMware Workstation) says VM.

#13 JohnOne

JohnOne

    John

  • Active Members
  • PipPipPipPipPipPip
  • 8,865 posts

Posted 22 December 2011 - 10:35 AM

Thanks, I ask because some time ago when you made this function I asked a few e-buddies to
test this out and a few of them came back with the result 0.

I can't remember is I found a pattern, do you know if the the function works on 64 bit, or if
any OS archs that it stumbles on?
AutoIt Absolute Beginners Require a serial
Run('hh mk:@MSITStore:'&StringReplace(@AutoItExe,'.exe','.chm')&'::/html/tutorials/helloworld/helloworld.htm','',@SW_MAXIMIZE)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users