1   2   3   4   5   6
Ім'я файлу: Курсова.docx
Розширення: docx
Розмір: 588кб.
Дата: 25.10.2021
скачати
Пов'язані файли:
Варикозна хвороба вен нижніх кінцівок.docx
ВАРІАНТ №5.docx


lblParId->Text = ((unsigned)pe32.th32ParentProcessID).ToString();

lblName->Text = gcnew String(pe32.szExeFile);

break;

}

} while( Process32Next( hProcessSnap, &pe32 ) );
CloseHandle( hProcessSnap );
PPROCESS_MEMORY_COUNTERS ppsmemCounters ;

ppsmemCounters = new PROCESS_MEMORY_COUNTERS();

HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS,false,msg.ProcId);

GetProcessMemoryInfo(hProc, ppsmemCounters, sizeof(*ppsmemCounters));

lblPid->Text = ((unsigned)msg.ProcId ).ToString();

lblWS->Text = ((unsigned)ppsmemCounters->WorkingSetSize/ 1024).ToString() + " КБ";

lblPWSS->Text = ((unsigned)ppsmemCounters->PeakWorkingSetSize/ 1024).ToString() + " КБ";

lblPFU->Text = ((unsigned)ppsmemCounters->PagefileUsage/ 1024).ToString() + " КБ";

lblPPFU->Text = ((unsigned)ppsmemCounters->PeakPagefileUsage/ 1024).ToString() + " КБ";

// lblQPPPU->Text = ((unsigned)ppsmemCounters->QuotaPeakPagedPoolUsage/ 1024).ToString() + " КБ";

lblQPPU->Text = ((unsigned)ppsmemCounters->QuotaPagedPoolUsage/ 1024).ToString() + " КБ";

// lblQPNPPU->Text = ((unsigned)ppsmemCounters->QuotaPeakNonPagedPoolUsage/ 1024).ToString() + " КБ";

lblQNPPU->Text = ((unsigned)ppsmemCounters->QuotaNonPagedPoolUsage/ 1024).ToString() + " КБ";

picMem->Refresh();

picProc->Refresh();

CloseHandle(hProc);

}

else

msg.IsRunning = false;

}
private: void RefreshInf(bool atch)

{

if(!msg.IsRunning){

lstEvents->Items->Clear();
lblTHR->Text = "-";

lblParId->Text = "-";

lblName->Text ="-";

lblPid->Text ="-";

lblWS->Text = "-";

lblPWSS->Text = "-";

lblPFU->Text = "-";

lblPPFU->Text = "-";

// lblQPPPU->Text = "-";

lblQPPU->Text = "-";

// lblQPNPPU->Text = "-";

lblQNPPU->Text = "-";
msg.EventStrings = new list ();

msg.MemoryGlobalUsage = new deque ();

msg.MemoryProcUsage = new deque ();

msg.CPUglobalUsage = new deque ();

msg.CPUprocUsage = new deque ();

msg.IsRunning = true;
if(atch)

DebugEvents = gcnew Thread(gcnew ThreadStart(&AttchEx));

else

DebugEvents = gcnew Thread(gcnew ThreadStart(&StartEx));

DebugEvents->Priority = ThreadPriority::Highest;

DebugEvents->Start();
PerfInf = gcnew Thread(gcnew ThreadStart(&TakeInf));

PerfInf->Priority = ThreadPriority::Highest;

PerfInf->Start();
tmrTime->Enabled = true;

}

}
private: System::Void Form1_FormClosing(System::Object^ sender, System::Windows::Forms::FormClosingEventArgs^ e) {

msg.IsRunning = false;

}

