阶段性完成,还差独立浏览器和几个别的需求。

This commit is contained in:
Mike Solar
2023-08-26 22:13:39 +08:00
parent 9ee232cead
commit fd525fb8d1
12 changed files with 227 additions and 119 deletions

View File

@ -1,4 +1,4 @@
#include "mysettingsdialog.h"
#include "mysettingsdialog.h"
#include <Windows.h>
#include <QClipBoard>
#include "netio.h"
@ -12,9 +12,9 @@ MySettingsDialog::MySettingsDialog(QWidget *parent)
setWindowFlags(Qt::WindowCloseButtonHint);
this->setFixedSize(width(), height());
HKEY hRoot = HKEY_CURRENT_USER;
wchar_t *szSubKey = (wchar_t *)"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
wchar_t *szSubKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
HKEY hKey;
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // 如果不存在不创建
LONG lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
if (lRet != ERROR_SUCCESS) {
@ -22,9 +22,10 @@ MySettingsDialog::MySettingsDialog(QWidget *parent)
}
QString app = QApplication::applicationFilePath();
app.replace("/", "\\");
DWORD size=128+sizeof(wchar_t);
char reg[128] = { 0 };
lRet = RegQueryValueEx(hKey, L"OfficeAssistant", NULL, NULL,(LPBYTE)reg, &size);
app += " autostart";
DWORD size=256*sizeof(wchar_t);
wchar_t reg[256] = { 0 };
lRet = RegQueryValueEx(hKey, LENG_NAME, NULL, NULL,(LPBYTE)reg, &size);
if (lRet==0) {
ui.autostart->setChecked(true);
}
@ -47,11 +48,11 @@ void MySettingsDialog::autoStart(int state)
HKEY hRoot = HKEY_CURRENT_USER;
wchar_t *szSubKey = (wchar_t*)L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
HKEY hKey;
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // 如果不存在不创建
LONG lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
if (lRet != ERROR_SUCCESS) {
QMessageBox::critical(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>"));
QMessageBox::critical(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项失败"));
return;
}
QString app = QApplication::applicationFilePath();
@ -61,7 +62,7 @@ void MySettingsDialog::autoStart(int state)
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>"));
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项成功"));
}
RegCloseKey(hKey);
if(agree)
@ -78,14 +79,14 @@ void MySettingsDialog::autoStart(int state)
LONG lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
if (lRet != ERROR_SUCCESS) {
QMessageBox::critical(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>"));
QMessageBox::critical(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项失败。"));
return;
}
QString app = QApplication::applicationFilePath();
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>"));
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项成功。"));
}
RegCloseKey(hKey);
if(agree)
@ -116,9 +117,9 @@ void MySettingsDialog::createShortcut() {
QString srcFile = QApplication::applicationFilePath();
bool succeed=QFile::link(srcFile, deskTopPath);
if (succeed) {
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD>ʽ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>"));
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建快捷方式成功。"));
}
else {
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD>ʽʧ<EFBFBD>ܡ<EFBFBD>"));
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建快捷方式失败。"));
}
}