/**************************************************************************
* 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. POJ 2186

    Popular Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 22189   Accepted: 9076 Des ...

  2. 深入浅出ES6(十六):模块 Modules

    作者 Jason Orendorff  github主页  https://github.com/jorendorff 早在2007年我刚加入Mozilla的JavaScript团队的时候广为流传一个 ...

  3. (3)VS2010+Opencv-2.4.8的配置攻略

    这是windows平台上的东西,我为什么要写到安卓这一块呢 因为作者做的安卓方面的东西需要先在windows平台实现一下,所以就想写这篇东西,也参考了网上很多教程,不得不感叹,这些软件版本更新的太快. ...

  4. C Primer Plus之文件输入/输出

    文件 一个文件通常就是磁盘上的一段命名的存储区.但对于操作系统来说,文件就会更复杂一些.例如,一个大文件可以存储在一些分散的区段中,或者还会包含一些使操作系统可以确定其文件类型的附加数据. C将文件看 ...

  5. interviewbit : Max Non Negative SubArrayBookmark Suggest Edit

    Find out the maximum sub-array of non negative numbers from an array.The sub-array should be continu ...

  6. yarn介绍

    hadoop 1.0 mapreduce过程 主要问题: JobTracker 是 Map-reduce 的集中处理点,存在单点故障. JobTracker 完成了太多的任务,造成了过多的资源消耗,当 ...

  7. Android核心分析之十九电话系统之GSMCallTacker

    GSMCallTracker在本质上是一个Handler.<IGNORE_JS_OP> 1.jpg (1.52 KB, 下载次数: 1) 下载附件  保存到相册 2012-3-22 11: ...

  8. Android 核心分析 之七Service深入分析

    Service深入分析 上一章我们分析了Android IPC架构,知道了Android服务构建的一些基本理念和原理,本章我们将深入分析Android的服务.Android体系架构中三种意义上服务: ...

  9. 怎样在java代码中调用执行shell脚本

    // 用法:Runtime.getRuntime().exec("命令"); String shpath="/test/test.sh"; //程序路径 Pro ...

  10. 如何搭建配置php开发环境

    PHP的配置 1.打开解压后的C:\Program Files (x86)\php-5.3.5文件夹 1 将php.ini-development文件并更改名称为php.ini(留个备份,好习惯) 2 ...