From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

How to get the amount of installed memory?

解決済み
解決策を見る

(This is under Windows OS

 

I am making a benchmarking program to get statistics on performance for some complicated calculations based on computer hardware.

 

What is the best way to obtain the amount of installed RAM programmatically?

How do I tell if the OS is 32 or 64 bit?

 

Thanks! 

0 件の賞賛
メッセージ1/17
5,328件の閲覧回数

does a call to the getnativesysteminfo function in kernel32.dll give it to you?

 

Here are some details. You can also try the IsWow64Process function, but I don't believe that is exactly what you want. As for the Ram, not sure.

Message Edited by for(imstuck) on 03-10-2010 02:07 PM
0 件の賞賛
メッセージ2/17
5,323件の閲覧回数

vi.lib\platform\system.llb has memstats.vi

 

 

vi.lib\utility\sysinfo.llb has Get Current platform

 

also look at property node >>> application >>> target stuff

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 件の賞賛
メッセージ3/17
5,300件の閲覧回数
解決策
トピック作成者altenbachが受理

Ben, it doesn't look like the Memstats VI returns the installed memory. It returns a number, but I can't match it to the amount of memory installed in my system. The GetCurrentPlatform seems to only return the OS Name, not whether it's 32-bit or 64-bit. I didn't see anything in the App->Target list that contained this information. At least in 8.2. Haven't checked in 2009.

 


altenbach wrote:

(This is under Windows OS

 

I am making a benchmarking program to get statistics on performance for some complicated calculations based on computer hardware.

 

What is the best way to obtain the amount of installed RAM programmatically?

How do I tell if the OS is 32 or 64 bit?

 

Thanks! 


Define "best". Best in speed? Best in compatibility over multiple versions of the Windows OS? Best in terms of accessing this information without having to delve too much into all sorts of Windows datatypes and DLLs?

 

Would you consider .NET to be a candidate for "best". If so, the amount of installed RAM can be easily acquired using the Microsoft.VisualBasic.Devices.ComputerInfo class:

 

 

As for determining whether your OS is 32-bit or 64-bit are you trying to distinguish between a 32-bit OS on a 64-bit CPU vs a 64-bit OS on a 64-bit CPU? I know the WMI class can be used to get this information, so if you're trying to make that distinction you could look at the Win32_ComputerSystem and Win32_Processor classes. For instance, I believe the following is what you would see:

 

64bit OS on x64processor:
win32_computersystem.systemtype = x64-based pc
win32_processor.addresswidth = 64
win32_processor.architecture = 9
win32_processor.datawidth = 64

32bit OS on x86processor:
win32_computersystem.systemtype = x86-based pc
win32_processor.addresswidth = 32
win32_processor.architecture = 0
win32_processor.datawidth = 32

32bit OS on x64processor:
win32_computersystem.systemtype = x86-based pc
win32_processor.addresswidth = 32
win32_processor.architecture = 9
win32_processor.DataWidth = 64

 

I've attached an example on how to access the classes with .NET. Not pretty, but not overly ugly either.

Message Edited by smercurio_fc on 03-10-2010 03:36 PM
すべてをダウンロード
メッセージ4/17
5,280件の閲覧回数

smercurio_fc wrote:

Define "best".


Just a quick and dirty method that does not require advanced knowledge of the windows guts, works on all OS variations, and does not require fancy code. 😉 (All I want is everything!)

 

I thougth maybe I could read the RAM out of the registry (That's what I do for the CPU info at the moment, see image), but I have not found the key.

 

Here's what I whipped up last night, maybe it's all wrong. I have not tried it on different machines.

 

Thanks for all the suggestions, I'll study them tonight. 😄 

 

 

Message Edited by altenbach on 03-10-2010 01:46 PM
0 件の賞賛
メッセージ5/17
5,270件の閲覧回数

altenbach wrote:

smercurio_fc wrote:

Define "best".


Just a quick and dirty method that does not require advanced knowledge of the windows guts, works on all OS variations, and does not require fancy code. 😉 (All I want is everything!)

 

I thougth maybe I could read the RAM out of the registry (That's what I do for the CPU info at the moment, see image), but I have not found the key.


There's an HKEY_LOCAL_MACHINE\HARDWARE\RESOURCEMAP\System Resources\Physical Memory\.Translated (yes, that's a period there). It's a packed value. Not sure how to unpack this value.

0 件の賞賛
メッセージ6/17
5,255件の閲覧回数

I am a bit old-fashioned when it comes to getting the RAM.

 

RAM IT.png

 

Not a lot of useful info returned, but it does give the total installed RAM.

0 件の賞賛
メッセージ7/17
5,248件の閲覧回数

Darin.K wrote:

I am a bit old-fashioned when it comes to getting the RAM.

 

RAM IT.png

 

Not a lot of useful info returned, but it does give the total installed RAM.


I had already tried that. It doesn't return anything remotely close to the total installed RAM. That returns the total contiguous extended memory, which isn't the same as the total installed RAM. 

0 件の賞賛
メッセージ8/17
5,242件の閲覧回数

Should have looked more closely at the number.  That is what I get for trying to dust off a command I probably last used on Windows 95.  Now that DOS is off in its own land it is harder to get that info.  There is probably a way to tie into Msinfo32, but that probably reads the Registry.

 

0 件の賞賛
メッセージ9/17
5,238件の閲覧回数
I'll second .NET as the most reliable option.
-Barrett
CLD
0 件の賞賛
メッセージ10/17
5,236件の閲覧回数