Big Bill

i just swicthed to c++ and and i need help on how to show performance counters on the progressbar

Re: Visual C++ Express Edition peroformance counters


Drop a Timer and a ProgressBar on your form, double-click the form and paste this code. Run it to show the CPU load in the progress bar.

System::Diagnostics::PerformanceCounter^ mCpu;

System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
mCpu = gcnew System::Diagnostics::PerformanceCounter("Processor", "% Processor Time", "_Total");
timer1->Interval = 250;
timer1->Enabled = true;
timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);

System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {
progressBar1->Value = (int)mCpu->NextValue();