Sdílet prostřednictvím


InstallContext.Parameters Vlastnost

Definice

Získá parametry příkazového řádku zadané při spuštění 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

Hodnota vlastnosti

A StringDictionary , který představuje parametry příkazového řádku, které byly zadány při spuštění spustitelného souboru instalace.

Příklady

Tento příklad je výňatek z příkladu v přehledu InstallContext třídy.

Ukázka načte Parameters vlastnost a zjistí, jestli uživatel zadal nějaký argument příkazového řádku. Používá také metodu IsParameterTrue k zjištění, zda LogtoConsole byl parametr nastaven. Pokud yes, pak použije metodu LogMessage k zápisu stavových zpráv do souboru protokolu instalace a konzoly.

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

Poznámky

Při vytvoření nového InstallContext objektu se parametry příkazového řádku parsují do Parameters vlastnosti. Klíče i hodnoty parametrů jsou řetězce.

Platí pro

Viz také