void MConfig::on_windowsDrvAddPushButton_clicked() { QString infFileName = QFileDialog::getOpenFileName(this, tr("Locate the Windows driver you want to add"), "/home", tr("Windows installation information file (*.inf)")); if (!infFileName.isEmpty()) { // Search in the inf file the name of the .sys file QFile infFile(infFileName); infFile.open(QFile::ReadOnly|QFile::Text); QString s; bool found = false; bool exist = false; QStringList foundSysFiles; QDir sysDir(infFileName); sysDir.cdUp(); while ((!infFile.atEnd())) { s = infFile.readLine(); if (s.contains("ServiceBinary",Qt::CaseInsensitive)) { s = s.right(s.length() - s.lastIndexOf('\\')); s = s.remove('\\'); s = s.remove('\n'); found = true; if (this->checkSysFileExists(sysDir, s, Qt::CaseInsensitive)) { exist = true; } else { foundSysFiles << s; } } } infFile.close(); if (found) { if (!exist) { QMessageBox::warning(0, QString(tr("*.sys file not found")), tr("The *.sys files must be in the same location as the *.inf file. %1 cannot be found").arg(foundSysFiles.join(", "))); } else { QString cmd = QString("ndiswrapper -i %1").arg(infFileName); system(cmd.toAscii()); cmd = QString("ndiswrapper -ma"); system(cmd.toAscii()); on_windowsDrvDiagnosePushButton_clicked(); } } else { QMessageBox::critical(0, QString(tr("sys file reference not found")).arg(infFile.fileName()), tr("The sys file for the given driver cannot be determined after parsing the inf file")); } } }
/** finds Control Panel items (applets / applications) that are implemented as a library (in a DLL named *.CPL, supposed to expose the CPlApplet function) and reside in the Windows\System32 directory (those do not necessarily need to be registered in the registry) */ void ControlPanelItemFinder::addSystem32CplControlPanelItems() { // Get a list of all CPL files in the system directory TCHAR sysDirBuffer[DEFAULT_BUFFER_SIZE]; if (GetSystemDirectory(sysDirBuffer, DEFAULT_BUFFER_SIZE)) { // GetSystemDirectory() function is provided primarily for compatibility, it is recommended to use SHGetFolderPath()! QString sysDirPath = QString::fromUtf16(sysDirBuffer); QDir sysDir(sysDirPath); QFileInfoList cplFiles = sysDir.entryInfoList(QStringList("*.cpl"), QDir::Files, QDir::Unsorted); foreach(QFileInfo cplFileInfo, cplFiles) { addCplControlPanelItem(&cplFileInfo); } }