如何判断代码运行于Inventor Desktop还是Inventor Server环境?
在iLogic规则中区分Inventor Desktop与Inventor Server环境的方法
在iLogic规则开发中,我们常需要区分代码运行环境——比如IDA/APS(基于Inventor Server)环境不允许使用消息框,而Inventor Desktop环境则可正常调用。我们希望实现这样的逻辑:
如果是Inventor Desktop环境,显示消息框;如果是Inventor Server环境,则执行替代逻辑,不调用消息框
可行方案:检查活动进程名称
Inventor Desktop对应的进程是Inventor.exe,而Inventor Server对应的进程是InventorCoreConsole.exe,通过判断当前运行的进程名即可区分环境。
代码示例
' 获取当前进程名称 Dim currentProcessName As String = System.Diagnostics.Process.GetCurrentProcess().ProcessName ' 判断环境并执行对应逻辑 If currentProcessName = "Inventor" Then MessageBox.Show("This is Inventor Desktop") Else ' Inventor Server环境下的替代逻辑 ' 例如写入日志、执行后台操作等 End If
内容的提问来源于stack exchange,提问作者Ryan Small
相关产品推荐
相关产品推荐

