Improved: Switched to stricter code formatter (Uncrustify) for better consistency across all source files.
This commit is contained in:
1 parent
a1be4cc70f
commit
57e8158efd
202 files changed
+4595
-4284
No files matched your search
+120
-120
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
This file is part of EqualizerAPO, a system-wide equalizer.
|
||||
Copyright (C) 2012 Jonas Thedering
|
||||
This file is part of EqualizerAPO, a system-wide equalizer.
|
||||
Copyright (C) 2012 Jonas Thedering
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
@@ -32,7 +32,7 @@ using namespace std;
|
||||
Configurator* configurator;
|
||||
|
||||
Configurator::Configurator(HINSTANCE hInstance, const wchar_t* cmdLine)
|
||||
:cmdLine(cmdLine)
|
||||
: cmdLine(cmdLine)
|
||||
{
|
||||
this->hInstance = hInstance;
|
||||
hDlg = NULL;
|
||||
@@ -67,56 +67,56 @@ void Configurator::onInitDialog(HWND hDlg)
|
||||
tci.pszText = stringBuf;
|
||||
tci.mask = TCIF_TEXT;
|
||||
|
||||
LoadStringW(hInstance, IDS_PLAYBACK_DEVICES, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_PLAYBACK_DEVICES, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
TabCtrl_InsertItem(categoryTabCtrl, 0, &tci);
|
||||
|
||||
LoadStringW(hInstance, IDS_CAPTURE_DEVICES, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_CAPTURE_DEVICES, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
TabCtrl_InsertItem(categoryTabCtrl, 1, &tci);
|
||||
|
||||
LoadStringW(hInstance, IDS_REQUEST, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_REQUEST, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
SetWindowTextW(requestLabel, stringBuf);
|
||||
|
||||
LoadStringW(hInstance, IDS_COPY_DEVICE_COMMAND, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_COPY_DEVICE_COMMAND, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
SetWindowTextW(copyDeviceCommandButton, stringBuf);
|
||||
|
||||
LoadStringW(hInstance, IDS_OK, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_OK, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
SetWindowTextW(okButton, stringBuf);
|
||||
|
||||
LoadStringW(hInstance, IDS_CANCEL, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_CANCEL, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
SetWindowTextW(cancelButton, stringBuf);
|
||||
|
||||
LoadStringW(hInstance, IDS_TOGGLE_TROUBLESHOOTING, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_TOGGLE_TROUBLESHOOTING, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
SetWindowTextW(toggleTroubleShooting, stringBuf);
|
||||
int width = 185;
|
||||
if(wcsncmp(stringBuf, L"Probleml", 8) == 0)
|
||||
if (wcsncmp(stringBuf, L"Probleml", 8) == 0)
|
||||
width = 215;
|
||||
RECT rect = {0, 0, width, 10};
|
||||
MapDialogRect(hDlg, &rect);
|
||||
SetWindowPos(toggleTroubleShooting, NULL, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
|
||||
SetWindowPos(toggleTroubleShooting, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
|
||||
|
||||
LoadStringW(hInstance, IDS_PRE_MIX_LABEL, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_PRE_MIX_LABEL, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
SetWindowTextW(preMixLabel, stringBuf);
|
||||
|
||||
LoadStringW(hInstance, IDS_POST_MIX_LABEL, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_POST_MIX_LABEL, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
SetWindowTextW(postMixLabel, stringBuf);
|
||||
|
||||
LoadStringW(hInstance, IDS_INSTALL_APO, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_INSTALL_APO, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
SetWindowTextW(installPreMix, stringBuf);
|
||||
SetWindowTextW(installPostMix, stringBuf);
|
||||
|
||||
LoadStringW(hInstance, IDS_USE_ORIGINAL_APO, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_USE_ORIGINAL_APO, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
SetWindowTextW(useOriginalAPOPreMix, stringBuf);
|
||||
SetWindowTextW(useOriginalAPOPostMix, stringBuf);
|
||||
|
||||
LoadStringW(hInstance, IDS_INSTALL_MODE_LFX_GFX, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_INSTALL_MODE_LFX_GFX, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
ComboBox_AddString(installModeComboBox, stringBuf);
|
||||
|
||||
if(RegistryHelper::isWindowsVersionAtLeast(6, 3)) // Windows 8.1
|
||||
if (RegistryHelper::isWindowsVersionAtLeast(6, 3)) // Windows 8.1
|
||||
{
|
||||
LoadStringW(hInstance, IDS_INSTALL_MODE_SFX_MFX, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_INSTALL_MODE_SFX_MFX, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
ComboBox_AddString(installModeComboBox, stringBuf);
|
||||
|
||||
LoadStringW(hInstance, IDS_INSTALL_MODE_SFX_EFX, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_INSTALL_MODE_SFX_EFX, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
ComboBox_AddString(installModeComboBox, stringBuf);
|
||||
}
|
||||
ComboBox_SetCurSel(installModeComboBox, 0);
|
||||
@@ -124,7 +124,7 @@ void Configurator::onInitDialog(HWND hDlg)
|
||||
LoadStringW(hInstance, IDS_SELECT_ONE_DEVICE, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
SetWindowTextW(selectOneDeviceLabel, stringBuf);
|
||||
|
||||
for(int i=0; i<=1; i++)
|
||||
for (int i = 0; i <= 1; i++)
|
||||
{
|
||||
HWND deviceList = deviceLists[i];
|
||||
ListView_SetExtendedListViewStyle(deviceList, ListView_GetExtendedListViewStyle(deviceList) | LVS_EX_CHECKBOXES);
|
||||
@@ -132,13 +132,13 @@ void Configurator::onInitDialog(HWND hDlg)
|
||||
column.pszText = stringBuf;
|
||||
column.mask = LVCF_TEXT;
|
||||
|
||||
LoadStringW(hInstance, IDS_CONNECTOR, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_CONNECTOR, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
ListView_InsertColumn(deviceList, 0, &column);
|
||||
|
||||
LoadStringW(hInstance, IDS_DEVICE, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_DEVICE, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
ListView_InsertColumn(deviceList, 1, &column);
|
||||
|
||||
LoadStringW(hInstance, IDS_STATUS, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_STATUS, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
ListView_InsertColumn(deviceList, 2, &column);
|
||||
|
||||
LVITEM item;
|
||||
@@ -148,42 +148,42 @@ void Configurator::onInitDialog(HWND hDlg)
|
||||
|
||||
try
|
||||
{
|
||||
apoInfos[i] = DeviceAPOInfo::loadAllInfos(i==1);
|
||||
wstring defaultDevice = StringHelper::toLowerCase(DeviceAPOInfo::getDefaultDevice(i==1));
|
||||
apoInfos[i] = DeviceAPOInfo::loadAllInfos(i == 1);
|
||||
wstring defaultDevice = StringHelper::toLowerCase(DeviceAPOInfo::getDefaultDevice(i == 1));
|
||||
|
||||
int itemCount=0;
|
||||
for(vector<DeviceAPOInfo>::iterator it = apoInfos[i].begin(); it != apoInfos[i].end(); it++)
|
||||
int itemCount = 0;
|
||||
for (vector<DeviceAPOInfo>::iterator it = apoInfos[i].begin(); it != apoInfos[i].end(); it++)
|
||||
{
|
||||
wcsncpy_s(stringBuf, sizeof(stringBuf)/sizeof(wchar_t), it->connectionName.c_str(), _TRUNCATE);
|
||||
wcsncpy_s(stringBuf, sizeof(stringBuf) / sizeof(wchar_t), it->connectionName.c_str(), _TRUNCATE);
|
||||
item.iItem = itemCount;
|
||||
item.lParam = itemCount;
|
||||
ListView_InsertItem(deviceList, &item);
|
||||
wcsncpy_s(stringBuf, sizeof(stringBuf)/sizeof(wchar_t), it->deviceName.c_str(), _TRUNCATE);
|
||||
wcsncpy_s(stringBuf, sizeof(stringBuf) / sizeof(wchar_t), it->deviceName.c_str(), _TRUNCATE);
|
||||
ListView_SetItemText(deviceList, itemCount, 1, stringBuf);
|
||||
|
||||
if(it->isInstalled)
|
||||
if (it->isInstalled)
|
||||
{
|
||||
ListView_SetCheckState(deviceList, itemCount, TRUE);
|
||||
if(it->canBeUpgraded())
|
||||
if (it->canBeUpgraded())
|
||||
LoadStringW(hInstance, IDS_WILL_BE_UPGRADED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
else if(it->isEnhancementsDisabled)
|
||||
else if (it->isEnhancementsDisabled)
|
||||
LoadStringW(hInstance, IDS_ENHANCEMENTS_WILL_BE_ENABLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
else
|
||||
LoadStringW(hInstance, IDS_ALREADY_INSTALLED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_ALREADY_INSTALLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
}
|
||||
else if(it->isExperimental())
|
||||
else if (it->isExperimental())
|
||||
{
|
||||
LoadStringW(hInstance, IDS_CAN_BE_INSTALLED_EXPERIMENTAL, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_CAN_BE_INSTALLED_EXPERIMENTAL, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadStringW(hInstance, IDS_CAN_BE_INSTALLED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_CAN_BE_INSTALLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
}
|
||||
|
||||
if(it->isDefaultDevice)
|
||||
if (it->isDefaultDevice)
|
||||
{
|
||||
wstring statusText = stringBuf;
|
||||
LoadStringW(hInstance, IDS_DEFAULT_DEVICE, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_DEFAULT_DEVICE, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
statusText = wstring(stringBuf) + L", " + statusText;
|
||||
|
||||
ListView_SetItemText(deviceList, itemCount, 2, const_cast<wchar_t*>(statusText.c_str()));
|
||||
@@ -196,7 +196,7 @@ void Configurator::onInitDialog(HWND hDlg)
|
||||
itemCount++;
|
||||
}
|
||||
}
|
||||
catch(RegistryException e)
|
||||
catch (RegistryException e)
|
||||
{
|
||||
MessageBoxW(hDlg, e.getMessage().c_str(), L"Error while accessing the registry", MB_ICONERROR | MB_OK);
|
||||
}
|
||||
@@ -226,15 +226,15 @@ void Configurator::onLvnItemChanged(unsigned sourceId, LPNMLISTVIEW info)
|
||||
|
||||
bool Configurator::onButtonClicked(unsigned sourceId)
|
||||
{
|
||||
switch(sourceId)
|
||||
switch (sourceId)
|
||||
{
|
||||
case IDOK:
|
||||
{
|
||||
for(int index = 0; index <= 1; index++)
|
||||
for (int index = 0; index <= 1; index++)
|
||||
{
|
||||
HWND deviceList = deviceLists[index];
|
||||
|
||||
for(int i = 0; i < ListView_GetItemCount(deviceList); i++)
|
||||
for (int i = 0; i < ListView_GetItemCount(deviceList); i++)
|
||||
{
|
||||
LVITEM item;
|
||||
item.iItem = i;
|
||||
@@ -245,18 +245,18 @@ bool Configurator::onButtonClicked(unsigned sourceId)
|
||||
try
|
||||
{
|
||||
DeviceAPOInfo info = apoInfos[index][item.lParam];
|
||||
if(ListView_GetCheckState(deviceList, i) && !info.isInstalled)
|
||||
if (ListView_GetCheckState(deviceList, i) && !info.isInstalled)
|
||||
info.install();
|
||||
else if(!ListView_GetCheckState(deviceList, i) && info.isInstalled)
|
||||
else if (!ListView_GetCheckState(deviceList, i) && info.isInstalled)
|
||||
info.uninstall();
|
||||
else if(ListView_GetCheckState(deviceList, i) && (info.canBeUpgraded() || info.hasChanges() || info.isEnhancementsDisabled))
|
||||
else if (ListView_GetCheckState(deviceList, i) && (info.canBeUpgraded() || info.hasChanges() || info.isEnhancementsDisabled))
|
||||
{
|
||||
info.uninstall();
|
||||
info.load(info.deviceGuid);
|
||||
info.install();
|
||||
}
|
||||
}
|
||||
catch(RegistryException e)
|
||||
catch (RegistryException e)
|
||||
{
|
||||
MessageBoxW(hDlg, e.getMessage().c_str(), L"Error while accessing the registry", MB_ICONERROR | MB_OK);
|
||||
}
|
||||
@@ -272,7 +272,7 @@ bool Configurator::onButtonClicked(unsigned sourceId)
|
||||
HWND deviceList = deviceLists[index];
|
||||
|
||||
bool first = true;
|
||||
for(int i = 0; i < ListView_GetItemCount(deviceList); i++)
|
||||
for (int i = 0; i < ListView_GetItemCount(deviceList); i++)
|
||||
{
|
||||
LVITEM item;
|
||||
item.iItem = i;
|
||||
@@ -281,9 +281,9 @@ bool Configurator::onButtonClicked(unsigned sourceId)
|
||||
item.stateMask = LVIS_SELECTED;
|
||||
ListView_GetItem(deviceList, &item);
|
||||
|
||||
if(item.state & LVIS_SELECTED)
|
||||
if (item.state & LVIS_SELECTED)
|
||||
{
|
||||
if(first)
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
command += L"; ";
|
||||
@@ -321,7 +321,7 @@ bool Configurator::onButtonClicked(unsigned sourceId)
|
||||
HWND deviceList = deviceLists[index];
|
||||
|
||||
unsigned selectedCount = ListView_GetSelectedCount(deviceList);
|
||||
for(int i = 0; i < ListView_GetItemCount(deviceList); i++)
|
||||
for (int i = 0; i < ListView_GetItemCount(deviceList); i++)
|
||||
{
|
||||
LVITEM item;
|
||||
item.iItem = i;
|
||||
@@ -330,11 +330,11 @@ bool Configurator::onButtonClicked(unsigned sourceId)
|
||||
item.stateMask = LVIS_SELECTED;
|
||||
ListView_GetItem(deviceList, &item);
|
||||
|
||||
if(item.state & LVIS_SELECTED)
|
||||
if (item.state & LVIS_SELECTED)
|
||||
{
|
||||
DeviceAPOInfo& info = apoInfos[index][item.lParam];
|
||||
|
||||
switch(sourceId)
|
||||
switch (sourceId)
|
||||
{
|
||||
case IDC_INSTALL_PRE_MIX:
|
||||
info.selectedInstallState.installPreMix = Button_GetCheck(installPreMix) == BST_CHECKED;
|
||||
@@ -362,45 +362,45 @@ bool Configurator::onButtonClicked(unsigned sourceId)
|
||||
break;
|
||||
}
|
||||
|
||||
if(sourceId == IDCANCEL && hasUpgrades())
|
||||
if (sourceId == IDCANCEL && hasUpgrades())
|
||||
{
|
||||
wchar_t captionBuf[255];
|
||||
LoadStringW(hInstance, IDS_CANCEL_UPGRADES_CAPTION, captionBuf, sizeof(captionBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_CANCEL_UPGRADES_CAPTION, captionBuf, sizeof(captionBuf) / sizeof(wchar_t));
|
||||
wchar_t stringBuf[255];
|
||||
LoadStringW(hInstance, IDS_CANCEL_UPGRADES, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
if(MessageBoxW(hDlg, stringBuf, captionBuf, MB_ICONWARNING | MB_YESNO) == IDNO)
|
||||
LoadStringW(hInstance, IDS_CANCEL_UPGRADES, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
if (MessageBoxW(hDlg, stringBuf, captionBuf, MB_ICONWARNING | MB_YESNO) == IDNO)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(sourceId == IDOK || sourceId == IDCANCEL)
|
||||
if (sourceId == IDOK || sourceId == IDCANCEL)
|
||||
{
|
||||
if(cmdLine == L"/i")
|
||||
if (cmdLine == L"/i")
|
||||
{
|
||||
wchar_t stringBuf[255];
|
||||
LoadStringW(hInstance, IDS_AFTERINSTALL, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_AFTERINSTALL, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
MessageBoxW(hDlg, stringBuf, L"Info", MB_ICONINFORMATION | MB_OK);
|
||||
}
|
||||
else if(sourceId == IDOK && RegistryHelper::isWindowsVersionAtLeast(6, 3) // Windows 8.1
|
||||
else if (sourceId == IDOK && RegistryHelper::isWindowsVersionAtLeast(6, 3) // Windows 8.1
|
||||
|| askForReboot)
|
||||
{
|
||||
wchar_t captionBuf[255];
|
||||
LoadStringW(hInstance, IDS_SHOULD_REBOOT_CAPTION, captionBuf, sizeof(captionBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_SHOULD_REBOOT_CAPTION, captionBuf, sizeof(captionBuf) / sizeof(wchar_t));
|
||||
wchar_t stringBuf[255];
|
||||
LoadStringW(hInstance, IDS_SHOULD_REBOOT, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
if(MessageBoxW(hDlg, stringBuf, captionBuf, MB_ICONQUESTION | MB_YESNO) == IDYES)
|
||||
LoadStringW(hInstance, IDS_SHOULD_REBOOT, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
if (MessageBoxW(hDlg, stringBuf, captionBuf, MB_ICONQUESTION | MB_YESNO) == IDYES)
|
||||
{
|
||||
HANDLE tokenHandle;
|
||||
if(OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &tokenHandle))
|
||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &tokenHandle))
|
||||
{
|
||||
LUID luid;
|
||||
if(LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &luid))
|
||||
if (LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &luid))
|
||||
{
|
||||
TOKEN_PRIVILEGES tp;
|
||||
tp.PrivilegeCount = 1;
|
||||
tp.Privileges[0].Luid = luid;
|
||||
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
if(AdjustTokenPrivileges(tokenHandle, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL))
|
||||
if (AdjustTokenPrivileges(tokenHandle, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL))
|
||||
InitiateShutdownW(NULL, NULL, 0, SHUTDOWN_RESTART | SHUTDOWN_GRACE_OVERRIDE, SHTDN_REASON_MAJOR_APPLICATION | SHTDN_REASON_MINOR_MAINTENANCE);
|
||||
}
|
||||
|
||||
@@ -431,11 +431,11 @@ bool Configurator::isAnySelected()
|
||||
{
|
||||
bool anySelected = false;
|
||||
|
||||
for(int index = 0; index <= 1; index++)
|
||||
for (int index = 0; index <= 1; index++)
|
||||
{
|
||||
HWND deviceList = deviceLists[index];
|
||||
|
||||
for(int i = 0; i < ListView_GetItemCount(deviceList); i++)
|
||||
for (int i = 0; i < ListView_GetItemCount(deviceList); i++)
|
||||
{
|
||||
LVITEM item;
|
||||
item.iItem = i;
|
||||
@@ -443,7 +443,7 @@ bool Configurator::isAnySelected()
|
||||
item.mask = LVIF_PARAM;
|
||||
ListView_GetItem(deviceList, &item);
|
||||
DeviceAPOInfo apoInfo = apoInfos[index][item.lParam];
|
||||
if(ListView_GetCheckState(deviceList, i) != 0)
|
||||
if (ListView_GetCheckState(deviceList, i) != 0)
|
||||
{
|
||||
anySelected = true;
|
||||
break;
|
||||
@@ -458,11 +458,11 @@ bool Configurator::isChanged()
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
for(int index = 0; index <= 1; index++)
|
||||
for (int index = 0; index <= 1; index++)
|
||||
{
|
||||
HWND deviceList = deviceLists[index];
|
||||
|
||||
for(int i = 0; i < ListView_GetItemCount(deviceList); i++)
|
||||
for (int i = 0; i < ListView_GetItemCount(deviceList); i++)
|
||||
{
|
||||
LVITEM item;
|
||||
item.iItem = i;
|
||||
@@ -470,7 +470,7 @@ bool Configurator::isChanged()
|
||||
item.mask = LVIF_PARAM;
|
||||
ListView_GetItem(deviceList, &item);
|
||||
DeviceAPOInfo apoInfo = apoInfos[index][item.lParam];
|
||||
if((ListView_GetCheckState(deviceList, i) != 0) != apoInfo.isInstalled
|
||||
if ((ListView_GetCheckState(deviceList, i) != 0) != apoInfo.isInstalled
|
||||
|| ListView_GetCheckState(deviceList, i) && apoInfo.isInstalled && (apoInfo.canBeUpgraded() || apoInfo.hasChanges() || apoInfo.isEnhancementsDisabled))
|
||||
{
|
||||
changed = true;
|
||||
@@ -486,11 +486,11 @@ bool Configurator::hasUpgrades()
|
||||
{
|
||||
bool hasUpgrades = false;
|
||||
|
||||
for(int index = 0; index <= 1; index++)
|
||||
for (int index = 0; index <= 1; index++)
|
||||
{
|
||||
HWND deviceList = deviceLists[index];
|
||||
|
||||
for(int i = 0; i < ListView_GetItemCount(deviceList); i++)
|
||||
for (int i = 0; i < ListView_GetItemCount(deviceList); i++)
|
||||
{
|
||||
LVITEM item;
|
||||
item.iItem = i;
|
||||
@@ -498,7 +498,7 @@ bool Configurator::hasUpgrades()
|
||||
item.mask = LVIF_PARAM;
|
||||
ListView_GetItem(deviceList, &item);
|
||||
DeviceAPOInfo apoInfo = apoInfos[index][item.lParam];
|
||||
if(ListView_GetCheckState(deviceList, i) && apoInfo.isInstalled && (apoInfo.canBeUpgraded() || apoInfo.isEnhancementsDisabled))
|
||||
if (ListView_GetCheckState(deviceList, i) && apoInfo.isInstalled && (apoInfo.canBeUpgraded() || apoInfo.isEnhancementsDisabled))
|
||||
{
|
||||
hasUpgrades = true;
|
||||
break;
|
||||
@@ -536,15 +536,15 @@ void Configurator::expandTroubleShooting(bool expand)
|
||||
WINDOWINFO windowInfo;
|
||||
GetWindowInfo(hDlg, &windowInfo);
|
||||
int height = expand ? 250 : 209;
|
||||
RECT rect={0, 0, 401, height};
|
||||
RECT rect = {0, 0, 401, height};
|
||||
MapDialogRect(hDlg, &rect);
|
||||
AdjustWindowRect(&rect, windowInfo.dwStyle, false);
|
||||
SetWindowPos(hDlg, NULL, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
|
||||
SetWindowPos(hDlg, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
|
||||
}
|
||||
|
||||
HDWP Configurator::moveWindow(HDWP hdwp, HWND hWnd, int x, int y)
|
||||
{
|
||||
RECT rect={x, y, 0, 0};
|
||||
RECT rect = {x, y, 0, 0};
|
||||
MapDialogRect(hDlg, &rect);
|
||||
return DeferWindowPos(hdwp, hWnd, NULL, rect.left, rect.top, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
|
||||
}
|
||||
@@ -555,32 +555,32 @@ void Configurator::updateList(int listIndex, int itemIndex)
|
||||
|
||||
int itemCount = ListView_GetItemCount(deviceList);
|
||||
|
||||
if(apoInfos[listIndex].size() == itemCount)
|
||||
if (apoInfos[listIndex].size() == itemCount)
|
||||
{
|
||||
DeviceAPOInfo apoInfo = apoInfos[listIndex][itemIndex];
|
||||
bool checked = ListView_GetCheckState(deviceList, itemIndex) != 0;
|
||||
wchar_t stringBuf[255];
|
||||
if(checked && !apoInfo.isInstalled)
|
||||
LoadStringW(hInstance, IDS_WILL_BE_INSTALLED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
else if(!checked && apoInfo.isInstalled)
|
||||
LoadStringW(hInstance, IDS_WILL_BE_UNINSTALLED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
else if(apoInfo.isInstalled && apoInfo.canBeUpgraded())
|
||||
LoadStringW(hInstance, IDS_WILL_BE_UPGRADED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
else if(apoInfo.isInstalled && apoInfo.hasChanges())
|
||||
LoadStringW(hInstance, IDS_WILL_BE_CHANGED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
else if(apoInfo.isInstalled && apoInfo.isEnhancementsDisabled)
|
||||
if (checked && !apoInfo.isInstalled)
|
||||
LoadStringW(hInstance, IDS_WILL_BE_INSTALLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
else if (!checked && apoInfo.isInstalled)
|
||||
LoadStringW(hInstance, IDS_WILL_BE_UNINSTALLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
else if (apoInfo.isInstalled && apoInfo.canBeUpgraded())
|
||||
LoadStringW(hInstance, IDS_WILL_BE_UPGRADED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
else if (apoInfo.isInstalled && apoInfo.hasChanges())
|
||||
LoadStringW(hInstance, IDS_WILL_BE_CHANGED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
else if (apoInfo.isInstalled && apoInfo.isEnhancementsDisabled)
|
||||
LoadStringW(hInstance, IDS_ENHANCEMENTS_WILL_BE_ENABLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
else if(apoInfo.isInstalled)
|
||||
LoadStringW(hInstance, IDS_ALREADY_INSTALLED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
else if(apoInfo.isExperimental())
|
||||
LoadStringW(hInstance, IDS_CAN_BE_INSTALLED_EXPERIMENTAL, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
else if (apoInfo.isInstalled)
|
||||
LoadStringW(hInstance, IDS_ALREADY_INSTALLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
else if (apoInfo.isExperimental())
|
||||
LoadStringW(hInstance, IDS_CAN_BE_INSTALLED_EXPERIMENTAL, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
else
|
||||
LoadStringW(hInstance, IDS_CAN_BE_INSTALLED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_CAN_BE_INSTALLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
|
||||
if(apoInfo.isDefaultDevice)
|
||||
if (apoInfo.isDefaultDevice)
|
||||
{
|
||||
wstring statusText = stringBuf;
|
||||
LoadStringW(hInstance, IDS_DEFAULT_DEVICE, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
LoadStringW(hInstance, IDS_DEFAULT_DEVICE, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
|
||||
statusText = wstring(stringBuf) + L", " + statusText;
|
||||
|
||||
ListView_SetItemText(deviceList, itemIndex, 2, const_cast<wchar_t*>(statusText.c_str()));
|
||||
@@ -600,7 +600,7 @@ void Configurator::updateButtons(int listIndex)
|
||||
|
||||
wchar_t stringBuf[255];
|
||||
bool changed = isChanged();
|
||||
if(changed || !isAnySelected())
|
||||
if (changed || !isAnySelected())
|
||||
{
|
||||
ShowWindow(okButton, SW_SHOW);
|
||||
EnableWindow(okButton, changed);
|
||||
@@ -622,10 +622,10 @@ void Configurator::updateButtons(int listIndex)
|
||||
bool hasOriginalAPOPreMix = true;
|
||||
bool hasOriginalAPOPostMix = true;
|
||||
DeviceAPOInfo::InstallState installState;
|
||||
if(selectedCount == 1)
|
||||
if (selectedCount == 1)
|
||||
{
|
||||
int selectedIndex = ListView_GetNextItem(deviceList, -1, LVNI_SELECTED);
|
||||
if(selectedIndex != -1)
|
||||
if (selectedIndex != -1)
|
||||
{
|
||||
enable = ListView_GetCheckState(deviceList, selectedIndex) != 0;
|
||||
|
||||
@@ -651,7 +651,7 @@ void Configurator::updateButtons(int listIndex)
|
||||
Button_SetCheck(useOriginalAPOPreMix, installState.useOriginalAPOPreMix && hasOriginalAPOPreMix);
|
||||
Button_SetCheck(useOriginalAPOPostMix, installState.useOriginalAPOPostMix && hasOriginalAPOPostMix);
|
||||
|
||||
if(RegistryHelper::isWindowsVersionAtLeast(6, 3)) // Windows 8.1
|
||||
if (RegistryHelper::isWindowsVersionAtLeast(6, 3)) // Windows 8.1
|
||||
ComboBox_SetCurSel(installModeComboBox, installState.installMode);
|
||||
|
||||
expandTroubleShooting(Button_GetCheck(toggleTroubleShooting) != 0);
|
||||
@@ -660,9 +660,9 @@ void Configurator::updateButtons(int listIndex)
|
||||
INT_PTR CALLBACK dlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE /* hPrevInstance */,
|
||||
LPWSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
HINSTANCE /* hPrevInstance */,
|
||||
LPWSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
|
||||
@@ -673,17 +673,17 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
|
||||
int result = 0;
|
||||
|
||||
if(wcscmp(lpCmdLine, L"/u") == 0)
|
||||
if (wcscmp(lpCmdLine, L"/u") == 0)
|
||||
{
|
||||
for(int index = 0; index <= 1; index++)
|
||||
for (int index = 0; index <= 1; index++)
|
||||
{
|
||||
vector<DeviceAPOInfo> apoInfos = DeviceAPOInfo::loadAllInfos(index == 1);
|
||||
|
||||
for(vector<DeviceAPOInfo>::iterator it = apoInfos.begin(); it != apoInfos.end(); it++)
|
||||
for (vector<DeviceAPOInfo>::iterator it = apoInfos.begin(); it != apoInfos.end(); it++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(it->isInstalled)
|
||||
if (it->isInstalled)
|
||||
it->uninstall();
|
||||
}
|
||||
catch (RegistryException e)
|
||||
@@ -699,7 +699,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
configurator = new Configurator(hInstance, lpCmdLine);
|
||||
DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAINWINDOW), GetDesktopWindow(), dlgProc);
|
||||
}
|
||||
|
||||
|
||||
CoUninitialize();
|
||||
|
||||
return result;
|
||||
@@ -716,7 +716,7 @@ INT_PTR CALLBACK dlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return (INT_PTR)TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
if(configurator->onButtonClicked(LOWORD(wParam)))
|
||||
if (configurator->onButtonClicked(LOWORD(wParam)))
|
||||
{
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
return (INT_PTR)TRUE;
|
||||
|
||||
Reference in new issue
Block a user