环境:VM4.0.0+vs2015 及以上
现象:怎么获取流程 ID?
解答
通过流程名可以获取流程 ID。
c#
public static bool GetProcessID(string ProcessName, ref int ProcessI
D, ref string ErrorMessage)
{
bool findIDResult = false;
try
{
ProcessInfoList stProcList = VmSolution.Instance.GetAll
ProcedureList(); // 获取所有流程列表
for (int i = 0; i < stProcList.nNum; i++)
{
string _ProcessName = stProcList.astProcessInfo[i].strP
rocessName;
if (ProcessName == _ProcessName)
{
ProcessID = (int)stProcList.astProcessInfo[i].nProcessID;
findIDResult = true;
break;
}
}
}
catch (Exception ex)
{
findIDResult = false;
ErrorMessage = “获取流程 ID 异常:” + ex.Message;
}
return findIDResult;
}