nesca/main.cpp

80 lines
1.8 KiB
C++
Raw Normal View History

2015-02-24 14:00:19 +00:00
#include "nesca_3.h"
#include <QApplication>
2015-02-24 14:14:32 +00:00
#include <qfontdatabase.h>
2015-08-07 22:37:28 +00:00
#include <QMessageBox.h>
#include <qpixmap.h>
#include "Utils.h"
2015-02-24 14:00:19 +00:00
int main(int argc, char *argv[])
{
2015-08-07 22:37:28 +00:00
bool isWM = false;
DWORD Type;
char value[512] = { 0 };
char resultString[512] = { 0 };
HKEY hkey;
if (RegOpenKey(HKEY_LOCAL_MACHINE,
TEXT("HARDWARE\\DESCRIPTION\\System"), &hkey) == ERROR_SUCCESS)
{
DWORD value_length = 512;
RegQueryValueEx(hkey, L"VideoBiosVersion", 0, &Type, (BYTE*)&value, &value_length);
RegCloseKey(hkey);
2015-03-23 12:52:07 +00:00
2015-08-07 22:37:28 +00:00
for (int i = 0, j = 0; i < 256; ++i, j += 2) {
char ch = value[j];
if (ch != '\0') {
resultString[i] = ch;
2015-02-24 14:00:19 +00:00
}
2015-08-07 22:37:28 +00:00
else {
resultString[i] = '\n';
2015-02-24 14:00:19 +00:00
}
}
2015-08-07 22:37:28 +00:00
resultString[256] = '\0';
2015-02-24 14:00:19 +00:00
}
2015-08-07 22:37:28 +00:00
if (strstr(resultString, "VirtualBox") ||
strstr(resultString, "virtualbox")) {
isWM = true;
};
2015-03-07 17:31:48 +00:00
2015-08-07 22:37:28 +00:00
QApplication a(argc, argv);
if (isWM) {
QMessageBox msgBox(
QMessageBox::Information,
"Nope",
"");
QPalette palette;
palette.setBrush(QPalette::Background, Qt::cyan);
msgBox.setIconPixmap(QPixmap(":/nesca_3/xc.jpg"));
msgBox.setPalette(palette);
msgBox.setVisible(true);
msgBox.exec();
} else {
QStringList list;
list << "small_font.ttf";
int fontID(-1);
bool fontWarningShown(false);
for (QStringList::const_iterator constIterator = list.constBegin(); constIterator != list.constEnd(); ++constIterator) {
QFile res(":/nesca_3/" + *constIterator);
if (res.open(QIODevice::ReadOnly) == false) {
if (fontWarningShown == false) {
fontWarningShown = true;
}
}
else {
fontID = QFontDatabase::addApplicationFontFromData(res.readAll());
if (fontID == -1 && fontWarningShown == false) {
fontWarningShown = true;
}
}
}
nesca_3 *gui = new nesca_3(isWM, 0);
if (isWM) {
Utils::emitScaryError();
}
gui->showNormal();
}
2015-02-24 14:00:19 +00:00
return a.exec();
}
2015-02-24 14:14:32 +00:00