Improved: Switched to stricter code formatter (Uncrustify) for better consistency across all source files.

This commit is contained in:
jthedering committed 2015-11-23 21:17:34 +00:00
1 parent a1be4cc70f
commit 57e8158efd
202 files changed
+4595 -4284

No files matched your search

+31 -31
View File
@@ -1,20 +1,20 @@
/*
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2015 Jonas Thedering
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2015 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"
@@ -46,7 +46,7 @@ ChannelHelper::ChannelHelper()
channelNameToPosMap[L"SL"] = SPEAKER_SIDE_LEFT;
channelNameToPosMap[L"SR"] = SPEAKER_SIDE_RIGHT;
for(unordered_map<wstring, int>::iterator it=channelNameToPosMap.begin(); it!=channelNameToPosMap.end(); it++)
for (unordered_map<wstring, int>::iterator it = channelNameToPosMap.begin(); it != channelNameToPosMap.end(); it++)
channelPosToNameMap[it->second] = it->first;
}
@@ -54,7 +54,7 @@ int ChannelHelper::getDefaultChannelMask(int channelCount)
{
int channelMask;
switch(channelCount)
switch (channelCount)
{
case 1:
channelMask = KSAUDIO_SPEAKER_MONO;
@@ -81,13 +81,13 @@ int ChannelHelper::getDefaultChannelMask(int channelCount)
vector<wstring> ChannelHelper::getChannelNames(int channelCount, int channelMask)
{
vector<wstring> channelNames;
int c=1;
for(int i=0; i<31; i++)
int c = 1;
for (int i = 0; i < 31; i++)
{
int channelPos = 1<<i;
if(channelMask & channelPos)
int channelPos = 1 << i;
if (channelMask & channelPos)
{
if(channelPosToNameMap.find(channelPos) != channelPosToNameMap.end())
if (channelPosToNameMap.find(channelPos) != channelPosToNameMap.end())
channelNames.push_back(channelPosToNameMap[channelPos]);
else
channelNames.push_back(to_wstring((unsigned long long)c));
@@ -96,7 +96,7 @@ vector<wstring> ChannelHelper::getChannelNames(int channelCount, int channelMask
}
// handle channels not covered by channelMask
for(; c<=channelCount; c++)
for (; c <= channelCount; c++)
channelNames.push_back(to_wstring((unsigned long long)c));
return channelNames;
@@ -106,11 +106,11 @@ int ChannelHelper::getChannelIndex(std::wstring word, const std::vector<std::wst
{
int channelIndex = -1;
if(iswdigit(word[0]))
if (iswdigit(word[0]))
{
channelIndex = wcstol(word.c_str(), NULL, 10) - 1;
if(channelIndex < 0 || channelIndex >= (int)channelNames.size())
if (channelIndex < 0 || channelIndex >= (int)channelNames.size())
{
LogFStatic(L"Channel number %s out of range (1 - %d)", word.c_str(), channelNames.size());
channelIndex = -1;
@@ -120,22 +120,22 @@ int ChannelHelper::getChannelIndex(std::wstring word, const std::vector<std::wst
{
vector<wstring>::const_iterator pos = find(channelNames.begin(), channelNames.end(), word);
if(pos == channelNames.end())
if (pos == channelNames.end())
{
//Special handling to accept "wrong", but unambiguous positions
if(word == L"SL")
// Special handling to accept "wrong", but unambiguous positions
if (word == L"SL")
pos = find(channelNames.begin(), channelNames.end(), L"RL");
else if(word == L"SR")
else if (word == L"SR")
pos = find(channelNames.begin(), channelNames.end(), L"RR");
else if(word == L"RL")
else if (word == L"RL")
pos = find(channelNames.begin(), channelNames.end(), L"SL");
else if(word == L"RR")
else if (word == L"RR")
pos = find(channelNames.begin(), channelNames.end(), L"SR");
}
if(pos != channelNames.end())
if (pos != channelNames.end())
channelIndex = (int)(pos - channelNames.begin());
else if(!allowNew)
else if (!allowNew)
LogFStatic(L"Invalid channel position %s", word.c_str());
}
+13 -13
View File
@@ -1,20 +1,20 @@
/*
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2015 Jonas Thedering
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2015 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.
*/
#pragma once
+25 -25
View File
@@ -1,20 +1,20 @@
/*
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2015 Jonas Thedering
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2015 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"
@@ -33,37 +33,37 @@ GainIterator::GainIterator(const vector<FilterNode>& nodes)
double GainIterator::gainAt(double freq)
{
if(nodeLeft == NULL && nodeRight == NULL || nodeLeft != NULL && freq < nodeLeft->freq)
if (nodeLeft == NULL && nodeRight == NULL || nodeLeft != NULL && freq < nodeLeft->freq)
{
FilterNode findNode(freq, 0);
vector<FilterNode>::iterator it = lower_bound(nodes.begin(), nodes.end(), findNode);
if(it != nodes.begin())
if (it != nodes.begin())
nodeLeft = &*(it - 1);
if(it != nodes.end())
if (it != nodes.end())
nodeRight = &*it;
if(nodeLeft != NULL && nodeRight != NULL)
if (nodeLeft != NULL && nodeRight != NULL)
{
logLeft = log(nodeLeft->freq);
logRightMinusLeft = log(nodeRight->freq) - logLeft;
}
}
else if(nodeRight != NULL && freq > nodeRight->freq)
else if (nodeRight != NULL && freq > nodeRight->freq)
{
vector<FilterNode>::iterator it = nodes.begin() + (nodeRight - &*nodes.begin());
while(it != nodes.end() && freq > it->freq)
while (it != nodes.end() && freq > it->freq)
{
it++;
}
if(it == nodes.end())
if (it == nodes.end())
nodeRight = NULL;
else
nodeRight = &*it;
if(it != nodes.begin())
if (it != nodes.begin())
nodeLeft = &*(it - 1);
if(nodeLeft != NULL && nodeRight != NULL)
if (nodeLeft != NULL && nodeRight != NULL)
{
logLeft = log(nodeLeft->freq);
logRightMinusLeft = log(nodeRight->freq) - logLeft;
@@ -71,14 +71,14 @@ double GainIterator::gainAt(double freq)
}
double dbGain;
if(nodeLeft == NULL)
if (nodeLeft == NULL)
{
if(nodeRight == NULL)
if (nodeRight == NULL)
dbGain = 0.0;
else
dbGain = nodeRight->dbGain;
}
else if(nodeRight == NULL)
else if (nodeRight == NULL)
{
dbGain = nodeLeft->dbGain;
}
+14 -14
View File
@@ -1,20 +1,20 @@
/*
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2015 Jonas Thedering
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2015 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.
*/
#pragma once
@@ -32,7 +32,7 @@ struct FilterNode
this->dbGain = dbGain;
}
bool operator < (FilterNode other)
bool operator<(FilterNode other)
{
return freq < other.freq;
}
+27 -27
View File
@@ -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"
@@ -36,36 +36,36 @@ bool LogHelper::useConsoleColors = false;
void LogHelper::log(const char* file, int line, const void* caller, bool trace, const wchar_t* format, ...)
{
if(!initialized)
if (!initialized)
{
//Do not try to initialize again, even in case of error
// Do not try to initialize again, even in case of error
initialized = true;
wchar_t temp[255];
GetTempPathW(sizeof(temp)/sizeof(wchar_t), temp);
GetTempPathW(sizeof(temp) / sizeof(wchar_t), temp);
logPath = temp;
logPath += L"EqualizerAPO.log";
try
{
if(RegistryHelper::readValue(APP_REGPATH, L"EnableTrace") != L"false")
if (RegistryHelper::readValue(APP_REGPATH, L"EnableTrace") != L"false")
enableTrace = true;
}
catch(RegistryException e)
catch (RegistryException e)
{
LogFStatic(L"%s", e.getMessage());
}
}
if(trace && !enableTrace)
if (trace && !enableTrace)
return;
FILE* fp;
if(presetFP == NULL)
if (presetFP == NULL)
{
errno_t err = _wfopen_s(&fp, logPath.c_str(), L"at");
if(err != 0)
if (err != 0)
return;
}
else
@@ -73,16 +73,16 @@ void LogHelper::log(const char* file, int line, const void* caller, bool trace,
fp = presetFP;
}
if(useConsoleColors)
if (useConsoleColors)
{
HANDLE con = GetStdHandle(STD_OUTPUT_HANDLE);
if(trace)
if (trace)
SetConsoleTextAttribute(con, 2); // Set console color to green
else
SetConsoleTextAttribute(con, 12); // Set console color to red
}
if(!compact)
if (!compact)
{
SYSTEMTIME ___st;
GetLocalTime(&___st);
@@ -91,7 +91,7 @@ void LogHelper::log(const char* file, int line, const void* caller, bool trace,
___st.wYear, ___st.wMonth, ___st.wDay, ___st.wHour, ___st.wMinute, ___st.wSecond, ___st.wMilliseconds, threadId, (DWORD)(unsigned long long)caller, file, line);
}
if(trace)
if (trace)
fwprintf(fp, L"(TRACE) ");
va_list varArgs;
@@ -101,13 +101,13 @@ void LogHelper::log(const char* file, int line, const void* caller, bool trace,
fwprintf(fp, L"\n");
if(useConsoleColors)
if (useConsoleColors)
{
HANDLE con = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(con, 7); // Set console color to light grey (default)
}
if(presetFP == NULL)
if (presetFP == NULL)
fclose(fp);
}
+13 -13
View File
@@ -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.
*/
#pragma once
+23 -23
View File
@@ -1,20 +1,20 @@
/*
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2013 Jonas Thedering
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2013 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"
@@ -40,8 +40,8 @@
// someone forgot to add the __stdcall/WINAPI modifier to BaseAudioProcessingObject.h, so we can't use the existing declarations
extern "C"
{
HRESULT __stdcall AERT_Allocate(size_t size, void **pMemory);
HRESULT __stdcall AERT_Free(void *pMemory);
HRESULT __stdcall AERT_Allocate(size_t size, void** pMemory);
HRESULT __stdcall AERT_Free(void* pMemory);
}
#endif
@@ -52,7 +52,7 @@ void* MemoryHelper::alloc(size_t size)
size += 16;
#ifdef USE_WINDDK
HRESULT hr = AERT_Allocate(size, &memory);
if(FAILED(hr))
if (FAILED(hr))
{
size += 16;
memory = malloc(size);
@@ -61,19 +61,19 @@ void* MemoryHelper::alloc(size_t size)
}
#else
#ifdef _DEBUG
memory = _malloc_dbg(size,_NORMAL_BLOCK, __FILE__, __LINE__);
memory = _malloc_dbg(size, _NORMAL_BLOCK, __FILE__, __LINE__);
#else
memory = malloc(size);
#endif
#endif
if(memory == NULL)
if (memory == NULL)
{
LogFStatic(L"Allocation of %d bytes failed.", size);
return NULL;
}
size_t offset = 16 - ((size_t)memory) % 16;
if(alternative)
if (alternative)
offset += 16;
void* ptr = ((char*)memory) + offset;
((char*)ptr)[-1] = (char)offset;
@@ -85,27 +85,27 @@ void MemoryHelper::free(void* ptr)
{
bool alternative = false;
char offset = ((char*)ptr)[-1];
if(offset > 16)
if (offset > 16)
alternative = true;
void* memory = ((char*)ptr) - offset;
#ifdef USE_WINDDK
if(alternative)
if (alternative)
{
::free(memory);
}
else
{
HRESULT hr = AERT_Free(memory);
if(FAILED(hr))
if (FAILED(hr))
{
LogFStatic(L"Memory release failed. Error code %X", hr);
}
}
#else
#ifdef _DEBUG
_free_dbg(memory,_NORMAL_BLOCK);
_free_dbg(memory, _NORMAL_BLOCK);
#else
::free(memory);
#endif
+13 -13
View File
@@ -1,20 +1,20 @@
/*
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2013 Jonas Thedering
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2013 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.
*/
#pragma once
+13 -13
View File
@@ -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.
*/
#pragma once
+78 -78
View File
@@ -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"
@@ -40,13 +40,13 @@ wstring RegistryHelper::readValue(wstring key, wstring valuename)
DWORD type;
DWORD bufSize;
status = RegQueryValueExW(keyHandle, valuename.c_str(), NULL, &type, NULL, &bufSize);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
{
RegCloseKey(keyHandle);
throw RegistryException(L"Error while reading registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
if(type != REG_SZ)
if (type != REG_SZ)
{
RegCloseKey(keyHandle);
throw RegistryException(L"Registry value " + key + L"\\" + valuename + L" has wrong type");
@@ -57,14 +57,14 @@ wstring RegistryHelper::readValue(wstring key, wstring valuename)
RegCloseKey(keyHandle);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
{
delete buf;
throw RegistryException(L"Error while reading registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
//Remove zero-termination
if(buf[bufSize / sizeof(wchar_t) - 1] == L'\0')
// Remove zero-termination
if (buf[bufSize / sizeof(wchar_t) - 1] == L'\0')
bufSize -= sizeof(wchar_t);
result = wstring((wchar_t*)buf, (wstring::size_type)bufSize / sizeof(wchar_t));
delete buf;
@@ -82,13 +82,13 @@ unsigned long RegistryHelper::readDWORDValue(wstring key, wstring valuename)
DWORD type;
DWORD bufSize;
status = RegQueryValueExW(keyHandle, valuename.c_str(), NULL, &type, NULL, &bufSize);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
{
RegCloseKey(keyHandle);
throw RegistryException(L"Error while reading registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
if(type != REG_DWORD)
if (type != REG_DWORD)
{
RegCloseKey(keyHandle);
throw RegistryException(L"Registry value " + key + L"\\" + valuename + L" has wrong type");
@@ -99,7 +99,7 @@ unsigned long RegistryHelper::readDWORDValue(wstring key, wstring valuename)
RegCloseKey(keyHandle);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
{
delete buf;
throw RegistryException(L"Error while reading registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
@@ -121,13 +121,13 @@ vector<wstring> RegistryHelper::readMultiValue(wstring key, wstring valuename)
DWORD type;
DWORD bufSize;
status = RegQueryValueExW(keyHandle, valuename.c_str(), NULL, &type, NULL, &bufSize);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
{
RegCloseKey(keyHandle);
throw RegistryException(L"Error while reading registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
if(type != REG_MULTI_SZ)
if (type != REG_MULTI_SZ)
{
RegCloseKey(keyHandle);
throw RegistryException(L"Registry value " + key + L"\\" + valuename + L" has wrong type");
@@ -138,28 +138,28 @@ vector<wstring> RegistryHelper::readMultiValue(wstring key, wstring valuename)
RegCloseKey(keyHandle);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
{
delete buf;
throw RegistryException(L"Error while reading registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
size_t length = bufSize / sizeof(wchar_t);
//Remove zero-termination
while(length > 0 && buf[length - 1] == L'\0')
// Remove zero-termination
while (length > 0 && buf[length - 1] == L'\0')
length--;
size_t start = 0;
for(size_t i = 0; i < length; i++)
for (size_t i = 0; i < length; i++)
{
if(buf[i] == L'\0')
if (buf[i] == L'\0')
{
result.push_back(wstring(buf + start, i - start));
start = i + 1;
}
}
if(length > start)
if (length > start)
result.push_back(wstring(buf + start, length - start));
delete buf;
@@ -175,13 +175,13 @@ vector<unsigned char> RegistryHelper::readBinaryValue(wstring key, wstring value
DWORD type;
DWORD bufSize;
status = RegQueryValueExW(keyHandle, valuename.c_str(), NULL, &type, NULL, &bufSize);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
{
RegCloseKey(keyHandle);
throw RegistryException(L"Error while reading registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
if(type != REG_BINARY)
if (type != REG_BINARY)
{
RegCloseKey(keyHandle);
throw RegistryException(L"Registry value " + key + L"\\" + valuename + L" has wrong type");
@@ -192,7 +192,7 @@ vector<unsigned char> RegistryHelper::readBinaryValue(wstring key, wstring value
RegCloseKey(keyHandle);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
{
throw RegistryException(L"Error while reading registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
@@ -208,7 +208,7 @@ void RegistryHelper::writeValue(wstring key, wstring valuename, wstring value)
RegCloseKey(keyHandle);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
throw RegistryException(L"Error while writing to registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
@@ -229,7 +229,7 @@ void RegistryHelper::writeMultiValue(wstring key, wstring valuename, wstring val
HKEY keyHandle = openKey(key, KEY_SET_VALUE | KEY_WOW64_64KEY);
wchar_t* data = new wchar_t[value.size() + 2];
value._Copy_s(data, (value.size() + 2)*sizeof(wchar_t), value.size());
value._Copy_s(data, (value.size() + 2) * sizeof(wchar_t), value.size());
data[value.size()] = L'\0';
data[value.size() + 1] = L'\0';
@@ -239,7 +239,7 @@ void RegistryHelper::writeMultiValue(wstring key, wstring valuename, wstring val
RegCloseKey(keyHandle);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
throw RegistryException(L"Error while writing to registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
@@ -248,12 +248,12 @@ void RegistryHelper::writeMultiValue(wstring key, wstring valuename, vector<wstr
HKEY keyHandle = openKey(key, KEY_SET_VALUE | KEY_WOW64_64KEY);
size_t size = 1;
for(wstring value : values)
for (wstring value : values)
size += value.size() + 1;
wchar_t* data = new wchar_t[size];
size_t offset = 0;
for(wstring value : values)
for (wstring value : values)
{
value._Copy_s(data + offset, size * sizeof(wchar_t), value.size());
offset += value.size();
@@ -267,7 +267,7 @@ void RegistryHelper::writeMultiValue(wstring key, wstring valuename, vector<wstr
RegCloseKey(keyHandle);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
throw RegistryException(L"Error while writing to registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
@@ -279,7 +279,7 @@ void RegistryHelper::deleteValue(wstring key, wstring valuename)
RegCloseKey(keyHandle);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
throw RegistryException(L"Error while deleting registry value " + key + L"\\" + valuename + L": " + StringHelper::getSystemErrorString(status));
}
@@ -290,7 +290,7 @@ void RegistryHelper::createKey(wstring key)
HKEY keyHandle;
LSTATUS status = RegCreateKeyExW(rootKey, subKey.c_str(), 0, NULL, 0, KEY_SET_VALUE | KEY_WOW64_64KEY, NULL, &keyHandle, NULL);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
throw RegistryException(L"Error while creating registry key " + key + L": " + StringHelper::getSystemErrorString(status));
RegCloseKey(keyHandle);
@@ -302,7 +302,7 @@ void RegistryHelper::deleteKey(wstring key)
wstring subKey = splitKey(key, &rootKey);
LSTATUS status = RegDeleteKeyExW(rootKey, subKey.c_str(), KEY_WOW64_64KEY, 0);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
throw RegistryException(L"Error while deleting registry key " + key + L": " + StringHelper::getSystemErrorString(status));
}
@@ -315,18 +315,18 @@ void RegistryHelper::makeWritable(wstring key)
PSECURITY_DESCRIPTOR oldSd = (PSECURITY_DESCRIPTOR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, descriptorSize);
LSTATUS status = RegGetKeySecurity(keyHandle, DACL_SECURITY_INFORMATION, oldSd, &descriptorSize);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
throw RegistryException(L"Error while getting security information for registry key " + key + L": " + StringHelper::getSystemErrorString(status));
BOOL aclPresent, aclDefaulted;
PACL oldAcl = NULL;
if(!GetSecurityDescriptorDacl(oldSd, &aclPresent, &oldAcl, &aclDefaulted))
if (!GetSecurityDescriptorDacl(oldSd, &aclPresent, &oldAcl, &aclDefaulted))
throw RegistryException(L"Error in GetSecurityDescriptorDacl while ensuring writability");
PSID sid = NULL;
SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY;
if(!AllocateAndInitializeSid(&authority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0, &sid))
if (!AllocateAndInitializeSid(&authority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0, &sid))
throw RegistryException(L"Error in AllocateAndInitializeSid while ensuring writability");
EXPLICIT_ACCESS ea;
@@ -338,21 +338,21 @@ void RegistryHelper::makeWritable(wstring key)
ea.Trustee.ptstrName = (LPWSTR)sid;
PACL acl = NULL;
if(ERROR_SUCCESS != SetEntriesInAcl(1, &ea, oldAcl, &acl))
if (ERROR_SUCCESS != SetEntriesInAcl(1, &ea, oldAcl, &acl))
throw RegistryException(L"Error in SetEntriesInAcl while ensuring writability");
PSECURITY_DESCRIPTOR sd = (PSECURITY_DESCRIPTOR)LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
if(NULL == sd)
if (NULL == sd)
throw RegistryException(L"Error in LocalAlloc while ensuring writability");
if(!InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION))
if (!InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION))
throw RegistryException(L"Error in InitializeSecurityDescriptor while ensuring writability");
if(!SetSecurityDescriptorDacl(sd, TRUE, acl, FALSE))
if (!SetSecurityDescriptorDacl(sd, TRUE, acl, FALSE))
throw RegistryException(L"Error in SetSecurityDescriptorDacl while ensuring writability");
status = RegSetKeySecurity(keyHandle, DACL_SECURITY_INFORMATION, sd);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
throw RegistryException(L"Error while setting security information for registry key " + key + L": " + StringHelper::getSystemErrorString(status));
FreeSid(sid);
@@ -364,11 +364,11 @@ void RegistryHelper::makeWritable(wstring key)
void RegistryHelper::takeOwnership(wstring key)
{
HANDLE tokenHandle;
if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &tokenHandle))
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &tokenHandle))
throw RegistryException(L"Error in OpenProcessToken while taking ownership");
LUID luid;
if(!LookupPrivilegeValue(NULL, SE_TAKE_OWNERSHIP_NAME, &luid))
if (!LookupPrivilegeValue(NULL, SE_TAKE_OWNERSHIP_NAME, &luid))
throw RegistryException(L"Error in LookupPrivilegeValue while taking ownership");
TOKEN_PRIVILEGES tp;
@@ -376,34 +376,34 @@ void RegistryHelper::takeOwnership(wstring key)
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))
throw RegistryException(L"Error in AdjustTokenPrivileges while taking ownership");
HKEY keyHandle = openKey(key, WRITE_OWNER | KEY_WOW64_64KEY);
PSECURITY_DESCRIPTOR sd = (PSECURITY_DESCRIPTOR)LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
if(NULL == sd)
if (NULL == sd)
throw RegistryException(L"Error in SetPrivilege while taking ownership");
if(!InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION))
if (!InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION))
throw RegistryException(L"Error in InitializeSecurityDescriptor while taking ownership");
PSID sid = NULL;
SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY;
if(!AllocateAndInitializeSid(&authority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0, &sid))
if (!AllocateAndInitializeSid(&authority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0, &sid))
throw RegistryException(L"Error in AllocateAndInitializeSid while taking ownership");
if(!SetSecurityDescriptorOwner(sd, sid, FALSE))
if (!SetSecurityDescriptorOwner(sd, sid, FALSE))
throw RegistryException(L"Error in SetSecurityDescriptorOwner while taking ownership");
LSTATUS status = RegSetKeySecurity(keyHandle, OWNER_SECURITY_INFORMATION, sd);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
throw RegistryException(L"Error while setting security information for registry key " + key + L": " + StringHelper::getSystemErrorString(status));
tp.Privileges[0].Attributes = 0;
if(!AdjustTokenPrivileges(tokenHandle, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL))
if (!AdjustTokenPrivileges(tokenHandle, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL))
throw RegistryException(L"Error in AdjustTokenPrivileges while taking ownership");
FreeSid(sid);
@@ -420,7 +420,7 @@ bool RegistryHelper::keyExists(wstring key)
HKEY keyHandle;
result = (RegOpenKeyExW(rootKey, subKey.c_str(), 0, KEY_QUERY_VALUE | KEY_WOW64_64KEY, &keyHandle) == ERROR_SUCCESS);
if(result)
if (result)
RegCloseKey(keyHandle);
return result;
@@ -448,7 +448,7 @@ vector<wstring> RegistryHelper::enumSubKeys(wstring key)
int i = 0;
LSTATUS status;
while((status = RegEnumKeyExW(keyHandle, i++, keyName, &keyLength, NULL, NULL, NULL, NULL)) == ERROR_SUCCESS)
while ((status = RegEnumKeyExW(keyHandle, i++, keyName, &keyLength, NULL, NULL, NULL, NULL)) == ERROR_SUCCESS)
{
keyLength = sizeof(keyName) / sizeof(wchar_t);
@@ -457,7 +457,7 @@ vector<wstring> RegistryHelper::enumSubKeys(wstring key)
RegCloseKey(keyHandle);
if(status != ERROR_NO_MORE_ITEMS)
if (status != ERROR_NO_MORE_ITEMS)
throw RegistryException(L"Error while enumerating sub keys of registry key " + key + L": " + StringHelper::getSystemErrorString(status));
return result;
@@ -473,7 +473,7 @@ bool RegistryHelper::keyEmpty(wstring key)
RegCloseKey(keyHandle);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
throw RegistryException(L"Error while reading info for registry key " + key + L": " + StringHelper::getSystemErrorString(status));
return keyCount == 0 && valueCount == 0;
@@ -482,12 +482,12 @@ bool RegistryHelper::keyEmpty(wstring key)
void RegistryHelper::saveToFile(wstring key, vector<wstring> valuenames, wstring filepath)
{
wofstream stream(filepath);
if(!stream.good())
if (!stream.good())
throw RegistryException(L"Error while opening file " + filepath + L" for writing");
stream << L"Windows Registry Editor Version 5.00\n" << endl;
stream << L"[HKEY_LOCAL_MACHINE\\" << key << L"]" << endl;
for(vector<wstring>::iterator it = valuenames.begin(); it != valuenames.end(); it++)
for (vector<wstring>::iterator it = valuenames.begin(); it != valuenames.end(); it++)
{
wstring& valuename = *it;
wstring value = readValue(key, valuename);
@@ -502,7 +502,7 @@ void RegistryHelper::saveToFile(wstring key, vector<wstring> valuenames, wstring
wstring RegistryHelper::getGuidString(GUID guid)
{
wchar_t* temp;
if(FAILED(StringFromCLSID(guid, &temp)))
if (FAILED(StringFromCLSID(guid, &temp)))
throw RegistryException(L"Could not convert GUID to string");
std::wstring result(temp);
CoTaskMemFree(temp);
@@ -512,18 +512,18 @@ wstring RegistryHelper::getGuidString(GUID guid)
bool RegistryHelper::isWindowsVersionAtLeast(unsigned major, unsigned minor)
{
if(windowsVersion == 0)
if (windowsVersion == 0)
{
DWORD handle;
DWORD size = GetFileVersionInfoSizeW(L"kernel32.dll", &handle);
if(size != 0)
if (size != 0)
{
void* data = malloc(size);
if(GetFileVersionInfo(L"kernel32.dll", handle, size, data))
if (GetFileVersionInfo(L"kernel32.dll", handle, size, data))
{
VS_FIXEDFILEINFO* info;
UINT len;
if(VerQueryValueW(data, L"\\", (LPVOID*)&info, &len))
if (VerQueryValueW(data, L"\\", (LPVOID*)&info, &len))
windowsVersion = info->dwProductVersionMS;
}
free(data);
@@ -543,7 +543,7 @@ HKEY RegistryHelper::openKey(const wstring& key, REGSAM samDesired)
HKEY keyHandle;
LSTATUS status = RegOpenKeyExW(rootKey, subKey.c_str(), 0, samDesired, &keyHandle);
if(status != ERROR_SUCCESS)
if (status != ERROR_SUCCESS)
throw RegistryException(L"Error while opening registry key " + key + L": " + StringHelper::getSystemErrorString(status));
return keyHandle;
@@ -552,22 +552,22 @@ HKEY RegistryHelper::openKey(const wstring& key, REGSAM samDesired)
wstring RegistryHelper::splitKey(const wstring& key, HKEY* rootKey)
{
size_t pos = key.find(L'\\');
if(pos == wstring::npos)
if (pos == wstring::npos)
throw RegistryException(L"Key " + key + L" has invalid format");
wstring rootPart = key.substr(0, pos);
wstring pathPart = key.substr(pos + 1);
wstring p = StringHelper::toUpperCase(rootPart);
if(p == L"HKEY_CLASSES_ROOT")
if (p == L"HKEY_CLASSES_ROOT")
*rootKey = HKEY_CLASSES_ROOT;
else if(p == L"HKEY_CURRENT_CONFIG")
else if (p == L"HKEY_CURRENT_CONFIG")
*rootKey = HKEY_CURRENT_CONFIG;
else if(p == L"HKEY_CURRENT_USER")
else if (p == L"HKEY_CURRENT_USER")
*rootKey = HKEY_CURRENT_USER;
else if(p == L"HKEY_LOCAL_MACHINE")
else if (p == L"HKEY_LOCAL_MACHINE")
*rootKey = HKEY_LOCAL_MACHINE;
else if(p == L"HKEY_USERS")
else if (p == L"HKEY_USERS")
*rootKey = HKEY_USERS;
else
throw RegistryException(L"Unknown root key " + rootPart);
+17 -16
View File
@@ -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.
*/
#pragma once
@@ -26,9 +26,9 @@
#include <windows.h>
// {EACD2258-FCAC-4FF4-B36D-419E924A6D79}
const GUID EQUALIZERAPO_PRE_MIX_GUID = { 0xeacd2258, 0xfcac, 0x4ff4, { 0xb3, 0x6d, 0x41, 0x9e, 0x92, 0x4a, 0x6d, 0x79 } };
const GUID EQUALIZERAPO_PRE_MIX_GUID = {0xeacd2258, 0xfcac, 0x4ff4, {0xb3, 0x6d, 0x41, 0x9e, 0x92, 0x4a, 0x6d, 0x79}};
// {EC1CC9CE-FAED-4822-828A-82A81A6F018F}
const GUID EQUALIZERAPO_POST_MIX_GUID = { 0xec1cc9ce, 0xfaed, 0x4822, { 0x82, 0x8a, 0x82, 0xa8, 0x1a, 0x6f, 0x01, 0x8f } };
const GUID EQUALIZERAPO_POST_MIX_GUID = {0xec1cc9ce, 0xfaed, 0x4822, {0x82, 0x8a, 0x82, 0xa8, 0x1a, 0x6f, 0x01, 0x8f}};
#define APP_REGPATH L"HKEY_LOCAL_MACHINE\\SOFTWARE\\EqualizerAPO"
#define USER_REGPATH L"HKEY_CURRENT_USER\\SOFTWARE\\EqualizerAPO"
@@ -67,7 +67,8 @@ private:
class RegistryException
{
public:
RegistryException(const std::wstring& message):message(message) {}
RegistryException(const std::wstring& message)
: message(message) {}
std::wstring getMessage()
{
+29 -29
View File
@@ -1,20 +1,20 @@
/*
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2013 Jonas Thedering
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2013 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"
@@ -31,10 +31,10 @@ wstring StringHelper::replaceCharacters(const wstring& s, const wstring& chars,
wstring result;
result.reserve(s.length());
for(unsigned i=0; i<s.length(); i++)
for (unsigned i = 0; i < s.length(); i++)
{
wchar_t c = s[i];
if(chars.find(c) == -1)
if (chars.find(c) == -1)
result += c;
else
result += replacement;
@@ -68,7 +68,7 @@ wstring StringHelper::toLowerCase(const wstring& s)
wstring result = charBuf;
delete charBuf;
if(err == 0)
if (err == 0)
return result;
else
return s;
@@ -83,7 +83,7 @@ wstring StringHelper::toUpperCase(const wstring& s)
wstring result = charBuf;
delete charBuf;
if(err == 0)
if (err == 0)
return result;
else
return s;
@@ -94,21 +94,21 @@ wstring StringHelper::trim(const wstring& s)
int firstNonSpace = -1;
int lastNonSpace = -1;
for(unsigned i=0;i<s.length();i++)
for (unsigned i = 0; i < s.length(); i++)
{
wchar_t c = s[i];
if(!iswspace(c))
if (!iswspace(c))
{
if(firstNonSpace == -1)
if (firstNonSpace == -1)
firstNonSpace = i;
lastNonSpace = i;
}
}
if(firstNonSpace == -1)
if (firstNonSpace == -1)
return L"";
else
return s.substr(firstNonSpace, lastNonSpace-firstNonSpace+1);
return s.substr(firstNonSpace, lastNonSpace - firstNonSpace + 1);
}
vector<wstring> StringHelper::split(const wstring& s, wchar_t splitChar, bool skipEmpty)
@@ -116,16 +116,16 @@ vector<wstring> StringHelper::split(const wstring& s, wchar_t splitChar, bool sk
vector<wstring> result;
size_t prevPos = 0;
size_t pos = 0;
while((pos = s.find(splitChar, pos)) != wstring::npos)
while ((pos = s.find(splitChar, pos)) != wstring::npos)
{
wstring part = s.substr(prevPos, pos-prevPos);
if(part.length() > 0 || !skipEmpty)
wstring part = s.substr(prevPos, pos - prevPos);
if (part.length() > 0 || !skipEmpty)
result.push_back(part);
prevPos = ++pos;
}
wstring part = s.substr(prevPos);
if(part.length() > 0 || !skipEmpty)
if (part.length() > 0 || !skipEmpty)
result.push_back(part);
return result;
@@ -137,9 +137,9 @@ wstring StringHelper::join(const vector<wstring>& strings, const wstring& separa
bool first = true;
for(vector<wstring>::const_iterator it = strings.cbegin(); it != strings.cend(); it++)
for (vector<wstring>::const_iterator it = strings.cbegin(); it != strings.cend(); it++)
{
if(first)
if (first)
first = false;
else
stream << separator;
@@ -153,7 +153,7 @@ wstring StringHelper::getSystemErrorString(long status)
{
wchar_t* buf;
if(FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, (LPTSTR)&buf, 0, NULL) != 0)
if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, status, 0, (LPTSTR)&buf, 0, NULL) != 0)
{
wstring result(buf);
LocalFree(buf);
+13 -13
View File
@@ -1,20 +1,20 @@
/*
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2013 Jonas Thedering
This file is part of EqualizerAPO, a system-wide equalizer.
Copyright (C) 2013 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.
*/
#pragma once