VM4.3 二次开发03 小技巧
1.查看SDK帮助文档。
SDK帮助文档路径:安装目录下的路径,注意自己安装时的盘符,我是安装在D盘的。
D:\Program Files\VisionMaster4.3.0\Development\V4.x\Documentations\CH
示例程序目录
D:\Program Files\VisionMaster4.3.0\Development\V4.x\Samples
2.上位机程序初始化前检测并自动关闭VM相关软件或进程
3.上位机软件关闭前释放VM所有资源
相关代码
public MainWindow()
{InitializeComponent();//杀死进程 VM相关进程KillProcess("VisionMasterServerApp");KillProcess("VisionMaster");KillProcess("VmModuleProxy");Loaded += MainWindow_Loaded;Closing += MainWindow_Closing;
}/// <summary>
/// 关闭前
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{//释放所有资源VmSolution.Instance.Dispose();
}/// <summary>
/// 关闭 进程
/// </summary>
/// <param name="killName"></param>
public void KillProcess(string killName)
{foreach (var item in Process.GetProcesses()){if (item.ProcessName.Contains(killName)){try{item.Kill();item.WaitForExit();}catch (Exception ex){//}}}
}