2023-05-23 16:13:17 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using DevExpress.UserSkins;
|
|
|
|
|
|
using DevExpress.Skins;
|
2025-01-23 22:53:20 +08:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
using System.Security.Principal;
|
2023-05-23 16:13:17 +08:00
|
|
|
|
|
|
|
|
|
|
namespace DeiNiu.wms.win
|
|
|
|
|
|
{
|
|
|
|
|
|
static class Program
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The main entry point for the application.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[STAThread]
|
|
|
|
|
|
static void Main()
|
|
|
|
|
|
{
|
2025-01-23 22:53:20 +08:00
|
|
|
|
var wi = WindowsIdentity.GetCurrent();
|
|
|
|
|
|
var wp = new WindowsPrincipal(wi);
|
|
|
|
|
|
|
|
|
|
|
|
bool runAsAdmin = wp.IsInRole(WindowsBuiltInRole.Administrator);
|
|
|
|
|
|
|
|
|
|
|
|
if (!runAsAdmin)
|
|
|
|
|
|
{
|
|
|
|
|
|
// It is not possible to launch a ClickOnce app as administrator directly,
|
|
|
|
|
|
// so instead we launch the app as administrator in a new process.
|
|
|
|
|
|
var processInfo = new ProcessStartInfo(Assembly.GetExecutingAssembly().CodeBase);
|
|
|
|
|
|
|
|
|
|
|
|
// The following properties run the new process as administrator
|
|
|
|
|
|
processInfo.UseShellExecute = true;
|
|
|
|
|
|
processInfo.Verb = "runas";
|
|
|
|
|
|
|
|
|
|
|
|
// Start the new process
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
Process.Start(processInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
// The user did not allow the application to run as administrator
|
|
|
|
|
|
MessageBox.Show("Sorry, but I don't seem to be able to start " +
|
|
|
|
|
|
"this program with administrator rights!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Shut down the current process
|
|
|
|
|
|
Application.Exit();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
AboutDevCompanion devCom = new AboutDevCompanion(100, true);//release 时启用
|
2023-05-23 16:13:17 +08:00
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
|
|
|
|
|
|
|
|
BonusSkins.Register();
|
|
|
|
|
|
SkinManager.EnableFormSkins();
|
|
|
|
|
|
Application.Run(new main());
|
2025-01-23 22:53:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-23 16:13:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|