TTKMusicPlayer  3.7.0.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 int MusicPlatformManager::windowsIEVersion() const
21 {
22  const DWORD versionInfoSize = GetFileVersionInfoSizeW(L"mshtml.dll", nullptr);
23  if(versionInfoSize == 0)
24  {
25  return -1;
26  }
27 
28  BYTE *data = new BYTE[versionInfoSize];
29  if(!GetFileVersionInfoW(L"mshtml.dll", 0, versionInfoSize, data))
30  {
31  delete[] data;
32  return -1;
33  }
34 
35  const VS_FIXEDFILEINFO *fixedFileInfo = nullptr;
36  UINT fixedFileInfoSize = 0;
37  if(!VerQueryValueW(data, L"\\", (LPVOID*)&fixedFileInfo, &fixedFileInfoSize))
38  {
39  delete[] data;
40  return -1;
41  }
42 
43  delete[] data;
44  return HIWORD(fixedFileInfo->dwProductVersionMS);
45 }
46 
47 void MusicPlatformManager::windowsStartUpMode(bool v) const
48 {
49  const QString &appName = TTK_APP_NAME;
50  QString appPath = TTK_SERVICE_FULL;
51  appPath.replace(TTK_SEPARATOR, TTK_RSEPARATOR);
52 
53  QSettings reg("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
54  QSettings regWOW("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
55 
56  if(v)
57  {
58  if(reg.value(appName).toString() != appPath)
59  {
60  reg.setValue(appName, QString("\"%1\"").arg(appPath));
61  }
62 
63  if(regWOW.value(appName).toString() != appPath)
64  {
65  regWOW.setValue(appName, QString("\"%1\"").arg(appPath));
66  }
67  }
68  else
69  {
70  if(reg.contains(appName))
71  {
72  reg.remove(appName);
73  reg.sync();
74  }
75 
76  if(regWOW.contains(appName))
77  {
78  regWOW.remove(appName);
79  regWOW.sync();
80  }
81  }
82 }
83 #endif
#define TTK_APP_NAME
Definition: ttkobject.h:25
#define TTK_RSEPARATOR
Definition: ttkglobal.h:196
#define TTK_SERVICE_FULL
Definition: ttkqtobject.h:25
#define TTK_SEPARATOR
Definition: ttkglobal.h:195