TTKMusicPlayer  4.1.3.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicplatformmanager.cpp
Go to the documentation of this file.
1 #include "musicplatformmanager.h"
2 
3 #ifdef Q_OS_WIN
4 #include <QSettings>
5 #include <QApplication>
6 #define WIN32_LEAN_AND_MEAN
7 #include <qt_windows.h>
8 
9 void MusicPlatformManager::windowsEnableLeftMode()
10 {
11  INPUT input[4];
12  memset(input, 0, sizeof(input));
13  input[0].type = input[1].type = input[2].type = input[3].type = INPUT_KEYBOARD;
14  input[0].ki.wVk = input[2].ki.wVk = VK_LWIN;
15  input[1].ki.wVk = input[3].ki.wVk = 0x44;
16  input[2].ki.dwFlags = input[3].ki.dwFlags = KEYEVENTF_KEYUP;
17  SendInput(4, input, sizeof(INPUT));
18 }
19 
20 void MusicPlatformManager::windowsStartUpMode(bool v) const
21 {
22  const QString &appName = TTK_APP_NAME;
23  QString appPath = TTK_SERVICE_FULL;
24  appPath.replace(TTK_SEPARATOR, TTK_WSEPARATOR);
25 
26  QSettings reg("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
27  QSettings regWOW("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
28 
29  if(v)
30  {
31  if(reg.value(appName).toString() != appPath)
32  {
33  reg.setValue(appName, QString("\"%1\"").arg(appPath));
34  }
35 
36  if(regWOW.value(appName).toString() != appPath)
37  {
38  regWOW.setValue(appName, QString("\"%1\"").arg(appPath));
39  }
40  }
41  else
42  {
43  if(reg.contains(appName))
44  {
45  reg.remove(appName);
46  reg.sync();
47  }
48 
49  if(regWOW.contains(appName))
50  {
51  regWOW.remove(appName);
52  regWOW.sync();
53  }
54  }
55 }
56 #endif
#define TTK_APP_NAME
Definition: ttkobject.h:25
#define TTK_SERVICE_FULL
Definition: ttkqtobject.h:25
#define TTK_SEPARATOR
Definition: ttkglobal.h:196
#define TTK_WSEPARATOR
Definition: ttkglobal.h:197