怎么查看一个进程消耗多少内存,占用多少cpu?并将这些数据输出到一个文档中,请高手不吝赐教

如何查看一个进程消耗多少内存,占用多少cpu?并将这些数据输出到一个文档中,请高手不吝赐教
如题,哪位大侠伸伸手,小弟着急啊!

  有没有什么合适的软件,不要多大的功能的,只要能够如查看一个进程消耗多少内存,占用多少cpu,并将这些数据输出到一个文档中,就可以了.

------解决方案--------------------
这个我熟,^_^
------解决方案--------------------
万一人家问的是linux:)
还是用p6的标准函数吧,linux和windows都支持
------解决方案--------------------
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.WIN32COM.v10.en/perfmon/base/collecting_memory_usage_information_for_a_process.htm

Collecting Memory Usage Information For a Process
To determine the efficiency of your application, you may want to examine its memory usage. The following sample code uses the GetProcessMemoryInfo function to obtain information about the memory usage of a process.


#include <windows.h>
#include <stdio.h>
#include "psapi.h "

void PrintMemoryInfo( DWORD processID )
{
HANDLE hProcess;
PROCESS_MEMORY_COUNTERS pmc;

// Print the process identifier.

printf( "\nProcess ID: %u\n ", processID );

// Print information about the memory usage of the process.

hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
if (NULL == hProcess)
return;

if ( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)) )
{
printf( "\tPageFaultCount: 0x%08X\n ", pmc.PageFaultCount );
printf( "\tPeakWorkingSetSize: 0x%08X\n ",
pmc.PeakWorkingSetSize );
printf( "\tWorkingSetSize: 0x%08X\n ", pmc.WorkingSetSize );
printf( "\tQuotaPeakPagedPoolUsage: 0x%08X\n ",
pmc.QuotaPeakPagedPoolUsage );
printf( "\tQuotaPagedPoolUsage: 0x%08X\n ",
pmc.QuotaPagedPoolUsage );
printf( "\tQuotaPeakNonPagedPoolUsage: 0x%08X\n ",
pmc.QuotaPeakNonPagedPoolUsage );
printf( "\tQuotaNonPagedPoolUsage: 0x%08X\n ",
pmc.QuotaNonPagedPoolUsage );
printf( "\tPagefileUsage: 0x%08X\n ", pmc.PagefileUsage );
printf( "\tPeakPagefileUsage: 0x%08X\n ",
pmc.PeakPagefileUsage );
}

CloseHandle( hProcess );
}

void main( )
{
// Get the list of process identifiers.

DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;

if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return;

// Calculate how many process identifiers were returned.

cProcesses = cbNeeded / sizeof(DWORD);

// Print the memory usage for each process

for ( i = 0; i < cProcesses; i++ )
PrintMemoryInfo( aProcesses[i] );
}

The main function obtains a list of processes by using the EnumProcesses function. For each process, main calls the PrintMemoryInfo function, passing the process identifier. PrintMemoryInfo in turn calls the OpenProcess function to obtain the process handle. If OpenProcess fails, the output shows only the process identifier. For example, OpenProcess fails for the Idle and CSRSS processes because their access restrictions prevent user-level code from opening them. Finally, PrintMemoryInfo calls the GetProcessMemoryInfo function to obtain the memory usage information.