InstallContext.Parameters 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得執行 InstallUtil.exe 時輸入的命令列參數。
public:
property System::Collections::Specialized::StringDictionary ^ Parameters { System::Collections::Specialized::StringDictionary ^ get(); };
public System.Collections.Specialized.StringDictionary Parameters { get; }
member this.Parameters : System.Collections.Specialized.StringDictionary
Public ReadOnly Property Parameters As StringDictionary
屬性值
A StringDictionary 代表安裝執行檔執行時輸入的命令列參數。
範例
此範例摘自該類別概述 InstallContext 中的範例。
範例會檢索該 Parameters 屬性,以確認使用者是否輸入了任何命令列參數。 它也會用該 IsParameterTrue 方法來判斷參數是否 LogtoConsole 已被設定。 若 yes,則會使用該 LogMessage 方法將狀態訊息寫入安裝日誌檔及主控台。
StringDictionary^ myStringDictionary = myInstallContext->Parameters;
if ( myStringDictionary->Count == 0 )
{
Console::Write( "No parameters have been entered in the command line " );
Console::WriteLine( "hence, the install will take place in the silent mode" );
}
else
{
// Check whether the "LogtoConsole" parameter has been set.
if ( myInstallContext->IsParameterTrue( "LogtoConsole" ) )
{
// Display the message to the console and add it to the logfile.
myInstallContext->LogMessage( "The 'Install' method has been called" );
}
}
StringDictionary myStringDictionary = myInstallContext.Parameters;
if( myStringDictionary.Count == 0 )
{
Console.WriteLine( "No parameters have been entered in the command line "
+"hence, the install will take place in the silent mode" );
}
else
{
// Check whether the "LogtoConsole" parameter has been set.
if ( myInstallContext.IsParameterTrue( "LogtoConsole" ))
{
// Display the message to the console and add it to the logfile.
myInstallContext.LogMessage( "The 'Install' method has been called" );
}
}
Dim myStringDictionary As StringDictionary = myInstallContext.Parameters
If myStringDictionary.Count = 0 Then
Console.WriteLine("No parameters have been entered in the command line" + _
"hence, the install will take place in the silent mode")
Else
' Check wether the "LogtoConsole" parameter has been set.
If myInstallContext.IsParameterTrue("LogtoConsole") = True Then
' Display the message to the console and add it to the logfile.
myInstallContext.LogMessage("The 'Install' method has been called")
End If
End If
備註
當建立新 InstallContext 檔案時,命令列參數會解析到該 Parameters 屬性中。 鍵和參數值都是字串。