开发者

Visual C++ - Kill process using .net

I want to be kill a process using Visual C++ as easy as the C# way:

foreach(Process process in Proce开发者_StackOverflowss.GetProcessesByName("ComponentEnvironmentServer"))
{
  process.Kill();
  process.WaitForExit();
}

I've seen some examples on the net but they're a lot less simpler than above (cross-platform I guess). I'm very confused about the relationship between MSVC++ and .Net; I thought the whole reason of the .Net platform was to make things simpler? i.e. to be able to transfer the above code to any .Net language?


In managed C++ that would be:

 foreach (Process* process in Process::GetProcessesByName(S"ComponentEnvironmentServer"))
    {
        process->Kill();
        process->WaitForExit();
    }

.NET allows you to use the same libraries whether you write C#, VB.NET or Managed C++.

For native C++ the code is different as you cant access the .NET libraries.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