windows - C# IMEI detection of any device connected via USB -
i working on c# desktop application detect imei of device connected via usb. got working samsung device after installing driver , running @ commands. there generic way devices.
any device supports @ command access using c# serial port class. once hold of device through serial port can send @ commands , response of commands. how can send @ command imei number , number response of @ command through uniform interface type of devices support @ commands , access through com port.
i have found following example on codeproject imei number , made little modification.
private string getimeinumber(string portname) //serial { string key = ""; serialport serialport = new serialport(); serialport.portname = portname; serialport.baudrate = 9600; try { if (!(serialport.isopen)) serialport.open(); serialport.write("at\r\n"); thread.sleep(3000); key = serialport.readexisting(); serialport.write("at+cgsn\r\n"); thread.sleep(3000); key = serialport.readexisting(); serialport.close(); string serial = ""; (int = 0; < key.length; i++) if (char.isdigit(key[i])) serial += key[i]; return serial; } catch (exception ex) { messagebox.show("error in opening/writing serial port :: " + ex.message, "error!"); return ""; } }
Comments
Post a Comment