第一阶段只差兼容性问题了
This commit is contained in:
@ -2,11 +2,13 @@
|
||||
#include <Windows.h>
|
||||
#include <QClipBoard>
|
||||
#include "netio.h"
|
||||
#include "config.h"
|
||||
#include "globalvariables.h"
|
||||
MySettingsDialog::MySettingsDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
setWindowFlags(Qt::WindowCloseButtonHint);
|
||||
this->setFixedSize(width(), height());
|
||||
HKEY hRoot = HKEY_CURRENT_USER;
|
||||
wchar_t *szSubKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||
@ -19,10 +21,10 @@ MySettingsDialog::MySettingsDialog(QWidget *parent)
|
||||
}
|
||||
QString app = QApplication::applicationFilePath();
|
||||
app.replace("/", "\\");
|
||||
DWORD size=128;
|
||||
wchar_t reg[128];
|
||||
lRet = RegGetValue(hRoot, szSubKey, L"OfficeAssistant", RRF_RT_ANY, nullptr, reg, &size);
|
||||
if (wcscmp(reg,app.toStdWString().c_str())==0) {
|
||||
DWORD size=128+sizeof(wchar_t);
|
||||
char reg[128] = { 0 };
|
||||
lRet = RegQueryValueEx(hKey, L"OfficeAssistant", NULL, NULL,(LPBYTE)reg, &size);
|
||||
if (lRet==0) {
|
||||
ui.autostart->setChecked(true);
|
||||
}
|
||||
copyButton = ui.copy;
|
||||
@ -31,6 +33,7 @@ MySettingsDialog::MySettingsDialog(QWidget *parent)
|
||||
connect(ui.addshortcut, &QPushButton::clicked, this, &MySettingsDialog::createShortcut);
|
||||
connect(ui.law_button, &QPushButton::clicked, this, &MySettingsDialog::law);
|
||||
ui.code->setText(QString(QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5).toHex()));
|
||||
ui.version->setText(QString(VERSION) + "-" + QString(RELEASE));
|
||||
}
|
||||
|
||||
MySettingsDialog::~MySettingsDialog()
|
||||
@ -53,7 +56,7 @@ void MySettingsDialog::autoStart(int state)
|
||||
QString app = QApplication::applicationFilePath();
|
||||
app.replace("/", "\\");
|
||||
qDebug() << app.toStdWString().c_str();
|
||||
lRet = RegSetValueEx(hKey, L"OfficeAssistant", 0, REG_SZ, (BYTE*)app.toStdWString().c_str(), app.length()*sizeof(wchar_t));
|
||||
lRet = RegSetValueEx(hKey, LENG_NAME, 0, REG_SZ, (BYTE*)app.toStdWString().c_str(), app.length()*sizeof(wchar_t));
|
||||
if (lRet == ERROR_SUCCESS)
|
||||
{
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>"));
|
||||
@ -72,7 +75,7 @@ void MySettingsDialog::autoStart(int state)
|
||||
return;
|
||||
}
|
||||
QString app = QApplication::applicationFilePath();
|
||||
lRet = RegDeleteValue(hKey, L"OfficeAssistant");
|
||||
lRet = RegDeleteValue(hKey, LENG_NAME);
|
||||
if (lRet == ERROR_SUCCESS)
|
||||
{
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>"));
|
||||
@ -95,7 +98,9 @@ void MySettingsDialog::copyToCLipboard() {
|
||||
}
|
||||
void MySettingsDialog::createShortcut() {
|
||||
QString deskTopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
||||
deskTopPath = deskTopPath + QString::fromLocal8Bit("/<EFBFBD>칫<EFBFBD><EFBFBD><EFBFBD><EFBFBD>.lnk");
|
||||
deskTopPath = deskTopPath + QString::fromLocal8Bit("/");
|
||||
deskTopPath = deskTopPath + QString::fromLocal8Bit(NAME);
|
||||
deskTopPath = deskTopPath + QString::fromLocal8Bit(".lnk");
|
||||
QString srcFile = QApplication::applicationFilePath();
|
||||
bool succeed=QFile::link(srcFile, deskTopPath);
|
||||
if (succeed) {
|
||||
|
Reference in New Issue
Block a user