Bonjour,

je cherche à obtenir des informations sur l'utilisation mémoire de mon processus :

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
#include <iostream>

using namespace std;

#include <windows.h>
#include <psapi.h> // For PPROCESS_MEMORY_COUNTERS

int main()
{
    // Variables
    DWORD processId; // Id of the process
    HANDLE hProcess; // Handle to the process
    PPROCESS_MEMORY_COUNTERS ppsmemCounters; // Pointer to a PROCESS_MEMORY_COUNTERS structure

    // Get and display the current process Id
    processId=GetCurrentProcessId();
    cout << "Current process Id : " << processId << endl;

    // Open the process
    if( (hProcess=OpenProcess(PROCESS_QUERY_INFORMATION, TRUE, processId)) == NULL){
        cout << "Unable to open the process : " << GetLastError() << endl;
    }

    // Get information about the memory usage of this process
    if(GetProcessMemoryInfo(hProcess, ppsmemCounters, sizeof(ppsmemCounters))==0){
        cout << "Unable to get the process memory info : " << GetLastError() << endl;
    }


    return 0;
}
Résultat : "Unable to get the process memory info : 998".

Pouquoi?

Merci.