InstallContext.Parameters Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает параметры командной строки, введенные при выполнении 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" ))
{
// 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 . Ключи и значения параметров являются строками.