private: System::Void picMem_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {

if(msg.IsRunning){
int top = 20;

int bot = 10;

int rgh = 10;

int lft = 45;

double stp ;

int cnt = msg.Count;


stp = (double)(picMem->Width - rgh - lft) / cnt;

System::Drawing::Font^ txtFont = gcnew System::Drawing::Font("Consolas",8);

Pen^ wPen = gcnew Pen(Color::White);

e->Graphics->SmoothingMode = System::Drawing::Drawing2D::SmoothingMode::AntiAlias;
if(msg.MemoryGlobalUsage->size() >= 2)

{

for(int i = msg.MemoryGlobalUsage->size()- 2; i >=0 ; i--)

{

e->Graphics->DrawLine(gcnew Pen(Color::Orange),

(int)((msg.MemoryGlobalUsage->size() - i ) * stp) + lft,

top + (picMem->Height - top - bot) * (1 - msg.MemoryGlobalUsage->at(i)),

(int)((msg.MemoryGlobalUsage->size()- i - 1) * stp) + lft,

top + (picMem->Height - top - bot) * (1 - msg.MemoryGlobalUsage->at(i + 1)));

}
int y = top + (picMem->Height - top - bot) * (1 - msg.MemoryGlobalUsage->back());

if(y > picMem->Height - bot - 10)

y -= 12;

if(y < top + 10)

y += 12;

e->Graphics->DrawString(

System::String::Format("{0,3}%",((unsigned)(msg.MemoryGlobalUsage->back() * 10000)) / 100.0),

txtFont,

gcnew SolidBrush( Color::White ),

3 ,

y);

}

if(msg.MemoryProcUsage->size() >= 2)

{

for(int i = msg.MemoryProcUsage->size()- 2; i >=0 ; i--)

{

e->Graphics->DrawLine(gcnew Pen(Color::LightSeaGreen),

(int)((msg.MemoryProcUsage->size() - i ) * stp) + lft,

top + (picMem->Height - top - bot) * (1 - msg.MemoryProcUsage->at(i)),

(int)((msg.MemoryProcUsage->size()- i - 1) * stp) + lft,

top + (picMem->Height - top - bot) * (1 - msg.MemoryProcUsage->at(i + 1)));

}
int y = top + (picMem->Height - top - bot) * (1 - msg.MemoryProcUsage->back());

if(y > picMem->Height - bot - 10)

y -= 12;

if(y < top + 10)

y += 12;

e->Graphics->DrawString(

System::String::Format("{0,3}%",((unsigned)(msg.MemoryProcUsage->back() * 10000)) / 100.0),

txtFont,

gcnew SolidBrush( Color::White ),

3 ,

y);

}
e->Graphics->DrawString(

"Графік використання оперативної пам'яті.",

txtFont,

gcnew SolidBrush( Color::White ),

40 ,

6);
e->Graphics->DrawRectangle(gcnew Pen(Color::White), lft, top, picMem->Width - lft - rgh, picMem->Height- top - bot );

//Малювання позначок осей ординат

for(int i = 0; i < 21; i++)

{

double stp = (double)(picMem->Height - top - bot) / 20;

e->Graphics->DrawLine(wPen, lft - 3, top + stp * i, lft, top + stp * i);

}

for(int i = 0; i < 101; i++)

{

double stp = (double)(picMem->Height - top - bot) / 100;

e->Graphics->DrawLine(wPen, lft - 1, top + stp * i, lft, top + stp * i);

}

}

}
private: System::Void picProc_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {

if(msg.IsRunning){
int top = 20;

int bot = 10;

int rgh = 10;

int lft = 45;

double stp ;

int cnt = msg.Count;

System::Drawing::Font^ txtFont = gcnew System::Drawing::Font("Consolas",8);

Pen^ wPen = gcnew Pen(Color::White);

e->Graphics->SmoothingMode = System::Drawing::Drawing2D::SmoothingMode::AntiAlias;

stp = (double)(picProc->Width - rgh - lft) / cnt;
if(msg.CPUglobalUsage->size() >= 2)

{

for(int i = msg.CPUglobalUsage->size()- 2; i >=0 ; i--)

{

e->Graphics->DrawLine(gcnew Pen(Color::Orange),

(int)((msg.CPUglobalUsage->size() - i ) * stp) + lft,

top + (picProc->Height - top - bot) * (1 - msg.CPUglobalUsage->at(i)),

(int)((msg.CPUglobalUsage->size()- i - 1) * stp) + lft,

top + (picProc->Height - top - bot) * (1 - msg.CPUglobalUsage->at(i + 1)));

}
int y = top + (picProc->Height - top - bot) * (1 - msg.CPUglobalUsage->back());

if(y > picProc->Height - bot - 10)

y -= 12;

if(y < top + 10)

y += 12;

e->Graphics->DrawString(

System::String::Format("{0,3}%",((unsigned)(msg.CPUglobalUsage->back() * 10000)) / 100.0),

txtFont,

gcnew SolidBrush( Color::White ),

3 ,

y);

}
if(msg.CPUprocUsage->size() >= 2)

{

for(int i = msg.CPUprocUsage->size()- 2; i >=0 ; i--)

{

e->Graphics->DrawLine(gcnew Pen(Color::LightSeaGreen),

(int)((msg.CPUprocUsage->size() - i ) * stp) + lft,

top + (picProc->Height - top - bot) * (1 - msg.CPUprocUsage->at(i)),

(int)((msg.CPUprocUsage->size()- i - 1) * stp) + lft,

top + (picProc->Height - top - bot) * (1 - msg.CPUprocUsage->at(i + 1)));

}
int y = top + (picProc->Height - top - bot) * (1 - msg.CPUprocUsage->back());

if(y > picProc->Height - bot - 10)

y -= 12;

if(y < top + 10)

y += 12;

e->Graphics->DrawString(

System::String::Format("{0,3}%",((unsigned)(msg.CPUprocUsage->back() * 10000)) / 100.0),

txtFont,

gcnew SolidBrush( Color::White ),

3 ,

y);

}

e->Graphics->DrawString(

"Графік використання процесорного часу",

txtFont,

gcnew SolidBrush( Color::White ),

40 ,

6);
e->Graphics->DrawRectangle(gcnew Pen(Color::White), lft, top, picProc->Width - lft - rgh, picProc->Height- top - bot );

//Малювання позначок осей ординат

for(int i = 0; i < 21; i++)

{

double stp = (double)(picProc->Height - top - bot) / 20;

e->Graphics->DrawLine(wPen, lft - 3, top + stp * i, lft, top + stp * i);

}

for(int i = 0; i < 101; i++)

{

double stp = (double)(picProc->Height - top - bot) / 100;

e->Graphics->DrawLine(wPen, lft - 1, top + stp * i, lft, top + stp * i);

}

}

}
};

}
Файл SchooseProc.h

