https://q.cnblogs.com/q/69381/
https://www.jb51.net/os/windows/339151.html
pnputil -d是指 -e枚举出来对应的oem*.inf文件
记录给自己看的;
#include <QCoreApplication>
#include <Qprocess>
#include <iostream>
#include <Windows.h>
bool is64BitOs()
{
auto hModule = GetModuleHandle(L"kernel32.dll");
if(hModule && GetProcAddress(hModule, "IsWow64Process"))
{
return true;
}
return false;
}
const QString infFile = "test.inf";
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QProcess p;
QString program;
if(is64BitOs())
{
program = QString("C:\\Windows\\sysnative\\pnputil");
}
else
{
program = QString("C\\Windows\\System32\\pnputil");
}
p.start(program, QStringList() << "-e");
p.waitForFinished();
auto info = QString::fromLocal8Bit(p.readAllStandardOutput());
if(info.contains(QStringLiteral("Silicon Labs Software")))
{
std::cout << "already installed Silicon Labs Software" << std::endl;
}
else
{
std::cout << "not installed" << std::endl;
std::cout << "install start: " << std::endl;
p.start(program, QStringList() << "-i" << "-a" << infFile);
p.waitForFinished();
std::cout << p.readAllStandardOutput().date() << std::endl;
std::cout << "install finshed: " << std::endl;
}
}