1

我需要知道如何在参数中使用变量 PROCESS 被初始化为 string PROCESS在类参数中。

Process::GetProcessesByName("")

当我用变量替换字符串时,这给了我一个错误

Process::GetProcessesByName(PROCESS)

我得到的错误是:没有重载函数的实例“System::Diagnostics::Process::GetProcessByName”匹配参数列表参数类型是(std::string)

4

1 回答 1

0

I think GetProcessesByName may take a parameter as LPSTR or char const *, but not a std::string,

try use

Process::GetProcessesByName(PROCESS.c_str());

or if your PROCESS is defined as std::string PROCESS;,

   String^ process_name = gcnew String(PROCESS.c_str());
   Process::GetProcessesByName(process_name);
于 2013-10-07T18:53:03.350 回答