add util function to extract icon from executable

This commit is contained in:
torusrxxx 2020-08-07 23:17:49 +08:00 committed by Duncan Ogilvie
parent 67ef8e3eaf
commit 714430c2ac
3 changed files with 16 additions and 2 deletions

View File

@ -1,5 +1,5 @@
#include "MiscUtil.h"
#include <windows.h>
#include <QtWin>
#include <QApplication>
#include <QMessageBox>
#include <QDir>
@ -159,6 +159,19 @@ QString getSymbolicNameStr(duint addr)
return finalText;
}
QIcon getFileIcon(QString file)
{
SHFILEINFO info;
if(SHGetFileInfoW((const wchar_t*)file.utf16(), 0, &info, sizeof(info), SHGFI_ICON) == 0)
{
return QIcon(); //API error
}
QIcon result;
result = QIcon(QtWin::fromHICON(info.hIcon));
DestroyIcon(info.hIcon);
return result;
}
bool ExportCSV(dsint rows, dsint columns, std::vector<QString> headers, std::function<QString(dsint, dsint)> getCellContent)
{
BrowseDialog browse(nullptr, QApplication::translate("ExportCSV", "Export data in CSV format"), QApplication::translate("ExportCSV", "Enter the CSV file name to export"), QApplication::translate("ExportCSV", "CSV files (*.csv);;All files (*.*)"), QApplication::applicationDirPath() + QDir::separator() + "db", true);

View File

@ -21,6 +21,7 @@ QString getSymbolicNameStr(duint addr);
bool ExportCSV(dsint rows, dsint columns, std::vector<QString> headers, std::function<QString(dsint, dsint)> getCellContent);
bool isEaster();
QString couldItBeSeasonal(QString icon);
QIcon getFileIcon(QString file);
#define DIcon(file) QIcon(QString(":/icons/images/").append(couldItBeSeasonal(file)))
#endif // MISCUTIL_H

View File

@ -36,7 +36,7 @@ UI_DIR = $${X64_GEN_DIR}
##
## QT libraries
##
QT += core gui network
QT += core gui network winextras
# QT5 requires widgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets