ListView/Process Questions

N

Newbie Coder

In C++.NET 2003 Windows Forms App

I fill a ListView control with process name & second column is the Process
ID.

I would like to kill the selected process, which is simple in VB.NET or C#,
but cannot work it out in C++.

In VB.NET, I'd do the following:

Dim intProcID As Int32
Dim Proc As New Process()

procID = (CInt(ListView1.SelectedItems(0).SubItems(1).Text))

Proc = Process.GetProcessById(procID)
Proc.Kill()

When trying to convert this code I get many compile errors. The C++ code I
am just typing in here & hasn't come from the VS 7.1 IDE:

Example:

SubItems aren't recognised
Kill isn't recognised either

If I create a string value to hold the ListView subitem then use
Convert::ToInt32... it still fails

Please help,
 
T

Tamas Demjen

Newbie said:
In VB.NET, I'd do the following:

Dim intProcID As Int32
Dim Proc As New Process()

procID = (CInt(ListView1.SelectedItems(0).SubItems(1).Text))

Proc = Process.GetProcessById(procID)
Proc.Kill()

When trying to convert this code I get many compile errors. The C++ code I
am just typing in here & hasn't come from the VS 7.1 IDE:

It would help if you could post your C++ code and the exact error
messages that you're getting. Here's my attempt to translate your VB code:

int procID = Convert::ToInt32(
listView1->SelectedItems->Item[0]->SubItems->Item[1]);
System::Diagnostics::process* proc =
System::Diagnostics::process::GetProcessById(procID);
proc->Kill();

Note that MC++ doesn't support default properties, so you can't write
SelectedItems[0], you need to type the whole thing out.

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top