ServiceInstallerDialogResult Enumeration
.NET Framework 2.0
Specifies the return value of a ServiceInstallerDialog form.
Namespace: System.ServiceProcess.Design
Assembly: System.ServiceProcess (in system.serviceprocess.dll)
Assembly: System.ServiceProcess (in system.serviceprocess.dll)
| Member name | Description | |
|---|---|---|
| Canceled | The dialog return value is Canceled. This value typically indicates that the user canceled out of the dialog without setting the account fields. | |
| OK | The dialog return value is OK. This value typically indicates that the user confirmed the account properties and pressed the OK button to close the dialog. | |
| UseSystem | Install the service with a system account rather than a user account. This value typically indicates that the dialog was not displayed to the user. For example, the ServiceProcessInstaller.Account property is set to something other than User. |
The ServiceInstallerDialog.Result property uses this enumeration to indicate the user response to the dialog box.
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 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
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Community Additions
ADD
Show: