ServiceInstallerDialogResult Enumeración

Definición

Especifica el valor devuelto por un formulario ServiceInstallerDialog.Specifies the return value of a ServiceInstallerDialog form.

public enum class ServiceInstallerDialogResult
public enum ServiceInstallerDialogResult
type ServiceInstallerDialogResult = 
Public Enum ServiceInstallerDialogResult
Herencia
ServiceInstallerDialogResult

Campos

Canceled 2

El valor devuelto del cuadro de diálogo es Canceled.The dialog return value is Canceled. Este valor indica normalmente que el usuario canceló el cuadro de diálogo sin establecer los campos de cuenta.This value typically indicates that the user canceled out of the dialog without setting the account fields.

OK 0

El valor devuelto del cuadro de diálogo es OK.The dialog return value is OK. Este valor indica normalmente que el usuario confirmó las propiedades de cuenta e hizo clic en el botón OK para cerrar el cuadro de diálogo.This value typically indicates that the user confirmed the account properties and pressed the OK button to close the dialog.

UseSystem 1

Instale el servicio con una cuenta del sistema en lugar de una cuenta de usuario.Install the service with a system account rather than a user account. Normalmente, este valor indica que no se muestra el cuadro de diálogo al usuario.This value typically indicates that the dialog was not displayed to the user. Por ejemplo, la propiedad Account se establece en algo distinto de User.For example, the Account property is set to something other than User.

Ejemplos

En el ejemplo siguiente se ServiceInstallerDialog usa un para solicitar al usuario una cuenta de instalación del servicio.The following example uses a ServiceInstallerDialog to prompt the user for a service installation account.

   // Prompt the user for service installation account values.
public:
   static bool GetServiceAccount( interior_ptr<ServiceProcessInstaller^> svcInst )
   {
      bool accountSet = false;
      ServiceInstallerDialog^ svcDialog = gcnew ServiceInstallerDialog;

      // Query the user for the service account type.
      do
      {
         svcDialog->TopMost = true;
         svcDialog->ShowDialog();
         if ( svcDialog->Result == ServiceInstallerDialogResult::OK )
         {
            // Do a very simple validation on the user
            // input.  Check to see whether the user name
            // or password is blank.
            if ( (svcDialog->Username->Length > 0) && (svcDialog->Password->Length > 0) )
            {
               // Use the account and password.
               accountSet = true;
               ( *svcInst)->Account = ServiceAccount::User;
               ( *svcInst)->Username = svcDialog->Username;
               ( *svcInst)->Password = svcDialog->Password;
            }
         }
         else
         if ( svcDialog->Result == ServiceInstallerDialogResult::UseSystem )
         {
            ( *svcInst)->Account = ServiceAccount::LocalSystem;
            ( *svcInst)->Username = nullptr;
            ( *svcInst)->Password = nullptr;
            accountSet = true;
         }

         if (  !accountSet )
         {
            // Display a message box.  Tell the user to
            // enter a valid user and password, or cancel
            // out to leave the service account alone.
            DialogResult result;
            result = MessageBox::Show( "Invalid user name or password for service installation."
                  "  Press Cancel to leave the service account unchanged.", "Change Service Account", 
                  MessageBoxButtons::OKCancel, MessageBoxIcon::Hand );
            if ( result == DialogResult::Cancel )
            {
               // Break out of loop.
               break;
            }
         }
      }
      while (  !accountSet );

      return accountSet;
   }
// Prompt the user for service installation account values.
public static bool GetServiceAccount(ref ServiceProcessInstaller svcInst)
{
    bool accountSet = false;
    ServiceInstallerDialog svcDialog = new ServiceInstallerDialog();

    // Query the user for the service account type.
    do
    {
        svcDialog.TopMost = true;
        svcDialog.ShowDialog();

        if (svcDialog.Result == ServiceInstallerDialogResult.OK)
        {
            // Do a very simple validation on the user
            // input.  Check to see whether the user name
            // or password is blank.

            if ((svcDialog.Username.Length > 0) &&
                (svcDialog.Password.Length > 0)   )
            {
                // Use the account and password.
                accountSet = true;

                svcInst.Account = ServiceAccount.User;
                svcInst.Username = svcDialog.Username;
                svcInst.Password = svcDialog.Password;
            }
        }
        else if (svcDialog.Result == ServiceInstallerDialogResult.UseSystem)
        {
            svcInst.Account = ServiceAccount.LocalSystem;
            svcInst.Username = null;
            svcInst.Password = null;
            accountSet  = true;
        }
            
        if (!accountSet )
        {
            // Display a message box.  Tell the user to
            // enter a valid user and password, or cancel
            // out to leave the service account alone.
            DialogResult result;
            result = MessageBox.Show("Invalid user name or password for service installation."+
                                     "  Press Cancel to leave the service account unchanged.",
                                     "Change Service Account", 
                                     MessageBoxButtons.OKCancel,
                                     MessageBoxIcon.Hand);

            if (result == DialogResult.Cancel)
            {
                // Break out of loop.
                break;
            }
        }
    } while (!accountSet);

    return accountSet;
}

Comentarios

La ServiceInstallerDialog.Result propiedad usa esta enumeración para indicar la respuesta del usuario al cuadro de diálogo.The ServiceInstallerDialog.Result property uses this enumeration to indicate the user response to the dialog box.

Se aplica a

Consulte también: