Current location - Quotes Website - Collection of slogans - How to read serial number with C#?
How to read serial number with C#?
Private system. IO . Ports.SerialPort com

Private void Form 1_Load (object sender, EventArgs e)

{

Com = new system. IO . ports . serial port();

//Get all serial ports

Microsoft. Visual basic. devices.computerpc = new Microsoft. visual basic . devices . computer();

Foreach (string s in PC. Port. Serial port name)

{

this . cbx port name . items . add;

}

}

is very good also

RegistryKey hklm = registry. Local machine;

RegistryKey hardware = hklm. OpenSubKey ("hardware");

RegistryKey device mapping = hardware. open subkey(" device map ");

registry key serial comm = device map。 open subkey(" serial comm ");

string[] s = SERIALCOMM。 GetValueNames();