Qt 获取usb设备信息 hacking
/**************************************************************************
* 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的更多相关文章
- C# 获取USB设备信息
C# 获取USB设备信息WMI方式 using System; using System.Management; using System.Text.RegularExpressions; using ...
- C#:基于WMI查询USB设备信息 及 Android设备厂商VID列表
/* ---------------------------------------------------------- 文件名称:WMIUsbQuery.cs 作者:秦建辉 MSN:splashc ...
- Windows下USB磁盘开发系列三:枚举系统中U盘、并获取其设备信息
前面我们介绍了枚举系统中的U盘盘符(见<Windows下USB磁盘开发系列一:枚举系统中U盘的盘符>).以及获取USB设备的信息(见<Windows下USB磁盘开发系列二:枚举系统中 ...
- 【转】android 安卓APP获取手机设备信息和手机号码的代码示例
http://blog.csdn.net/changemyself/article/details/7421476 下面我从安卓开发的角度,简单写一下如何获取手机设备信息和手机号码 准备条件:一部安卓 ...
- android 安卓APP获取手机设备信息和手机号码的代码示例
下面我从安卓开发的角度,简单写一下如何获取手机设备信息和手机号码 准备条件:一部安卓手机.手机SIM卡确保插入手机里.eclipse ADT和android-sdk开发环境 第一步:新建一个andro ...
- libusb获取usb设备的idVendor(vid),idProduct(pid),以及Serial Number
发表于2015/6/23 21:55:11 4594人阅读 最近在做关于usb设备的项目,用到了libusb,发现关于这个的函数库的介绍,讲解很少,下面仅仅是简单展示一些基本的使用方法,以备后用. ...
- ?Object-C获取手机设备信息
一.获取UiDevice设备信息 // 获取设备名称 NSString *name = [[UIDevice currentDevice] name]; // 获取设备系统名称 NSString *s ...
- iOS开发-Object-C获取手机设备信息(UIDevice)
一.获取UiDevice设备信息 // 获取设备名称 NSString *name = [[UIDevice currentDevice] name]; // 获取设备系统名称 NSString *s ...
- Python学习---Django的request扩展[获取用户设备信息]
关于Django的request扩展[获取用户设备信息] settings.py INSTALLED_APPS = [ ... 'app01', # 注册app ] STATICFILES_DIRS ...
随机推荐
- 解决Myeclipse 编辑jsp页面卡
解决Myeclipse 编辑jsp页面卡 编辑一个jsp页面时,如果每输入一下,CPU都100%一下,和大家分项一下. 问题: 当你编辑一个jsp页面时,如果每输入一下,CPU都100%一下,3, ...
- http status 汇总
http status 汇总 常见HTTP状态码 200 OK 301 Moved Permanently 302 Found 304 Not Modified 307 Temporary Redir ...
- vi编辑器的常见使用技巧
光标移动 在普通模式下, 1.按 h 向左移动光标 按 h + 数字n 可以向右移动 n个字符 比如 h + 5 就是向左移动5个字符 2.按j向下移动光标 3.按k向上移动光标 4.按 l 向 ...
- [STL]heap和priority_queue
一.heap 在STL中,priority_queue(优先权队列)的底层机制是最大堆,因此有必要先来了解一下heap.heap采用完全二叉树的结构,当然不是真正的binary tree,因为对于完全 ...
- (转载) .NET2.0程序集无法在.net 4.0 中运行的解决方案
首先在MSDN上看到 4.0 的更新日志中有如下这条: .NET Framework 4 不能自动使用自己的公共语言运行时版本来运行由 .NET Framework 早期版本生成的应用程序. 若要使用 ...
- C#遍历打印机
#region 获取本机默认打印机名称 ArrayList al1=new ArrayLIst(); private static PrintDocument fPrintDocument = new ...
- hdu 3853 LOOPS(基础DP求期望)
题目大意 有一个人被困在一个 R*C(2<=R,C<=1000) 的迷宫中,起初他在 (1,1) 这个点,迷宫的出口是 (R,C).在迷宫的每一个格子中,他能花费 2 个魔法值开启传送通道 ...
- linux环境几个特殊的shell变量
特殊的shell变量: $0 获取当前执行的shell脚本的文件名 $n 获取当前执行的shell脚本的第n个参数值,n=1..9 $* 获取当前shell的所有参数 “$1 $2 $3 …注意 ...
- Keil 4.7a版本问题&Jlink Clone问题
听PP说Keil 4.7A新出,支持代码自动补全.激动之至,keil官网急填,下载安装. 问题即刻遇见①,电脑蓝屏,安装包损坏.当下载安装包未下载完时,续传安装包没用了.还是重下载吧,免得浪费时间. ...
- iOS:Autolayout自动布局实例
Autolayout自动布局实例即可以用故事板布局,也可以用纯代码创建,各有各的优点:用故事板布局,比较方便,而且直观,可以很直白的看到视图布局后的变化:采用代码布局,虽然代码比较多,有些麻烦,但是可 ...