我有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
爲什麼做的不僅僅是做清單的變化而變化的代碼「容易」? –