-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
79 lines (70 loc) · 2.48 KB
/
Form1.cs
File metadata and controls
79 lines (70 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime;
using System.Runtime.InteropServices;
namespace UacControlPanel
{
public partial class Form1 : Form
{
[DllImport("advapi32.dll")]
public static extern bool InitiateSystemShutdown(string Machinename, string Message, long Timeout, int ForceAppsClosed, int RebootAfterShutdown);
private Engine en;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
en = new Engine();
}
catch (Exception ex)
{
MessageBox.Show(null, ex.Message + "\nIl programma verrà chiuso.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
System.Environment.Exit(0);
}
comboBox1.SelectedIndex = (int) en.getUac();
comboBox2.SelectedIndex = (int)en.getElevamento();
}
private void button1_Click(object sender, EventArgs e)
{
bool riavvio=false;
if (comboBox1.SelectedIndex == 0)
riavvio=en.disabilitaUac();
else
riavvio=en.abilitaUac((Engine.STATO_ELEVAMENTO) Enum.ToObject(typeof(Engine.STATO_ELEVAMENTO), comboBox2.SelectedIndex));
if (riavvio)
{
label3.Text = "E' necessario riavviare il computer per rendere effettive le modifiche.";
button1.Visible = false;
button3.Visible = true;
label3.Visible = true;
}
else
{
label3.Text = "Operazione completata. Premere \"Esci\" per uscire.";
label3.Visible = true;
button1.Visible = false;
button2.Visible = true;
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox2.Enabled = (comboBox1.SelectedIndex != 0);
}
private void button2_Click(object sender, EventArgs e)
{
System.Environment.Exit(0);
}
private void button3_Click(object sender, EventArgs e)
{
InitiateSystemShutdown("", "", 0, 1, 1);
}
}
}