20 #include <QApplication>
33 static inline tstring toTString(QString s)
35 return s.toStdWString();
39 static inline tstring toTString(QString s)
41 return s.toStdString();
48 return toTString(
"\"" + QApplication::applicationFilePath().replace(
'/',
'\\') +
"\" -p \""
58 bool Platform::setAutorun(
bool on)
61 if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT(
"Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
62 0, KEY_ALL_ACCESS, &key)
71 result = RegSetValueEx(key, keyName.c_str(), 0, REG_SZ,
const_cast<PBYTE
>(
reinterpret_cast<const unsigned char*
>(path.c_str())),
72 path.length() *
sizeof(TCHAR))
75 result = RegDeleteValue(key, keyName.c_str()) == ERROR_SUCCESS;
81 bool Platform::getAutorun()
84 if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT(
"Software\\Microsoft\\Windows\\CurrentVersion\\Run"),
85 0, KEY_ALL_ACCESS, &key)
91 TCHAR path[MAX_PATH] = {0};
92 DWORD length =
sizeof(path);
96 if (RegQueryValueEx(key, keyName.c_str(),
nullptr, &type,
const_cast<PBYTE
>(
reinterpret_cast<const unsigned char*
>(path)), &length) == ERROR_SUCCESS