本文整理汇总了C#中System.ServiceProcess.Design.ServiceInstallerDialogResult枚举的典型用法代码示例。如果您正苦于以下问题:C# ServiceInstallerDialogResult枚举的具体用法?C# ServiceInstallerDialogResult怎么用?C# ServiceInstallerDialogResult使用的例子?那么恭喜您, 这里精选的枚举代码示例或许可以为您提供帮助。
在下文中一共展示了ServiceInstallerDialogResult枚举的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetServiceAccount
// 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;
}