/**************************************************************************
* Qt 获取usb设备信息 hacking
* 声明:
* 本文主要是为了查看之前朋友留下的Qt获取usb设备信息软件运作机制。
*
* 2015-12-31 深圳 南山平山村 曾剑锋
*************************************************************************/ 一、usbfs 文件系统
需要在Linux内核中打开usbfs选项:
───────────────────────────────────────────────────────────────────────────
┌────────────────────────────── USB support ──────────────────────────────┐
│ Arrow keys navigate the menu. <Enter> selects submenus --->. │
│ Highlighted letters are hotkeys. Pressing <Y> includes, <N> excludes, │
│ <M> modularizes features. Press <Esc><Esc> to exit, <?> for Help, </> │
│ for Search. Legend: [*] built-in [ ] excluded <M> module < > │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ --- USB support │ │
│ │ <*> Support for Host-side USB │ │
│ │ [*] USB verbose debug messages │ │
│ │ [*] USB announce new devices │ │
│ │ *** Miscellaneous USB options *** │ │
│ │ [*] USB device filesystem (DEPRECATED) <----------- these │ │
│ │ [*] USB device class-devices (DEPRECATED) │ │
│ │ [ ] Dynamic USB minor allocation │ │
│ │ [*] USB runtime power management (autosuspend) and wakeup │ │
│ │ [*] OTG support │ │
│ └────v(+)─────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────────┤
│ <Select> < Exit > < Help > │
└─────────────────────────────────────────────────────────────────────────┘ 二、cat mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
} MainWindow::~MainWindow()
{
delete ui;
} void MainWindow::on_pushButton_clicked()
{
if(myprocess)
delete myprocess; myprocess = new QProcess(this);
connect(myprocess, SIGNAL(readyReadStandardOutput()),this, SLOT(result()));
connect(myprocess, SIGNAL(readyReadStandardError()),this, SLOT(result())); /**
* If you say Y here (and to "/proc file system support" in the "File
* systems" section, above), you will get a file /proc/bus/usb/devices
* which lists the devices currently connected to your USB bus or
* busses, and for every connected device a file named
* "/proc/bus/usb/xxx/yyy", where xxx is the bus number and yyy the
* device number; the latter files can be used by user space programs
* to talk directly to the device. These files are "virtual", meaning
* they are generated on the fly and not stored on the hard drive.
*
* You may need to mount the usbfs file system to see the files, use
* mount -t usbfs none /proc/bus/usb
*
* For the format of the various /proc/bus/usb/ files, please read
* <file:Documentation/usb/proc_usb_info.txt>.
*/
myprocess->start("cat /proc/bus/usb/devices");
ui->result->clear();
}
void MainWindow::result()
{
QString abc = myprocess->readAllStandardOutput();
ui->result->append(abc.trimmed());
QString efg = myprocess->readAllStandardError();
if(efg.length()>)ui->result->append(efg.trimmed());
}

