R
r2du-soft
Guest
i tried find a process memory usage by pid number
#include <windows.h>
#include <stdio.h>
#include <psapi.h>
#include <iostream>
using namespace std;
int main(void)
{
DWORD Process_PID = 7540;
HANDLE hProcess;
PROCESS_MEMORY_COUNTERS_EX PCM;
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION |PROCESS_VM_READ, FALSE, Process_PID);
if (GetProcessMemoryInfo(hProcess, (PROCESS_MEMORY_COUNTERS *)&PCM, sizeof(PCM)))
{
cout << PCM.WorkingSetSize << " IS WorkingSetSize";
cout << endl;
cout << PCM.PrivateUsage << " IS PrivateSetSize";
cout << endl;
cout << (PCM.PrivateUsage - PCM.WorkingSetSize) / 1024 << " KB";
cout << endl;
}
}
But i the return value is different value of task manager that process memory usage...
Which part of my calculation is wrong?
thanks
Continue reading...
#include <windows.h>
#include <stdio.h>
#include <psapi.h>
#include <iostream>
using namespace std;
int main(void)
{
DWORD Process_PID = 7540;
HANDLE hProcess;
PROCESS_MEMORY_COUNTERS_EX PCM;
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION |PROCESS_VM_READ, FALSE, Process_PID);
if (GetProcessMemoryInfo(hProcess, (PROCESS_MEMORY_COUNTERS *)&PCM, sizeof(PCM)))
{
cout << PCM.WorkingSetSize << " IS WorkingSetSize";
cout << endl;
cout << PCM.PrivateUsage << " IS PrivateSetSize";
cout << endl;
cout << (PCM.PrivateUsage - PCM.WorkingSetSize) / 1024 << " KB";
cout << endl;
}
}
But i the return value is different value of task manager that process memory usage...
Which part of my calculation is wrong?
thanks
Continue reading...