请选择 进入手机版 | 继续访问电脑版
搜索
热搜: 活动 交友 discuz

[参数信息] C# 调用adb command 读取手机型号和IMEI

  [复制链接]

5

主题

5

帖子

34

积分

版主

Rank: 7Rank: 7Rank: 7

积分
34
发表于 2019-1-23 09:45:14 | 显示全部楼层 |阅读模式
如下:

点击Button, label 显示获取的手机型号,texBox显示获取的手机IMEI号码。


代码如下:
  1. using System;

  2. using System.Collections.Generic;

  3. using System.ComponentModel;

  4. using System.Data;

  5. using System.Drawing;

  6. using System.Linq;

  7. using System.Text;

  8. using System.Windows.Forms;

  9. using System.Diagnostics;



  10. namespace ExecuteADB

  11. {

  12.     public partial class Form1 : Form

  13.     {

  14.         string preimei, imei;

  15.         public Form1()

  16.         {

  17.             InitializeComponent();

  18.         }



  19.         private void Form1_Load(object sender, EventArgs e)

  20.         {

  21.             

  22.         }



  23.         private void button1_Click(object sender, EventArgs e)

  24.         {

  25.             String cmd = Application.StartupPath + "\\adb\\adb.exe";



  26.             Process p = new Process();

  27.             p.StartInfo = new System.Diagnostics.ProcessStartInfo();

  28.             p.StartInfo.FileName = cmd;//设定程序名

  29.             p.StartInfo.Arguments = " shell getprop ro.product.model";

  30.             p.StartInfo.UseShellExecute = false; //关闭shell的使用

  31.             p.StartInfo.RedirectStandardInput = true; //重定向标准输入

  32.             p.StartInfo.RedirectStandardOutput = true; //重定向标准输出

  33.             p.StartInfo.RedirectStandardError = true; //重定向错误输出

  34.             p.StartInfo.CreateNoWindow = true;//设置不显示窗口

  35.             p.Start();

  36.             label2.Text = p.StandardOutput.ReadToEnd();

  37.             p.Close();

  38.             ///////////////////////////

  39.             p.StartInfo = new System.Diagnostics.ProcessStartInfo();

  40.             p.StartInfo.FileName = cmd;//设定程序名

  41.             p.StartInfo.Arguments = " shell dumpsys iphonesubinfo";

  42.             p.StartInfo.UseShellExecute = false; //关闭shell的使用

  43.             p.StartInfo.RedirectStandardInput = true; //重定向标准输入

  44.             p.StartInfo.RedirectStandardOutput = true; //重定向标准输出

  45.             p.StartInfo.RedirectStandardError = true; //重定向错误输出

  46.             p.StartInfo.CreateNoWindow = true;//设置不显示窗口

  47.             p.Start();

  48.             preimei = p.StandardOutput.ReadToEnd();

  49.             //preimei

  50.             //Phone Subscriber Info:

  51.             //Phone Type = GSM

  52.             //Device ID = 861699010825377

  53. string[] sArray = preimei.Split(new char[1] { '=' });



  54. imei = sArray[2];



  55. textBox1.Text = imei.Trim();



  56.                         p.Close();



  57. } }}
复制代码









上一篇:读取IMSI的apk
下一篇:ROM开发入门到精通-内容教程整合【开发必备】
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

抖音账号
关注抖音
加入粉丝群,抽取论坛金币


Archiver|手机版|小黑屋|IT趣-GEEK社区

GMT+8, 2024-3-29 19:42 , Processed in 0.028725 second(s), 22 queries .

Powered by Discuz! X3.4. 技术支持 by 巅峰设计

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表