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
屬性值
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" ) == true )
{
// 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 屬性。 索引鍵和參數的值都是字串。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應