/**************************************************************************
* 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. ECMAScript5下Array的方法

    声明:ECMAScript不会兼容IE8及以下版本IE浏览器. 一.迭代方法 注:这些迭代方法不会影响数组的值. 每个方法都有两个参数: array.方法(执行函数体,当前作用域(比如this,这个可 ...

  2. HDU 4632 Palindrome subsequence(区间dp,回文串,字符处理)

    题目 参考自博客:http://blog.csdn.net/u011498819/article/details/38356675 题意:查找这样的子回文字符串(未必连续,但是有从左向右的顺序)个数. ...

  3. LA 3713

    The Bandulu Space Agency (BSA) has plans for the following three space missions: Mission A: Landing ...

  4. POJ 3181 Dollar Dayz (完全背包,大数据运算)

    题意:给出两个数,n,m,问1~m中的数组成n,有多少种方法? 这题其实就相当于 UVA 674 Coin Change,求解一样 只不过数据很大,需要用到高精度运算... 后来还看了网上别人的解法, ...

  5. (转)【移动开发】Android中三种超实用的滑屏方式汇总(ViewPager、ViewFlipper、ViewFlow)

    转自: http://smallwoniu.blog.51cto.com/3911954/1308959 现如今主流的Android应用中,都少不了左右滑动滚屏这项功能,(貌似现在好多人使用智能机都习 ...

  6. spring 主题使用详解[转]

    在common_include_v2.jsp文件中,spring主题的使用: <link href="${staticPath }/<spring:theme code='sty ...

  7. Linux之select系统调用_2

    在上一篇博文中,我们的程序中我们有3个客户端,因此也事先建立了3个管道,每个客户端分别使用一个管道向服务器发送消息.而在服务器端使用select系统调用,只要监测到某一管道有消息写入,服务器就将其re ...

  8. No ResultSet was produced

    遇到的详细问题: 出现了No ResultSet was produced的异常,但数据是成功插入, 大致判断异常发生在执行插入操作后,检查代码. 解决方案: 通常在executeQuery(sql) ...

  9. iOS 开发--多线程

    前面在<Bison眼中的iOS开发多线程是这样的(二)>一文中讲完了多线程的NSThread,不难发现这种方式的多线程实现起来非常的复杂,为了简化多线程的开发,iOS提供了GCD来实现多线 ...

  10. 当滚动条滚动到页面底部自动加载增加内容的js代码

    这篇文章主要介绍了如何使用javscript实现滚动条滚动到页面底部自动加载增加页面内容,需要的朋友可以参考下..1,注册页面滚动事件,window.onscroll = function(){ }; ...