AddInProcess.IsCurrentProcess 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得值,指出目前的 AddInProcess 物件是否代表主機應用程式處理序。
public:
property bool IsCurrentProcess { bool get(); };
public bool IsCurrentProcess { get; }
member this.IsCurrentProcess : bool
Public ReadOnly Property IsCurrentProcess As Boolean
屬性值
如果 AddInProcess 物件對應目前的處理序,則為 true
否則為 false
。
範例
下列範例會在外部進程中啟動載入宏,並使用 IsCurrentProcess 屬性來判斷載入宏是否與主應用程式進程位於相同的進程中。
// Create an external process.
AddInProcess pExternal = new AddInProcess();
// Activate an add-in in the external process
// with a full trust security level.
Calculator CalcAddIn4 =
selectedToken.Activate<Calculator>(pExternal,
AddInSecurityLevel.FullTrust);
// Show that the add-in is an external process
// by verifying that it is not in the current (host's) process.
AddInController AddinCtl = AddInController.GetAddInController(CalcAddIn4);
Console.WriteLine("Add-in in host's process: {0}",
AddinCtl.AddInEnvironment.Process.IsCurrentProcess);
' Create an external process.
Dim pExternal As New AddInProcess()
' Activate an add-in in the external process
' with a full trust security level.
Dim CalcAddIn4 As Calculator = _
selectedToken.Activate(Of Calculator)(pExternal, _
AddInSecurityLevel.FullTrust)
' Show that the add-in is an external process
' by verifying that it is not in the current (host's) process.
Dim AddinCtl As AddInController = AddInController.GetAddInController(CalcAddIn4)
Console.WriteLine("Add-in in host's process: {0}", _
AddinCtl.AddInEnvironment.Process.IsCurrentProcess)
備註
如果這個屬性的值是 true
,載入宏會與主應用程式同進程執行。 在這裡情況下,使用 Start 或 Shutdown 方法會 InvalidOperationException擲回 。
注意
如果載入宏正在進程中執行,則 AddInEnvironment.Process 屬性會傳 AddInProcess 回 物件,代表主應用程式進程。