사용자 삽입 이미지

 
// Program Name : PROCESS COUNTER
// Written by Hoon-seung Jeong

// Consultation http://support.microsoft.com/kb/175030/ko


#include <iostream>
#include <windows.h>
// For Windows API function
#include <time.h>
// For time of day
#include <tlhelp32.h>
// For process count of Windows XP
using namespace std;
void Process_Count();
int main()
{
    while(1)
    {
        Process_Count();
    }
    return 0;
}
void Process_Count()
{
    int number=0;
// Initialization 0
    time_t now;
// Declare time struct
    now = time(NULL); // Time function
    HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); // This function has system information
    if(snap) // Excution snapshat handle
    {
        BOOL p_Count;
// For count process
        PROCESSENTRY32 p_Entry; // Declare process struct
        p_Entry.dwSize = sizeof(PROCESSENTRY32); // A Function of PROCESSENTRY32
        p_Count = Process32First(snap, &p_Entry); // Search a executing process
        while(p_Count)
        {
            p_Count = Process32Next(snap, &p_Entry);
// Repeat to search executing process
            number++;
// Increase number of executing process
        }
        CloseHandle(snap); // Close snapshot handle
    }
    cout << asctime(localtime(&now)); // Print time of day
    cout << "\tNumber of executing process : " << number << "\n"; // Print number of executing process
    Sleep(1000);
// 1000 is 1 second
}

프로그램 제목 : Process Counter

윈도우상에서 컨트롤+알트+델 누르면
윈도우즈 작업관리자가 뜨는데
왼쪽 하단에 현재 실행중인 프로세스 개수가 뜬다.

그걸 콘솔모드(도스모드) 프로그램으로 해본 것...
Posted by 정훈승