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
| static string GetManufacturerID(Byte[] bObj)
{
int Char1 = 0;
int Char2 = 0;
int Char3 = 0;
string TempsEDIDMfg = Encoding.Default.GetString(bObj, 0x08, 2);
int Byte1 = Convert.ToInt32(Encoding.ASCII.GetBytes(TempsEDIDMfg.Substring(0, 1))[0]);
int Byte2 = Convert.ToInt32(Encoding.ASCII.GetBytes(TempsEDIDMfg.Substring(TempsEDIDMfg.Length - 1, 1))[0]);
if ((Byte1 & 0x40) > 0) Char1 += 16;
if ((Byte1 & 0x20) > 0) Char1 += 8;
if ((Byte1 & 0x10) > 0) Char1 += 4;
if ((Byte1 & 0x08) > 0) Char1 += 2;
if ((Byte1 & 0x04) > 0) Char1 += 1;
if ((Byte1 & 0x02) > 0) Char2 += 16;
if ((Byte1 & 0x01) > 0) Char2 += 8;
if ((Byte2 & 0x80) > 0) Char2 += 4;
if ((Byte2 & 0x40) > 0) Char2 += 2;
if ((Byte2 & 0x20) > 0) Char2 += 1;
if ((Byte2 & 0x10) > 0) Char3 += 16;
if ((Byte2 & 0x08) > 0) Char3 += 8;
if ((Byte2 & 0x04) > 0) Char3 += 4;
if ((Byte2 & 0x02) > 0) Char3 += 2;
if ((Byte2 & 0x01) > 0) Char3 += 1;
Char1 += 64;
Char2 += 64;
Char3 += 64;
char CChar1 = Convert.ToChar(Char1);
char CChar2 = Convert.ToChar(Char2);
char CChar3 = Convert.ToChar(Char3);
return CChar1.ToString() + CChar2.ToString() + CChar3.ToString();
} |
Partager