Installer.Context 屬性

定義

取得或設定有關目前安裝的資訊。Gets or sets information about the current installation.

public:
 property System::Configuration::Install::InstallContext ^ Context { System::Configuration::Install::InstallContext ^ get(); void set(System::Configuration::Install::InstallContext ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Configuration.Install.InstallContext Context { get; set; }
member this.Context : System.Configuration.Install.InstallContext with get, set
Public Property Context As InstallContext

屬性值

InstallContext,包含關於目前安裝的資訊。An InstallContext that contains information about the current installation.

屬性

範例

下列範例示範Context Installer類別的屬性。The following example demonstrates the Context property of the Installer class. Context屬性的內容包含安裝的記錄檔位置的相關資訊、儲存Uninstall方法所需資訊的檔案位置, 以及安裝時所輸入的命令列。可執行檔已執行。The contents of the Context property contain information about the location of the log file for the installation, the location of the file to save information required by the Uninstall method, and the command line that was entered when the installation executable was run. 這些內容會接著顯示在主控台上。These contents are then displayed on the console.

StringDictionary^ myStringDictionary = Context->Parameters;
if ( Context->Parameters->Count > 0 )
{
   Console::WriteLine( "Context Property : " );
   IEnumerator^ myEnum = Context->Parameters->Keys->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      String^ myString = safe_cast<String^>(myEnum->Current);
      Console::WriteLine( Context->Parameters[ myString ] );
   }
}
StringDictionary myStringDictionary = Context.Parameters;
if ( Context.Parameters.Count > 0 )
{
   Console.WriteLine("Context Property : " );
   foreach( string myString in Context.Parameters.Keys)
   {
      Console.WriteLine( Context.Parameters[ myString ] );
   }
}
Dim myStringDictionary As StringDictionary = Context.Parameters
If Context.Parameters.Count > 0 Then
   Console.WriteLine("Context Property : ")
   Dim myString As String
   For Each myString In  Context.Parameters.Keys
      Console.WriteLine(Context.Parameters(myString))
   Next myString
End If

備註

Context屬性包含安裝資訊。The Context property contains installation information. 例如, 用於安裝之記錄檔位置的資訊、用Uninstall來儲存方法所需資訊的檔案位置, 以及執行安裝可執行檔時所輸入的命令列。For example, information about the location of the log file for the installation, the location of the file to save information required by the Uninstall method, and the command line that was entered when the installation executable was run.

Install呼叫ContextCommit、或方法的程式會使用方法所需的資訊來設定屬性。Uninstall RollbackThe program that calls the Install, Commit, Rollback, or Uninstall methods sets the Context property with information that the methods need.

如果安裝程式屬於安裝程式集合, 父安裝程式會先設定Context屬性, 再呼叫這些方法中的任何一個。If an installer belongs to an installer collection, the parent installer sets the Context property before calling any of these methods. 父系安裝程式可透過Parent屬性存取。The parent installer can be accessed through the Parent property.

適用於

另請參閱