From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the amount of installed memory?

Solved!
Go to solution

smercurio_fc wrote:

 

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:

 


 

 
 Thanks, I went with this and it seems to work. (first time I dragged this snipped onto my diagram, my entire project crashed, though 😞 Ouch!).
 
Will this also work on computers that don't have .NET framework installed?
 
Of course using SI units won't give the customary numbers (1GiB = 1073741824 Bytes), so I divided by 2^30 and used plain formatting followed by the string "GiB";)
 
Is there a a special format code to get IEC prefixes instead of SI directly? Maybe there should be.
 
Thanks to all! 
0 Kudos
Message 11 of 17
(2,102 Views)

altenbach wrote: 
Thanks, I went with this and it seems to work. (first time I dragged this snipped onto my diagram, my entire project crashed, though 😞 Ouch!).

Odd. I had used the Code Capture Tool. Maybe it creates something that 2009 doesn't like, though I suspect it's more likely to do with the fact that I was using .NET.

 


Will this also work on computers that don't have .NET framework installed?

Unfortunately, no. A .NET-free version would need to use the Windows API via DLLs/Call Library Function Node to call the GlobalMemoryStatusEx function. The details of the structure are here. Attached is a VI that does this.

Message 12 of 17
(2,085 Views)

smercurio_fc wrote: 
A .NET-free version would need to use the Windows API via DLLs/Call Library Function Node to call the GlobalMemoryStatusEx function. The details of the structure are here. Attached is a VI that does this.

 

 
O, that looks great!
 
Maybe I'll use this instead of .NET to make it more universal, because I have very little control over the end user computer and what's installed there.  😉
 
Thanks! 
0 Kudos
Message 13 of 17
(2,077 Views)

Upon testing the executable on Vista machines, it seem I cannot get e.g. the "ProcessorNameString" from the registry unless I select to run in "XP compatibility mode" or select "Run as Administrator".

 

Is there a way to configure the installer so one of these options is applied automatically? Just curious.

 

(Also, I don't have access to a Windows 7 machine. Does it act like Vista in this case?)

Message Edited by altenbach on 03-12-2010 08:37 AM
0 Kudos
Message 14 of 17
(2,046 Views)

altenbach wrote:

Upon testing the executable on Vista machines, it seem I cannot get e.g. the "ProcessorNameString" from the registry unless I select to run in "XP compatibility mode" or select "Run as Administrator".


Odd. I can see why you would need to be admin to be able to write to that key, but one should be able to read it. On XP, at least, the permissions are such that the special account Everyone can read that key. I don't have Vista to check this, and my Win 7 machine is at home so I can check this tonight.

 


Is there a way to configure the installer so one of these options is applied automatically? Just curious.

Yes. For the compatibility mode there's the branch HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers. There should be separate keys for each application. The key name is the full path to the executable. The type is string (REG_SZ), and the data is the compatibility mode, e.g., WINXPSP2, WIN95, WIN2000. There also a similar key in HKEY_CURRENT_USER. Not sure which one takes precedence. Note that you need to be admin to be able to create these keys.

 

As for Windows 7, it has those keys as well, but I read in one site that those keys are either obsolete or that the values get written someplace else. I can check on my Windows 7 machine.

 

 

As far as setting the "Run as Administrator" programmatically, I'm not sure if you can do this. Seems to be a security risk to me. 

Message 15 of 17
(2,031 Views)

Ah, looking more closely at the "open registry key", there is a optional input for "security access mask" where I can select e.g. "Key_read" or "Key_query_value", which I assume is "read-only access" I'll try this.

 

Found some documentation at microsoft. The LabVIEW help does not give any details. 

 

If uwired (the way I had it!), it defaults to read/write.

 

That might be it....

Message Edited by altenbach on 03-12-2010 10:19 AM
0 Kudos
Message 16 of 17
(2,028 Views)

Success! Using "Key_query_value" as security access mask solves the vista problem. 🙂

 

(I did not bother to look into this earlier, because things worked fine under XP ;)) 

0 Kudos
Message 17 of 17
(2,019 Views)