From: nki00 on

"Ulrich Eckhardt" <eckhardt(a)satorlaser.com> wrote in message
news:0n2cd7-el1.ln1(a)satorlaser.homedns.org...
> nki00 wrote:
>> I'm trying to determine the total amount of physical RAM in the system
> [...]
>> It seems to work in Windows XP, but in Vista and Windows 7 I get the
>> following discrepancies:
>>
>> RAM reported in msx.ullTotalPhys = 4252442624 bytes
>> RAM resulting in strSz = "3.96 GB"
>> RAM reported in the properties for My Computer = "Memory (RAM): 4.00 GB"
>
> Those should be GiB. Anyway, is this on the same computer? I ask because
> some computers actually use normal system RAM for graphics.
>
> Uli
>

No, all the data comes from different computers. But I agree, the ones that
report less memory are 64-bit OS's (at least in my example).


From: nki00 on

"Leslie Milburn" <CDB4W(a)NOSPAM.bigpond.com> wrote in message
news:pWIMn.152$Ls1.78(a)news-server.bigpond.net.au...
>
> "nki00" <lukkycharm1(a)gmail.com> wrote in message
> news:htuv0h$7ta$1(a)speranza.aioe.org...
>> Thanks a lot! It did work, but now I've encountered two unexpected
>> issues:
>>
>> (1) If linked like that the code doesn't run on Windows 2000 Pro. (I can
>> probably fix it by using LoadLibrary and GetProcAddress)
>>
>> (2) Even though the amount of RAM is reported correct on my previous test
>> machines, one Windows XP produced very interesting results. The machine
>> has 4GB of RAM installed in it. It has a 32-bit version of XP with SP3
>> and if I check it in My Computer properties it is reported as 3GB of RAM.
>> But if I run your updated program (with WMI Data) it is reported as 4Gib
>> there. GlobalMemoryStatusEx() returns it as 3GB as well. Have you ever
>> encountered anything like that?
>
> From memory, 32 Bit Windows only sees 3GB maximum, anything over is
> ignored. Not true of 64 Bit Windows.
> hth
>
>

Yes, I agree, but why does WMI function from the sample above return 4GB for
the same machine?


From: Jackie on
On 5/31/2010 02:14, nki00 wrote:
> (1) If linked like that the code doesn't run on Windows 2000 Pro. (I can
> probably fix it by using LoadLibrary and GetProcAddress)
>

Yeah, I guess you you don't *have* to use VarUI8FromStr. I saw some
other examples where they just did it similarly to how you worked around
it.

> (2) Even though the amount of RAM is reported correct on my previous test
> machines, one Windows XP produced very interesting results. The machine has
> 4GB of RAM installed in it. It has a 32-bit version of XP with SP3 and if I
> check it in My Computer properties it is reported as 3GB of RAM. But if I
> run your updated program (with WMI Data) it is reported as 4Gib there.
> GlobalMemoryStatusEx() returns it as 3GB as well. Have you ever encountered
> anything like that?

Interesting. So it knows 4 GiB is installed but not that only 3 GiB is
available. Then I wonder exactly how that value is retrieved in
Windows... If I can somehow debug it and see how it gets that value... Hmm.

Regarding my code... I noticed "while (returned > 0);" in there. I
forgot to remove it after changing the loop from "do" to "while".
From: Jackie on
Maybe I got it.
Please see the code here: http://pastebin.com/hjDYhaKD

TotalVisibleMemorySize from Win32_OperatingSystem:
http://msdn.microsoft.com/en-us/library/aa394239(v=VS.85).aspx
"Total amount, in kilobytes, of physical memory available to the
operating system. This value does not necessarily indicate the true
amount of physical memory, but what is reported to the operating system
as available to it."

I used pretty much the same code and it works at least.

Output:
----------------------------------------
Total visible memory:
4.00: GiB
4.19: GB
----------------------------------------

On my (64-bit) system, it is just slightly less than 4 GiB (4094.06 MiB).
From: nki00 on
> Interesting. So it knows 4 GiB is installed but not that only 3 GiB is
> available. Then I wonder exactly how that value is retrieved in Windows...

Yes, it is interesting and I actually like this result :)


> If I can somehow debug it and see how it gets that value... Hmm.
>

Just curious, how do you debug it? Do you use something like SoftICE?


> Regarding my code... I noticed "while (returned > 0);" in there. I forgot
> to remove it after changing the loop from "do" to "while".

Yeah, I noticed it. I learned something too. For instance, the following is
a valid and complilable construct in MS VC++:

a.. while (enumClassObj)
a.. {
a.. //....
a.. }
a.. while (returned > 0);


Both while's aren't actually necessary, by the way. The first one should've
been the 'if' to check if enumClassObj is not NULL. Then it can be an
infinite loop, like while(1) and the way you get out of it is when retuned
== 0, right?