我閂鎖到Catia時使用:CATIA和VB.NET檢測CATIA的閉合在外部應用程序
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim boolCatAlive As Boolean
boolCatAlive = False
Try
Dim myCatia As INFITF.Application
myCatia = Interaction.GetObject(vbNullString, "CATIA.Application")
boolCatAlive = True
Catch ex As Exception
boolCatAlive = False
End Try
Select Case boolCatAlive
Case True
'continue loading app, do my stuff
Case Else
'end this now
MsgBox("No running CATIA instance detected, please start a new CATIA instance and re-run this program.", MsgBoxStyle.Critical, "Error")
End
End Select
End Sub
所以這是在形式裝載,其確定所述應用程序是否是要加載或一個簡單的布爾開關不。
這可以正常工作,但在應用程序啓動時僅執行一次檢查。是否有辦法持續檢測CATIA狀態,以便 - 如果用戶在我的應用程序運行中退出CATIA - 應用程序會收到通知並意識到CATIA COM鏈接不再有效?
我也可以用它來檢測選擇的變化,例如?