Qt 获取usb设备信息 hacking的更多相关文章

  1. C# 获取USB设备信息

    C# 获取USB设备信息WMI方式 using System; using System.Management; using System.Text.RegularExpressions; using ...

  2. C#:基于WMI查询USB设备信息 及 Android设备厂商VID列表

    /* ---------------------------------------------------------- 文件名称:WMIUsbQuery.cs 作者:秦建辉 MSN:splashc ...

  3. Windows下USB磁盘开发系列三:枚举系统中U盘、并获取其设备信息

    前面我们介绍了枚举系统中的U盘盘符(见<Windows下USB磁盘开发系列一:枚举系统中U盘的盘符>).以及获取USB设备的信息(见<Windows下USB磁盘开发系列二:枚举系统中 ...

  4. 【转】android 安卓APP获取手机设备信息和手机号码的代码示例

    http://blog.csdn.net/changemyself/article/details/7421476 下面我从安卓开发的角度,简单写一下如何获取手机设备信息和手机号码 准备条件:一部安卓 ...

  5. android 安卓APP获取手机设备信息和手机号码的代码示例

    下面我从安卓开发的角度,简单写一下如何获取手机设备信息和手机号码 准备条件:一部安卓手机.手机SIM卡确保插入手机里.eclipse ADT和android-sdk开发环境 第一步:新建一个andro ...

  6. libusb获取usb设备的idVendor(vid),idProduct(pid),以及Serial Number

    发表于2015/6/23 21:55:11  4594人阅读 最近在做关于usb设备的项目,用到了libusb,发现关于这个的函数库的介绍,讲解很少,下面仅仅是简单展示一些基本的使用方法,以备后用. ...

  7. ?Object-C获取手机设备信息

    一.获取UiDevice设备信息 // 获取设备名称 NSString *name = [[UIDevice currentDevice] name]; // 获取设备系统名称 NSString *s ...

  8. iOS开发-Object-C获取手机设备信息(UIDevice)

    一.获取UiDevice设备信息 // 获取设备名称 NSString *name = [[UIDevice currentDevice] name]; // 获取设备系统名称 NSString *s ...

  9. Python学习---Django的request扩展[获取用户设备信息]

    关于Django的request扩展[获取用户设备信息] settings.py INSTALLED_APPS = [ ... 'app01', # 注册app ] STATICFILES_DIRS ...

随机推荐

  1. codeforces 439D Devu and Partitioning of the Array(有深度的模拟)

    题目 //参考了网上的代码 注意答案可能超过32位 //要达成目标,就是要所有数列a的都比数列b的要小或者等于 //然后,要使最小的要和最大的一样大,就要移动(大-小)步, //要使较小的要和较大的一 ...

  2. android:scaleType属性

    android:scaleType是控制图片如何resized/moved来匹对ImageView的size. ImageView.ScaleType / android:scaleType值的意义区 ...

  3. Linux多线程之互斥

    题目 共要卖票20张,由命令行输入窗口数,由线程模拟窗口.每卖掉一张票,屏幕显示由几号窗口所卖,一并显示剩余票数 思路 由于票数 ticket_cnt 是全局变量,因此每当一个线程将其减一(卖出一张票 ...

  4. Jenkins配置基于角色的项目权限管理--转

    本文将介绍如何配置jenkins,使其可以支持基于角色的项目权限管理. 由于jenkins默认的权限管理体系不支持用户组或角色的配置,因此需要安装第三发插件来支持角色的配置,本文将使用Role Str ...

  5. spring_150803_component

    实体类: package com.spring.model; public class DogPet { private int id; private String name; private in ...

  6. 快速幂取模 POJ 3761 bubble sort

    题目传送门 /* 题意:求冒泡排序扫描k次能排好序的全排列个数 数学:这里有一个反序列表的概念,bj表示在j左边,但大于j的个数.不多说了,我也是看网上的解题报告. 详细解释:http://blog. ...

  7. [RM HA 1] Cloudera CDH5 RM HA功能验证

    简介: 最新的Cloudera CDH5.0.0 beta版本已经支持RM的HA, 笔者为此简单验证了RM HA的功能. 后续将继续分析其HA的原理,以及其与社区RM HA的区别. 集群部属与RM f ...

  8. Qt之QSpacerItem(控件之间的间距不尽相同,可以借助QSpacerItem来设置,并且还可以对QSpacerItem设置QSizePolicy)

    http://blog.csdn.net/u011012932/article/details/51614868

  9. 创建新进程,就三个函数CreateProcessAsUser CreateProcessWithLogonW CreateProcessWithTokenW(附网友的流程)

    CreateProcessAsUser 怎么会还需要密码呢~~~ 先WTSGetActiveConsoleSessionId 得到当前的处理激活状态的SessionId OpenProcessToke ...

  10. Struts2笔记——利用token防止表单重复提交

    在一些项目中经常会让用户提交表单,当用户点击按钮提交后,如果再次浏览器刷新,这就会造成表单重复提交,若是提交的内容上传至服务器并请求数据库保存,重复提交的表单可能会导致错误,然后跳转到错误界面,这是一 ...