Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- #include "Unit2.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::N2Click(TObject *Sender)
- {
- Form1->Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::N1Click(TObject *Sender)
- {
- Form2->Top=300;
- Form2->Left=300;
- Form2->Show();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- if(PriznakPr==0)
- {
- PriznakPr=1;
- Button1->Caption="Çóïèíèòè";
- hThreads[0]=0;
- hThreads[1]=0;
- hThreads[2]=0;
- PriznKPr1=0;
- PriznKPr2=0;
- PriznKPr3=0;
- Edit2->Text = 0;
- Edit4->Text = 0;
- Edit6->Text = 0;
- }
- else
- {
- PriznakPr=0;
- Button1->Caption="Ñòàðòóâàòè";
- CheckBox1->Checked=false;
- CheckBox2->Checked=false;
- CheckBox3->Checked=false;
- PriznakPr1=0;
- PriznakPr2=0;
- PriznakPr3=0;
- }
- if(PriznakPr==1)
- {
- ///////////////////////////////////////////////////
- TStartupInfo si;
- TProcessInformation pi;
- AnsiString cmdline;
- ZeroMemory(&si,sizeof (si));
- si.cb = sizeof(si);
- DWORD vpr1=NORMAL_PRIORITY_CLASS;
- DWORD vpr2=NORMAL_PRIORITY_CLASS;
- DWORD vpr3=NORMAL_PRIORITY_CLASS;
- ///////////////////////////////////////////////////
- //DateTimePr=Time();
- if(PriznakPr1==1)
- {
- cmdline = "proces1.exe "+Edit1->Text; // çàïóñêàåì ýòó ïðîãðàììó
- DateTimePr1=Time();
- if(!CreateProcess(NULL, // No module name (use command line).
- cmdline.c_str(), // Command line.
- NULL, // Process handle not inheritable.
- NULL, // Thread handle not inheritable.
- false, // Set handle inheritance to FALSE.
- 0, // No creation flags.
- NULL, // Use parent's environment block.
- NULL, // Use parent's starting directory.
- &si, // Pointer to STARTUPINFO structure.
- &pi)) // Pointer to PROCESS_INFORMATION structure.
- {
- ShowMessage("CreateProcess failed.");
- }
- else
- {
- hProces1=pi.hProcess;
- switch (ComboBox1->ItemIndex)
- {
- case 0 : vpr1=REALTIME_PRIORITY_CLASS;
- break;
- case 1 : vpr1=HIGH_PRIORITY_CLASS;
- break;
- case 2 : vpr1=NORMAL_PRIORITY_CLASS;
- break;
- case 3 : vpr1=IDLE_PRIORITY_CLASS;
- break;
- default :
- vpr1=NORMAL_PRIORITY_CLASS;
- }
- SetPriorityClass(hProces1,vpr1);
- ProcesCode1=0;
- hThreads[0]=hProces1;
- if(CheckBox1->Checked==true)
- {
- WaitForMultipleObjects(1, &hThreads[0], TRUE, INFINITE);
- DateTimePr1=Time()-DateTimePr1;
- Edit2->Text=DateTimePr1;
- TerminateProcess(hProces1,100);
- }
- }
- } // if(PriznakPr1==1)
- else
- {
- PriznKPr1=1;
- //DateTimePr1=0;
- }
- //////////////////////////////////////////////////
- ///////////////////////////////////////////////////
- if(PriznakPr2==1)
- {
- cmdline = "proces2.exe "+Edit3->Text; // çàïóñêàåì ýòó ïðîãðàììó
- DateTimePr2=Time();
- if (!CreateProcess( NULL, // No module name (use command line).
- cmdline.c_str(), // Command line.
- NULL, // Process handle not inheritable.
- NULL, // Thread handle not inheritable.
- false, // Set handle inheritance to FALSE.
- 0, // No creation flags.
- NULL, // Use parent's environment block.
- NULL, // Use parent's starting directory.
- &si, // Pointer to STARTUPINFO structure.
- &pi )) // Pointer to PROCESS_INFORMATION structure.
- {
- ShowMessage("CreateProcess failed.");
- }
- else
- {
- hProces2=pi.hProcess;
- switch (ComboBox2->ItemIndex)
- {
- case 0 : vpr2=REALTIME_PRIORITY_CLASS;
- break;
- case 1 : vpr2=HIGH_PRIORITY_CLASS;
- break;
- case 2 : vpr2=NORMAL_PRIORITY_CLASS;
- break;
- case 3 : vpr2=IDLE_PRIORITY_CLASS;
- break;
- default :
- vpr2=NORMAL_PRIORITY_CLASS;
- }
- SetPriorityClass(hProces2,vpr2);
- hThreads[1]=hProces2;
- if(CheckBox2->Checked==true)
- {
- WaitForMultipleObjects(1, &hThreads[1], TRUE, INFINITE);
- DateTimePr2 = Time() - DateTimePr2;
- Edit4->Text = DateTimePr2;
- TerminateProcess(hProces2,100);
- }
- }
- } // if(PriznakPr2==1)
- else
- {
- PriznKPr2=1;
- DateTimePr2=0;
- }
- //////////////////////////////////////////////////
- ///////////////////////////////////////////////////
- if(PriznakPr3==1)
- {
- cmdline = "proces3.exe "+Edit5->Text; // çàïóñêàåì ýòó ïðîãðàììó
- DateTimePr3=Time();
- if (!CreateProcess( NULL, // No module name (use command line).
- cmdline.c_str(), // Command line.
- NULL, // Process handle not inheritable.
- NULL, // Thread handle not inheritable.
- false, // Set handle inheritance to FALSE.
- 0, // No creation flags.
- NULL, // Use parent's environment block.
- NULL, // Use parent's starting directory.
- &si, // Pointer to STARTUPINFO structure.
- &pi )) // Pointer to PROCESS_INFORMATION structure.
- {
- ShowMessage("CreateProcess failed.");
- }
- else
- {
- hProces3=pi.hProcess;
- switch (ComboBox3->ItemIndex)
- {
- case 0 : vpr3=REALTIME_PRIORITY_CLASS;
- break;
- case 1 : vpr3=HIGH_PRIORITY_CLASS;
- break;
- case 2 : vpr3=NORMAL_PRIORITY_CLASS;
- break;
- case 3 : vpr3=IDLE_PRIORITY_CLASS;
- break;
- default :
- vpr3=NORMAL_PRIORITY_CLASS;
- }
- SetPriorityClass(hProces3,vpr3);
- hThreads[2]=hProces3;
- if(CheckBox3->Checked==true)
- {
- WaitForMultipleObjects(1, &hThreads[2], TRUE, INFINITE);
- DateTimePr3 = Time() - DateTimePr3;
- Edit6->Text = DateTimePr3;
- TerminateProcess(hProces3,100);
- }
- }
- } // if(PriznakPr3==1)
- else
- {
- PriznKPr3=1;
- DateTimePr3=0;
- }
- //////////////////////////////////////////////////
- } // if(PriznakPr==1)
- else
- {
- TerminateProcess(hProces1,100);
- TerminateProcess(hProces2,100);
- TerminateProcess(hProces3,100);
- } // else if(PriznakPpr==1)
- /* if(PriznakPr1==1 || PriznakPr2==1 || PriznakPr3==1)
- {
- if(CheckBox7->Checked==true)
- Edit11->Text = DateTimePr1 + DateTimePr2 + DateTimePr3;
- else
- {
- int pp=PriznakPr1+PriznakPr2+PriznakPr3;
- if(pp==1)
- {
- if(PriznakPr2==1) hThreads[0]=hThreads[1];
- else if(PriznakPr3==1) hThreads[0]=hThreads[2];
- } // if(pp==1)
- else if(pp==2)
- {
- if(PriznakPr2==1 && PriznakPr3==1)
- {
- hThreads[0]=hThreads[1];
- hThreads[1]=hThreads[2];
- } // if(PriznakPr2==1 && PriznakPr3==1)
- else
- if(PriznakPr1==1 && PriznakPr3==1) hThreads[1]=hThreads[2];
- } // else if(pp==2)
- WaitForMultipleObjects(pp, hThreads, TRUE, INFINITE);
- Edit11->Text= Time() - DateTimePr;
- } // else
- */
- PriznakPr=0;
- Form1->Button1->Caption="Ñòàðòóâàòè";
- TerminateProcess(hProces1,100);
- TerminateProcess(hProces2,100);
- TerminateProcess(hProces3,100);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CheckBox1Click(TObject *Sender)
- {
- if(CheckBox1->Checked==true)
- {
- Edit1->Text=1000;
- ComboBox1->ItemIndex=2;
- Edit2->Text=0;
- //Edit11->Text=0;
- PriznakPr1=1;
- if(Button1->Enabled==false)
- Button1->Enabled=true;
- }
- else
- {
- //Edit12->Text=0;
- Edit1->Text=0;
- //Edit11->Text=0;
- PriznakPr1=0;
- if(CheckBox2->Checked==false && CheckBox3->Checked==false)
- Button1->Enabled=false;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CheckBox2Click(TObject *Sender)
- {
- if(CheckBox2->Checked==true)
- {
- Edit3->Text=1000;
- ComboBox2->ItemIndex=2;
- Edit4->Text=0;
- //Edit11->Text=0;
- PriznakPr2=1;
- if(Button1->Enabled==false)
- Button1->Enabled=true;
- }
- else
- {
- //Edit12->Text=0;
- Edit3->Text=0;
- //Edit11->Text=0;
- PriznakPr2=0;
- if(CheckBox1->Checked==false && CheckBox3->Checked==false)
- Button1->Enabled=false;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CheckBox3Click(TObject *Sender)
- {
- if(CheckBox3->Checked==true)
- {
- Edit5->Text=1000;
- ComboBox3->ItemIndex=2;
- Edit6->Text=0;
- //Edit11->Text=0;
- PriznakPr3=1;
- if(Button1->Enabled==false)
- Button1->Enabled=true;
- }
- else
- {
- //Edit12->Text=0;
- Edit5->Text=0;
- //Edit11->Text=0;
- PriznakPr3=0;
- if(CheckBox1->Checked==false && CheckBox2->Checked==false)
- Button1->Enabled=false;
- }
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement