#include <iostream>
#include <iomanip>
#pragma comment (lib, "psapi.lib") // Add 'psapi.lib' to your linker options
#include <windows.h>
#include <psapi.h>
using namespace std;
int main()
{
// Open current process
HANDLE hProcess = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, ::GetCurrentProcessId());
if(hProcess)
{
PROCESS_MEMORY_COUNTERS ProcessMemoryCounters;
memset(&ProcessMemoryCounters, 0, sizeof(ProcessMemoryCounters));
// Set size of structure
ProcessMemoryCounters.cb = sizeof(ProcessMemoryCounters);
// Get memory usage
if(::GetProcessMemoryInfo(hProcess,
&ProcessMemoryCounters,
sizeof(ProcessMemoryCounters)) == TRUE)
{
std::cout << std::setfill('0') << std::hex
<< "PageFaultCount: 0x" << std::setw(8)
<< ProcessMemoryCounters.PageFaultCount << std::endl
<< "PeakWorkingSetSize: 0x" << std::setw(8)
<< ProcessMemoryCounters.PeakWorkingSetSize << std::endl
<< "WorkingSetSize: 0x" << std::setw(8)
<< ProcessMemoryCounters.WorkingSetSize << std::endl
<< "QuotaPeakPagedPoolUsage: 0x" << std::setw(8)
<< ProcessMemoryCounters.QuotaPeakPagedPoolUsage << std::endl
<< "QuotaPagedPoolUsage: 0x" << std::setw(8)
<< ProcessMemoryCounters.QuotaPagedPoolUsage << std::endl
<< "QuotaPeakNonPagedPoolUsage: 0x" << std::setw(8)
<< ProcessMemoryCounters.QuotaPeakNonPagedPoolUsage << std::endl
<< "QuotaNonPagedPoolUsage: 0x" << std::setw(8)
<< ProcessMemoryCounters.QuotaNonPagedPoolUsage << std::endl
<< "PagefileUsage: 0x" << std::setw(8)
<< ProcessMemoryCounters.PagefileUsage << std::endl
<< "PeakPagefileUsage: 0x" << std::setw(8)
<< ProcessMemoryCounters.PeakPagefileUsage <<std::endl;
}
else
std::cout << "Could not get memory usage (Error: "
<< ::GetLastError() << ")" << std::endl;
// Close process
::CloseHandle(hProcess);
}
else
std::cout << "Could not open process (Error "
<< ::GetLastError() << ")" << std::endl;
return 0;
}
#pragma comment(lib,"Ws2_32.lib")表示链接Ws2_32.lib这个库。和在工程设置里写上链入Ws2_32.lib的效果一样,不过这种方法写的程序别人在使用你的代码的时候就不用再设置工程settings了。
分享到:
相关推荐
In this update I have added the information about CPU vendor (Intel, Cyrix, AMD, etc.) ,CPU speed, and Physical memory status of sustem . CPU Information: To get CPU information I could not find ...
task’s priority, suspend and resume a task, and get information about a task. Chapter 5, Time Management This chapter describes how μC/OS-II can suspend a task’s execution until some user specified...
- pxwplan <sql_id> : get explain plan with work area information of a particular cursor and all connected cursor slave SQL - eplan <sql_id> []: get explain plan with execution statistics - pxeplan ...
Further on in the book, you will get to know about animation and still shots, and learn how to create advanced materials for realistic rendering, as well cartoon style shaders. This cookbook contains...
Capture detailed data about processors, memory, and clocks Troubleshoot unbootable devices, file-in-use errors, unexplained communication, and many other problems Understand Windows core concepts that...
We strongly recommend that you read the following information about this release. 1) IRPTrace Components ===================== README.TXT - This file HOWTOREG.TXT - How to register IRPTrace and ...
Get to know how to dump and analyze computer memory. In Detail Over the last few years, the wave of the cybercrime has risen rapidly. We have witnessed many major attacks on the governmental, ...
information about an updated RCD.SYS device driver. 2.4 Disk Manager ---------------- To upgrade Ontrack Computer System's Disk Manager, do the following: 1. Use the EXPAND command to expand and ...
1.11 How do I find out about a process' memory usage? 我怎样找出一个进程的存储器使用情况? 1.12 Why do processes never decrease in size? 为什么进程的大小不缩减? 1.13 How do I change the name of my ...
flag which can potentially be unclear about what you will get. This is especially important in macros and structures where register numbers may be unknown until instantiated. Both syntaxes support ...
Running tests with an in-memory database Handling HTTP clients and service discovery Implementing sample tests Integration tests Categorizing tests Capturing HTTP traffic Contract tests Using Pact ...
7)....Added: Streaming unpacked debug info into temporal files instead of memory - this greatly reduces run-time application memory usage at cost of slightly slower exception processing. This also ...
For more information about how to decode this value, see also… Inside SQL Server 2000, pages 803 and 806. Key Range Locking Key Range Locking To support SERIALIZABLE transaction semantics, ...
-advance / --advanced will launch advance parameters and information on the usage output -m / --match-original is a new feature for apk analysis. This retains the apk is nearly original format, but ...
If you convert multiple hundredthousands or millions of files the memory usage of convmv might grow quite high. This option would help you out in that case. --nosmart by default convmv will detect ...
An Easy Way to Remember the 8086 Memory Addressing Modes 4.6.2.8 - Some Final Comments About 8086 Addressing Modes 4.6.3 - 80386 Register Addressing Modes 4.6.4 - 80386 Memory Addressing ...
* Description: This is the Sample code to show the usage of EDSDK. * * * * * ******************************************************************************* * * * Written and developed by Camera ...
Diskeeper records information about its activity in two ways. First, general information about previously-run defragmentation job is shown in the Log tab within the Diskeeper console. Additional ...
Other information 1 Overview of the Assembler 1.1 About the ARM Compiler toolchain assemblers 1.2 Key features of the assembler 1.3 How the assembler works 1.4 Directives that can be omitted in pass 2...
application users can inadvertently leak otherwise secure information. ; This is php.ini-development INI file. ;;;;;;;;;;;;;;;;;;; ; Quick Reference ; ;;;;;;;;;;;;;;;;;;; ; The following are all ...