我有Windows窗体应用程序,需要在管理员模式下运行而不编辑app.manifest文件。得到了下面的代码,但不知道在windows窗体应用程序中放置代码的位置。管理员模式下的Windows窗体应用程序
ProcessStartInfo proc = new ProcessStartInfo();
proc.UseShellExecute = true;
proc.WorkingDirectory = Environment.CurrentDirectory;
proc.FileName = Application.ExecutablePath;
proc.Verb = "runas";
Process.Start(proc);
Application.Exit(); // Quit itself
为什么做的不仅仅是做清单的变化而变化的代码“容易”? –