ServiceInstallerDialogResult 열거형

정의

ServiceInstallerDialog 양식의 반환 값을 지정합니다.

public enum class ServiceInstallerDialogResult
public enum ServiceInstallerDialogResult
type ServiceInstallerDialogResult = 
Public Enum ServiceInstallerDialogResult
상속
ServiceInstallerDialogResult

필드

Canceled 2

대화 상자의 반환 값은 Canceled입니다. 이 값은 일반적으로 사용자가 계정 필드를 설정하지 않고 대화 상자를 취소했음을 나타냅니다.

OK 0

대화 상자의 반환 값은 OK입니다. 이 값은 일반적으로 사용자가 계정 속성을 확인하고 나서 OK 단추를 눌러 대화 상자를 닫았음을 나타냅니다.

UseSystem 1

사용자 계정이 아닌 시스템 계정으로 서비스를 설치합니다. 이 값은 일반적으로 대화 상자가 사용자에게 표시되지 않았음을 나타냅니다. 예를 들어 Account 속성이 User 이외의 값으로 설정되어 있습니다.

예제

다음 예제에서는 한 ServiceInstallerDialog 서비스 설치 계정에 대 한 사용자에 게 프롬프트.

   // 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;
}

설명

ServiceInstallerDialog.Result 속성 대화 상자에 사용자 응답을 나타내는이 열거형을 사용 합니다.

적용 대상

추가 정보