diff --git a/Configurator/DeviceAPOInfo.cpp b/Configurator/DeviceAPOInfo.cpp index 5809ec4..97588a8 100644 --- a/Configurator/DeviceAPOInfo.cpp +++ b/Configurator/DeviceAPOInfo.cpp @@ -68,7 +68,8 @@ void DeviceAPOInfo::install() RegistryHelper::writeValue(APP_REGPATH L"\\Child APOs", deviceGuid, originalApoGuid); - RegistryHelper::saveToFile(renderKeyPath L"\\" + deviceGuid + L"\\FxProperties", apoGuidValueName, L"backup_" + deviceName + L"_" + connectionName + L".reg"); + RegistryHelper::saveToFile(renderKeyPath L"\\" + deviceGuid + L"\\FxProperties", apoGuidValueName, + L"backup_" + RegistryHelper::replaceIllegalCharacters(deviceName) + L"_" + RegistryHelper::replaceIllegalCharacters(connectionName) + L".reg"); RegistryHelper::writeValue(renderKeyPath L"\\" + deviceGuid + L"\\FxProperties", apoGuidValueName, RegistryHelper::getGuidString(__uuidof(EqualizerAPO))); } diff --git a/RegistryHelper.cpp b/RegistryHelper.cpp index 14df2f8..eebe9cf 100644 --- a/RegistryHelper.cpp +++ b/RegistryHelper.cpp @@ -18,6 +18,7 @@ */ #include +#include #define WIN32_LEAN_AND_MEAN #include #include @@ -211,6 +212,34 @@ wstring RegistryHelper::getGuidString(GUID guid) return result; } +wstring RegistryHelper::replaceIllegalCharacters(wstring filename) +{ + wstringstream stream; + + for(unsigned i=0; i': + case L':': + case L'"': + case L'/': + case L'\\': + case L'|': + case L'?': + case L'*': + stream.put(L'_'); + break; + default: + stream.put(c); + } + } + + return stream.str(); +} + wstring RegistryHelper::getSystemErrorString(long status) { wchar_t* buf; diff --git a/RegistryHelper.h b/RegistryHelper.h index 64f2094..ca7ae57 100644 --- a/RegistryHelper.h +++ b/RegistryHelper.h @@ -38,6 +38,7 @@ public: static unsigned long valueCount(std::wstring key); static void saveToFile(std::wstring key, std::wstring valuename, std::wstring filepath); static std::wstring getGuidString(GUID guid); + static std::wstring replaceIllegalCharacters(std::wstring filename); private: static std::wstring getSystemErrorString(long status);