IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++/CLI Discussion :

WMI et infos mémoire vive


Sujet :

C++/CLI

  1. #1
    Membre actif

    Profil pro
    Inscrit en
    Juin 2003
    Messages
    73
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Loiret (Centre)

    Informations forums :
    Inscription : Juin 2003
    Messages : 73
    Points : 218
    Points
    218
    Par défaut WMI et infos mémoire vive
    Bonjour,

    j'utilise ce code pour intéroger la mémoire de l'ordinateur.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 :

  2. #2
    Membre actif

    Profil pro
    Inscrit en
    Juin 2003
    Messages
    73
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Loiret (Centre)

    Informations forums :
    Inscription : Juin 2003
    Messages : 73
    Points : 218
    Points
    218
    Par défaut
    Pour info, j'ai trouvé : il fallait utiliser cette requête :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    SELECT TotalPhysicalMemory FROM Win32_ComputerSystem

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Info]Mémoire utilisée
    Par lr dans le forum Eclipse Java
    Réponses: 6
    Dernier message: 24/10/2005, 11h34
  2. [Info][Mémoire] utilisée pour un pointeur null
    Par thomas_strass dans le forum Langage
    Réponses: 14
    Dernier message: 04/11/2004, 13h48
  3. Processus Sql Server prend toute la mémoire vive
    Par cracosore dans le forum MS SQL Server
    Réponses: 9
    Dernier message: 19/02/2004, 18h53
  4. [API] mémoire vive
    Par Halleck dans le forum Windows
    Réponses: 8
    Dernier message: 29/01/2004, 01h17
  5. Utilisation de la mémoire vive....
    Par Neilos dans le forum Windows
    Réponses: 9
    Dernier message: 24/11/2003, 12h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo