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

GetProcessList();

lblProcName->Text = "";

button1->Enabled = false;

}

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

if(lstProcs->SelectedIndex != 0)

{

lblProcName->Text =

lstProcs->Items[lstProcs->SelectedIndex]->ToString();

button1->Enabled = true;

}

}

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

DWORD pid = lstProcsId[lstProcs->Items->IndexOf(lblProcName->Text)];

HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS,false, pid);

if (hProc == NULL || hProc == INVALID_HANDLE_VALUE)

{

MessageBox::Show(

"Вибраний процес не існує або недосяжний!",

"Повідомлення", MessageBoxButtons::OK,

MessageBoxIcon::Warning);

GetProcessList();

return;

}

ProcId = lstProcsId[lstProcs->Items->IndexOf(lblProcName->Text)];

}

};

}

Файл StartProc.h

#pragma once
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;
///

/// Summary for StartProc

///


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

{

public:

StartProc(void)

{

InitializeComponent();

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

//

//TODO: Add the constructor code here

//

}
protected:

///

/// Clean up any resources being used.

///


StartProc()

{

if (components)

{

delete components;

}

}

private: System::Windows::Forms::TextBox^ txtFileName;

private: System::Windows::Forms::TextBox^ txtCmdLine;

protected:
protected:
//public: bool IsOk;

public: String^ FileName;

public: String^ CmdLine;
private: System::Windows::Forms::Label^ label1;

private: System::Windows::Forms::Label^ label2;

private: System::Windows::Forms::Button^ btnSearch;
private: System::Windows::Forms::Button^ btnOk;

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

private: System::Windows::Forms::OpenFileDialog^ dlgOpen;
private:

///

/// Required designer variable.

///


System::ComponentModel::Container ^components;
#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->txtFileName = (gcnew System::Windows::Forms::TextBox());

this->txtCmdLine = (gcnew System::Windows::Forms::TextBox());

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

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

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

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

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

this->dlgOpen = (gcnew System::Windows::Forms::OpenFileDialog());

this->SuspendLayout();

//

// txtFileName

//

this->txtFileName->Location = System::Drawing::Point(113, 30);

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

this->txtFileName->Size = System::Drawing::Size(415, 20);

this->txtFileName->TabIndex = 0;

//

// txtCmdLine

//

this->txtCmdLine->Location = System::Drawing::Point(113, 56);

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

this->txtCmdLine->Size = System::Drawing::Size(415, 20);

this->txtCmdLine->TabIndex = 2;

//

// label1

//

this->label1->AutoSize = true;

this->label1->Location = System::Drawing::Point(0, 59);

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

this->label1->Size = System::Drawing::Size(107, 13);

this->label1->TabIndex = 2;

this->label1->Text = L"Параметри запуску";

//

// label2

//

this->label2->AutoSize = true;

this->label2->Location = System::Drawing::Point(39, 33);

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

this->label2->Size = System::Drawing::Size(68, 13);

this->label2->TabIndex = 3;

this->label2->Text = L"Імя процесу";

//

// btnSearch

//

this->btnSearch->Location = System::Drawing::Point(540, 28);

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

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

this->btnSearch->TabIndex = 1;

this->btnSearch->Text = L"огляд...";

this->btnSearch->UseVisualStyleBackColor = true;

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

//

// btnOk

//

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

this->btnOk->Location = System::Drawing::Point(453, 116);

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

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

this->btnOk->TabIndex = 3;

this->btnOk->Text = L"ОК";

this->btnOk->UseVisualStyleBackColor = true;

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

//

// btnCancel

//

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

this->btnCancel->Location = System::Drawing::Point(540, 116);

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

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

this->btnCancel->TabIndex = 4;

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

this->btnCancel->UseVisualStyleBackColor = true;

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

//

// dlgOpen

//

this->dlgOpen->Filter = L"Виконавчі файли|*.exe";

//

// StartProc

//

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

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

this->ClientSize = System::Drawing::Size(627, 151);

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

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

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

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

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

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

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

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

this->MaximizeBox = false;

this->MinimizeBox = false;

this->Name = L"StartProc";

this->Text = L"Запустити процес";

this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &StartProc::StartProc_FormClosing);

this->ResumeLayout(false);

this->PerformLayout();
}

#pragma endregion

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

if(dlgOpen->ShowDialog() != System::Windows::Forms::DialogResult::Cancel)

{

txtFileName->Text = dlgOpen->FileName;

FileName = dlgOpen->FileName;

}

}

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

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

this->Close();

}

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

if(dlgOpen->FileName != "")

{

FileName = txtFileName->Text;

CmdLine = txtCmdLine->Text;

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

this->Close();

}

}

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

if(this->FileName == "")

{

//if(this->this->DialogResult = System::Windows::Forms::DialogResult::Cancel)

txtFileName->Text = "";

txtCmdLine->Text = "";

}

}

};

}
1   2   3   4   5   6

скачати

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