WMI et infos mémoire vive
Bonjour,
j'utilise ce code pour intéroger la mémoire de l'ordinateur.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
int m_MemoireMo;
// Calcul de la taille de la mémoire vive
ManagementScope oMs = new ManagementScope();
ObjectQuery oQuery = new ObjectQuery("SELECT Capacity FROM Win32_PhysicalMemory");
ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery);
ManagementObjectCollection oReturnCollection = oSearcher.Get();
UInt64 Memory = 0;
foreach (ManagementObject oReturn in oReturnCollection)
{
Console.WriteLine(oReturn.ToString());
Memory += (UInt64)oReturn["Capacity"];
}
m_MemoireMo = Convert.ToInt32(Memory / (UInt64)1048576);
System.Windows.Forms.MessageBox.Show("Quantité de mémoire totale : " + m_MemoireMo.ToString() + " Mo."); |
Ca fonctionne mais lorsque je l'utilise avec une machine virtuel (virtual pc) la quantité totale est fausse :
Il m'affiche 64 Mo alors qu'il y en a 512 Mo (j'ai vérifié par l'affichage des Propriétés système).
Comment je peux avoir la "vrai" information ??
Merci.
Voici les infos retournés par la table "Win32_PhysicalMemory" :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
| BankLabel : BANK0
Capacity : 16777216
Caption : Mémoire physique
CreationClassName : Win32_PhysicalMemory
DataWidth : 72
Description : Mémoire physique
DeviceLocator : DIMM1
FormFactor : 8
HotSwappable :
InstallDate :
InterleaveDataDepth : 1
InterleavePosition : 0
Manufacturer :
MemoryType : 17
Model :
Name : Mémoire physique
OtherIdentifyingInfo :
PartNumber :
PositionInRow : 1
PoweredOn :
Removable :
Replaceable :
SerialNumber :
SKU :
Speed :
Status :
Tag : Physical Memory 0
TotalWidth : 64
TypeDetail : 128
Version :
BankLabel : BANK1
Capacity : 16777216
Caption : Mémoire physique
CreationClassName : Win32_PhysicalMemory
DataWidth : 72
Description : Mémoire physique
DeviceLocator : DIMM2
FormFactor : 8
HotSwappable :
InstallDate :
InterleaveDataDepth : 1
InterleavePosition : 0
Manufacturer :
MemoryType : 17
Model :
Name : Mémoire physique
OtherIdentifyingInfo :
PartNumber :
PositionInRow : 1
PoweredOn :
Removable :
Replaceable :
SerialNumber :
SKU :
Speed :
Status :
Tag : Physical Memory 1
TotalWidth : 64
TypeDetail : 128
Version :
BankLabel : BANK1
Capacity : 16777216
Caption : Mémoire physique
CreationClassName : Win32_PhysicalMemory
DataWidth : 72
Description : Mémoire physique
DeviceLocator : DIMM2
FormFactor : 8
HotSwappable :
InstallDate :
InterleaveDataDepth : 1
InterleavePosition : 0
Manufacturer :
MemoryType : 17
Model :
Name : Mémoire physique
OtherIdentifyingInfo :
PartNumber :
PositionInRow : 1
PoweredOn :
Removable :
Replaceable :
SerialNumber :
SKU :
Speed :
Status :
Tag : Physical Memory 2
TotalWidth : 64
TypeDetail : 128
Version :
BankLabel : BANK1
Capacity : 16777216
Caption : Mémoire physique
CreationClassName : Win32_PhysicalMemory
DataWidth : 72
Description : Mémoire physique
DeviceLocator : DIMM2
FormFactor : 8
HotSwappable :
InstallDate :
InterleaveDataDepth : 1
InterleavePosition : 0
Manufacturer :
MemoryType : 17
Model :
Name : Mémoire physique
OtherIdentifyingInfo :
PartNumber :
PositionInRow : 1
PoweredOn :
Removable :
Replaceable :
SerialNumber :
SKU :
Speed :
Status :
Tag : Physical Memory 3
TotalWidth : 64
TypeDetail : 128
Version : |