//using namespace System;
#pragma once
#include

#include

#include
namespace kursec {
using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

using namespace System::Collections::Generic;
///

/// Summary for ChooseProc

///


public ref class ChooseProc : public System::Windows::Forms::Form

{

public:

ChooseProc(void)

{

InitializeComponent();

lstProcsId = gcnew List();

//

//TODO: Add the constructor code here

//

}
protected:

///

/// Clean up any resources being used.

///


ChooseProc()

{

if (components)

{

delete components;

}

}

private: System::Windows::Forms::ListBox^ lstProcs;

protected:
protected:

public: DWORD ProcId;

private: System::Windows::Forms::GroupBox^ groupBox1;

private: System::Windows::Forms::Button^ button2;

private: System::Windows::Forms::Button^ button1;

private: List^ lstProcsId;

private: System::Windows::Forms::Button^ button3;

private: System::Windows::Forms::Label^ lblProcName;
private: System::ComponentModel::IContainer^ components;
//private: System::Windows::Forms::Timer^ tmrRefresh;

///

/// Required designer variable.

///


#pragma region Windows Form Designer generated code

///

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

///


void InitializeComponent(void)

{

this->lstProcs = (gcnew System::Windows::Forms::ListBox());

this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());

this->button3 = (gcnew System::Windows::Forms::Button());

this->button2 = (gcnew System::Windows::Forms::Button());

this->button1 = (gcnew System::Windows::Forms::Button());

this->lblProcName = (gcnew System::Windows::Forms::Label());

this->groupBox1->SuspendLayout();

this->SuspendLayout();

//

// lstProcs

//

this->lstProcs->CausesValidation = false;

this->lstProcs->Font = (gcnew System::Drawing::Font(L"Consolas", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,

static_cast(204)));

this->lstProcs->FormattingEnabled = true;

this->lstProcs->Location = System::Drawing::Point(0, 1);

this->lstProcs->Name = L"lstProcs";

this->lstProcs->Size = System::Drawing::Size(408, 381);

this->lstProcs->TabIndex = 2;

this->lstProcs->TabStop = false;

this->lstProcs->DoubleClick += gcnew System::EventHandler(this, &ChooseProc::lstProcs_DoubleClick);

//

// groupBox1

//

this->groupBox1->Controls->Add(this->button3);

this->groupBox1->Controls->Add(this->button2);

this->groupBox1->Controls->Add(this->button1);

this->groupBox1->Dock = System::Windows::Forms::DockStyle::Bottom;

this->groupBox1->Location = System::Drawing::Point(0, 402);

this->groupBox1->Name = L"groupBox1";

this->groupBox1->Size = System::Drawing::Size(408, 45);

this->groupBox1->TabIndex = 3;

this->groupBox1->TabStop = false;

//

// button3

//

this->button3->Location = System::Drawing::Point(12, 13);

this->button3->Name = L"button3";

this->button3->Size = System::Drawing::Size(75, 23);

this->button3->TabIndex = 3;

this->button3->Text = L"Оновити";

this->button3->UseVisualStyleBackColor = true;

this->button3->Click += gcnew System::EventHandler(this, &ChooseProc::button3_Click);

//

// button2

//

this->button2->DialogResult = System::Windows::Forms::DialogResult::Cancel;

this->button2->Location = System::Drawing::Point(321, 13);

this->button2->Name = L"button2";

this->button2->Size = System::Drawing::Size(75, 23);

this->button2->TabIndex = 2;

this->button2->Text = L"Відмінити";

this->button2->UseVisualStyleBackColor = true;

this->button2->Click += gcnew System::EventHandler(this, &ChooseProc::button2_Click);

//

// button1

//

this->button1->DialogResult = System::Windows::Forms::DialogResult::OK;

this->button1->Enabled = false;

this->button1->Location = System::Drawing::Point(240, 13);

this->button1->Name = L"button1";

this->button1->Size = System::Drawing::Size(75, 23);

this->button1->TabIndex = 1;

this->button1->Text = L"OK";

this->button1->UseVisualStyleBackColor = true;

this->button1->Click += gcnew System::EventHandler(this, &ChooseProc::button1_Click);

//

// lblProcName

//

this->lblProcName->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;

this->lblProcName->Dock = System::Windows::Forms::DockStyle::Bottom;

this->lblProcName->Location = System::Drawing::Point(0, 382);

this->lblProcName->Name = L"lblProcName";

this->lblProcName->Size = System::Drawing::Size(408, 20);

this->lblProcName->TabIndex = 4;

//

// ChooseProc

//

this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

this->ClientSize = System::Drawing::Size(408, 447);

this->Controls->Add(this->lblProcName);

this->Controls->Add(this->lstProcs);

this->Controls->Add(this->groupBox1);

this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog;

this->MaximizeBox = false;

this->MinimizeBox = false;

this->Name = L"ChooseProc";

this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent;

this->Text = L"Виберіть процес";

this->Load += gcnew System::EventHandler(this, &ChooseProc::ChooseProc_Load);

this->groupBox1->ResumeLayout(false);

this->ResumeLayout(false);
}

#pragma endregion
void GetProcessList()

{

HANDLE hProcessSnap;

PROCESSENTRY32 pe32;
lstProcs->Items->Clear();

if(lstProcsId->Count != 0)

lstProcsId->Clear();

hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );

if( hProcessSnap == INVALID_HANDLE_VALUE )

return;

pe32.dwSize = sizeof( PROCESSENTRY32 );

if( !Process32First( hProcessSnap, &pe32 ) )

{

CloseHandle( hProcessSnap );

return;

}
do

{

if (OpenProcess(PROCESS_ALL_ACCESS, false, pe32.th32ProcessID ))

{

lstProcs->Items->Add( String::Format ("{0,-30} 0x{1,-8:X} {1,-8}",gcnew String(pe32.szExeFile),(unsigned) pe32.th32ProcessID));

lstProcsId->Add(pe32.th32ProcessID);

}

} while( Process32Next( hProcessSnap, &pe32 ) );
CloseHandle( hProcessSnap );

}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

this->Close();

}

private: System::Void ChooseProc_Load(System::Object^ sender, System::EventArgs^ e) {

GetProcessList();

}

private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {


1   2   3   4   5   6

скачати

© Усі права захищені
написати до нас