ServiceInstallerDialog クラスとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ServiceInstallerDialog クラスの意味・解説 

ServiceInstallerDialog クラス

Windows サービス アプリケーションアカウント情報入力要求するプロンプトを示すダイアログ ボックス表示します

名前空間: System.ServiceProcess.Design
アセンブリ: System.ServiceProcess (system.serviceprocess.dll 内)
構文構文

Public Class ServiceInstallerDialog
    Inherits Form
Dim instance As ServiceInstallerDialog
public class ServiceInstallerDialog : Form
public ref class ServiceInstallerDialog : public
 Form
public class ServiceInstallerDialog extends
 Form
public class ServiceInstallerDialog extends
 Form
解説解説
使用例使用例

ServiceInstallerDialog使用してユーザーサービス インストール アカウント入力するように要求するプロンプト表示する例を次に示します

// 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;
}
   // 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 boolean GetServiceAccount(ServiceProcessInstaller
 svcInst)
{
    boolean accountSet = false;
    ServiceInstallerDialog svcDialog = new ServiceInstallerDialog();
    // Query the user for the service account type.
    do {
        svcDialog.set_TopMost(true);
        svcDialog.ShowDialog();

        if (svcDialog.get_Result().Equals(ServiceInstallerDialogResult.OK))
        {
            // Do a very simple validation on the user
            // input.  Check to see whether the user name
            // or password is blank.
            if (svcDialog.get_Username().get_Length() > 0 
                && svcDialog.get_Password().get_Length() > 0) {
                // Use the account and password.
                accountSet = true;

                svcInst.set_Account(ServiceAccount.User);
                svcInst.set_Username(svcDialog.get_Username());
                svcInst.set_Password(svcDialog.get_Password());
            }
        }
        else {
            if (svcDialog.get_Result().Equals(ServiceInstallerDialogResult.
                UseSystem)) {
                svcInst.set_Account(ServiceAccount.LocalSystem);
                svcInst.set_Username(null);
                svcInst.set_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.Equals(DialogResult.Cancel)) {
                // Break out of loop.
                break;
            }
        }
    } while (!(accountSet));
    return accountSet;
} //GetServiceAccount
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
         System.Windows.Forms.ScrollableControl
           System.Windows.Forms.ContainerControl
             System.Windows.Forms.Form
              System.ServiceProcess.Design.ServiceInstallerDialog
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ServiceInstallerDialog メンバ
System.ServiceProcess.Design 名前空間
ServiceInstallerDialogResult
ServiceProcessInstaller クラス
ServiceAccount 列挙



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ServiceInstallerDialog クラス」の関連用語

ServiceInstallerDialog クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ServiceInstallerDialog クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS