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 124 125 126 127
|
//------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <iostream>
using namespace std;
//#include <windows.h>
#include <psapi.h> // For PPROCESS_MEMORY_COUNTERS
#include "Unit1.h"
//------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#pragma argsused
TForm1 *Form1;
//------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner){}
//------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{ // Variables
DWORD processId; // Id of the process
HANDLE hProcess; // Handle to the process
PROCESS_MEMORY_COUNTERS psmemCounters; // GetProcessMemoryInfo( HANDLE Process,PPROCESS_MEMORY_COUNTERS ppsmemCounters, DWORD cb );
PERFORMACE_INFORMATION pPerformanceInformation; // GetPerformanceInfo ( PPERFORMACE_INFORMATION pPerformanceInformation, DWORD cb );
ENUM_PAGE_FILE_INFORMATION pCallBackRoutine; // EnumPageFilesW ( PENUM_PAGE_FILE_CALLBACKW pCallBackRoutine,LPVOID pContext );
// Get and display the current process Id
// processId=GetCurrentProcessId();
// cout << "Current process Id : " << processId << endl;
// Open the process
// if( (hProcess=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ , TRUE, processId)) == NULL)
// {cout << "Unable to open the process : " << GetLastError() << endl; }
// if (GetProcessMemoryInfo( hProcess, &psmemCounters, sizeof(psmemCounters)) )
// {cout << "Unable to ................ : " << GetLastError() << endl; }
Memo1->Clear();
Memo1->Lines->Add("PROCESS_MEMORY_COUNTERS psmemCounters;");
Longint Ram1 = psmemCounters.cb;
Longint Ram2 = psmemCounters.PageFaultCount;
Longint Ram3 = psmemCounters.PeakWorkingSetSize;
Longint Ram4 = psmemCounters.WorkingSetSize;
Longint Ram5 = psmemCounters.QuotaPeakPagedPoolUsage;
Longint Ram6 = psmemCounters.QuotaPagedPoolUsage;
Longint Ram7 = psmemCounters.QuotaPeakNonPagedPoolUsage;
Longint Ram8 = psmemCounters.QuotaNonPagedPoolUsage;
Longint Ram9 = psmemCounters.PagefileUsage;
Longint Ram10= psmemCounters.PeakPagefileUsage;
Memo1->Lines->Add("cb");
Memo1->Lines->Add(Ram1);
Memo1->Lines->Add("PageFaultCount");
Memo1->Lines->Add(Ram2);
Memo1->Lines->Add("PeakWorkingSetSize");
Memo1->Lines->Add(Ram3);
Memo1->Lines->Add("WorkingSetSize");
Memo1->Lines->Add(Ram4);
Memo1->Lines->Add("QuotaPeakPagedPoolUsage");
Memo1->Lines->Add(Ram5);
Memo1->Lines->Add("QuotaPagedPoolUsage");
Memo1->Lines->Add(Ram6);
Memo1->Lines->Add("QuotaPeakNonPagedPoolUsage");
Memo1->Lines->Add(Ram7);
Memo1->Lines->Add("QuotaNonPagedPoolUsage");
Memo1->Lines->Add(Ram8);
Memo1->Lines->Add("PagefileUsage");
Memo1->Lines->Add(Ram9);
Memo1->Lines->Add("PeakPagefileUsage");
Memo1->Lines->Add(Ram10);
Memo1->Lines->Add("PERFORMACE_INFORMATION pPerformanceInformation");
Longint Ram11 = pPerformanceInformation.cb;
Longint Ram12 = pPerformanceInformation.CommitTotal;
Longint Ram13 = pPerformanceInformation.CommitLimit;
Longint Ram14 = pPerformanceInformation.CommitPeak;
Longint Ram15 = pPerformanceInformation.PhysicalTotal;
Longint Ram16 = pPerformanceInformation.PhysicalAvailable;
Longint Ram17 = pPerformanceInformation.SystemCache;
Longint Ram18 = pPerformanceInformation.KernelTotal;
Longint Ram19 = pPerformanceInformation.KernelPaged;
Longint Ram20 = pPerformanceInformation.KernelNonpaged;
Longint Ram21 = pPerformanceInformation.PageSize;
Longint Ram22 = pPerformanceInformation.HandleCount;
Longint Ram23 = pPerformanceInformation.ProcessCount;
Longint Ram24 = pPerformanceInformation.ThreadCount;
Memo1->Lines->Add("cb");
Memo1->Lines->Add(Ram11);
Memo1->Lines->Add("CommitTotal");
Memo1->Lines->Add(Ram12);
Memo1->Lines->Add("CommitLimit");
Memo1->Lines->Add(Ram13);
Memo1->Lines->Add("CommitPeak");
Memo1->Lines->Add(Ram14);
Memo1->Lines->Add("PhysicalTotal");
Memo1->Lines->Add(Ram15);
Memo1->Lines->Add("PhysicalAvailable");
Memo1->Lines->Add(Ram16);
Memo1->Lines->Add("SystemCache");
Memo1->Lines->Add(Ram17);
Memo1->Lines->Add("KernelTotal");
Memo1->Lines->Add(Ram18);
Memo1->Lines->Add("KernelPaged");
Memo1->Lines->Add(Ram19);
Memo1->Lines->Add("KernelNonpaged");
Memo1->Lines->Add(Ram20);
Memo1->Lines->Add("PageSize");
Memo1->Lines->Add(Ram21);
Memo1->Lines->Add("HandleCount");
Memo1->Lines->Add(Ram22);
Memo1->Lines->Add("ProcessCount");
Memo1->Lines->Add(Ram23);
Memo1->Lines->Add("ThreadCount");
Memo1->Lines->Add(Ram24);
Memo1->Lines->Add("ENUM_PAGE_FILE_INFORMATION pCallBackRoutine"); // EnumPageFilesW ( PENUM_PAGE_FILE_CALLBACKW pCallBackRoutine,LPVOID pContext );
Longint Ram25 = pCallBackRoutine.cb;
Longint Ram26 = pCallBackRoutine.Reserved;
Longint Ram27 = pCallBackRoutine.TotalSize;
Longint Ram28 = pCallBackRoutine.TotalInUse;
Longint Ram29 = pCallBackRoutine.PeakUsage;
Memo1->Lines->Add("cb");
Memo1->Lines->Add(Ram25);
Memo1->Lines->Add("Reserved");
Memo1->Lines->Add(Ram26);
Memo1->Lines->Add("TotalSize");
Memo1->Lines->Add(Ram27);
Memo1->Lines->Add("TotalInUse");
Memo1->Lines->Add(Ram28);
Memo1->Lines->Add("PeakUsage");
Memo1->Lines->Add(Ram29);
} |
Partager