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

How to get the amount of installed memory?

解決済み
解決策を見る

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 件の賞賛
メッセージ11/17
1,179件の閲覧回数

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.

メッセージ12/17
1,162件の閲覧回数

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 件の賞賛
メッセージ13/17
1,154件の閲覧回数

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 件の賞賛
メッセージ14/17
1,123件の閲覧回数

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. 

メッセージ15/17
1,108件の閲覧回数

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 件の賞賛
メッセージ16/17
1,105件の閲覧回数

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 件の賞賛
メッセージ17/17
1,096件の閲覧回数