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 80 81 82 83 84 85 86 87 88 89 90 91 92
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Runtime.InteropServices;
namespace CLSInstaller
{
public partial class MainForm : Form
{
[DllImport("kernel32.dll")]
static extern bool SetComputerName(string lpComputerName);
enum COMPUTER_NAME_FORMAT
{
ComputerNameNetBIOS,
ComputerNameDnsHostname,
ComputerNameDnsDomain,
ComputerNameDnsFullyQualified,
ComputerNamePhysicalNetBIOS,
ComputerNamePhysicalDnsHostname,
ComputerNamePhysicalDnsDomain,
ComputerNamePhysicalDnsFullyQualified,
}
public MainForm()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
// Application des paramètres régionaux...
RegistryKey cle = Registry.CurrentUser.OpenSubKey(@"Control Panel\International", true);
cle.SetValue("sShortDate", "dd/MM/yyyy");
cle.SetValue("sTimeFormat", "HH:mm:ss");
cle.Close();
progressBar1.Value = 50;
// Application du nom de L'ordianteur...
string ComptNm = textBox1.Text;
bool done = SetComputerName(ComptNm);
if (done)
{
Console.WriteLine("Done");
}
RegistryKey cleCMPT1 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\SchedulingAgent", true);
RegistryKey cleCMPT2 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet001\Services\Tcpip\Parameters", true);
RegistryKey cleCMPT3 = Registry.LocalMachine.OpenSubKey(@"SYSTEM\ControlSet002\Services\Tcpip\Parameters", true);
cleCMPT1.SetValue("OldName", ComptNm);
cleCMPT2.SetValue("Hostname", ComptNm);
cleCMPT2.SetValue("NV Hostname", ComptNm);
cleCMPT3.SetValue("Hostname", ComptNm);
cleCMPT3.SetValue("NV Hostname", ComptNm);
cleCMPT1.Close();
cleCMPT2.Close();
cleCMPT3.Close();
progressBar1.Value = 100;
}
}
} |
Partager