From e69b5e312cce5cc67a3cc971a61b20bd2a7ae1f4 Mon Sep 17 00:00:00 2001 From: narzoul Date: Sat, 4 Aug 2018 13:08:30 +0200 Subject: [PATCH] Moved common macros to compiler options --- DDrawCompat/Common/CompatQueryInterface.h | 2 - DDrawCompat/Common/Log.cpp | 22 ++++---- DDrawCompat/Common/Log.h | 4 +- DDrawCompat/Common/VtableVisitor.h | 2 - DDrawCompat/D3dDdi/AdapterCallbacks.h | 2 - DDrawCompat/D3dDdi/AdapterFuncs.h | 2 - DDrawCompat/D3dDdi/Device.h | 2 - DDrawCompat/D3dDdi/DeviceCallbacks.h | 2 - DDrawCompat/D3dDdi/DeviceFuncs.h | 2 - DDrawCompat/D3dDdi/Hooks.cpp | 2 - DDrawCompat/D3dDdi/KernelModeThunks.cpp | 2 - DDrawCompat/D3dDdi/KernelModeThunks.h | 3 -- DDrawCompat/D3dDdi/Log/AdapterFuncsLog.h | 2 - DDrawCompat/D3dDdi/Log/DeviceCallbacksLog.h | 2 - DDrawCompat/D3dDdi/Log/DeviceFuncsLog.h | 2 - DDrawCompat/D3dDdi/Log/KernelModeThunksLog.h | 2 - DDrawCompat/D3dDdi/OversizedResource.h | 2 - DDrawCompat/D3dDdi/RenderTargetResource.h | 2 - .../D3dDdi/Visitors/AdapterCallbacksVisitor.h | 2 - .../D3dDdi/Visitors/AdapterFuncsVisitor.h | 2 - .../D3dDdi/Visitors/DeviceCallbacksVisitor.h | 2 - .../D3dDdi/Visitors/DeviceFuncsVisitor.h | 2 - DDrawCompat/DDraw/ActivateAppHandler.cpp | 2 - DDrawCompat/DDraw/DirectDraw.h | 2 - DDrawCompat/DDraw/Hooks.cpp | 2 - DDrawCompat/DDraw/RealPrimarySurface.h | 2 - DDrawCompat/DDraw/Repository.h | 2 - DDrawCompat/DDraw/Surfaces/PrimarySurface.cpp | 5 +- .../DDraw/Surfaces/PrimarySurfaceImpl.h | 2 - DDrawCompat/DDraw/Surfaces/Surface.h | 2 - DDrawCompat/DDraw/Surfaces/SurfaceImpl.h | 2 - DDrawCompat/DDraw/Types.h | 2 - DDrawCompat/DDrawCompat.vcxproj | 4 +- DDrawCompat/Direct3d/Hooks.cpp | 2 - DDrawCompat/Direct3d/Types.h | 2 - .../Visitors/Direct3dDeviceVtblVisitor.h | 2 - .../Visitors/Direct3dTextureVtblVisitor.h | 2 - .../Direct3dVertexBufferVtblVisitor.h | 2 - .../Visitors/Direct3dViewportVtblVisitor.h | 2 - .../Direct3d/Visitors/Direct3dVtblVisitor.h | 2 - DDrawCompat/Win32/Registry.cpp | 50 ++++++++++++------- 41 files changed, 46 insertions(+), 112 deletions(-) diff --git a/DDrawCompat/Common/CompatQueryInterface.h b/DDrawCompat/Common/CompatQueryInterface.h index a761d19..f10f0ec 100644 --- a/DDrawCompat/Common/CompatQueryInterface.h +++ b/DDrawCompat/Common/CompatQueryInterface.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/Common/Log.cpp b/DDrawCompat/Common/Log.cpp index 1439c19..81b5cd6 100644 --- a/DDrawCompat/Common/Log.cpp +++ b/DDrawCompat/Common/Log.cpp @@ -2,7 +2,6 @@ #include -#include #include #include "Common/Log.h" @@ -53,8 +52,7 @@ std::ostream& operator<<(std::ostream& os, const WCHAR* wstr) return os << static_cast(wstr); } - CStringA str(wstr); - return os << '"' << static_cast(str) << '"'; + return os << std::string(wstr, wstr + wcslen(wstr)).c_str(); } std::ostream& operator<<(std::ostream& os, const DEVMODEA& dm) @@ -143,13 +141,13 @@ std::ostream& operator<<(std::ostream& os, const DDSURFACEDESC2& sd) { return Compat::LogStruct(os) << Compat::hex(sd.dwFlags) - << sd.dwHeight - << sd.dwWidth - << sd.lPitch - << sd.dwBackBufferCount + << sd.dwHeight + << sd.dwWidth + << sd.lPitch + << sd.dwBackBufferCount << sd.dwMipMapCount - << sd.dwAlphaBitDepth - << sd.dwReserved + << sd.dwAlphaBitDepth + << sd.dwReserved << sd.lpSurface << sd.ddpfPixelFormat << sd.ddsCaps @@ -160,16 +158,16 @@ std::ostream& operator<<(std::ostream& os, const CWPSTRUCT& cwrp) { return Compat::LogStruct(os) << Compat::hex(cwrp.message) - << cwrp.hwnd + << cwrp.hwnd << Compat::hex(cwrp.wParam) << Compat::hex(cwrp.lParam); } std::ostream& operator<<(std::ostream& os, const CWPRETSTRUCT& cwrp) { - return Compat::LogStruct(os) + return Compat::LogStruct(os) << Compat::hex(cwrp.message) - << cwrp.hwnd + << cwrp.hwnd << Compat::hex(cwrp.wParam) << Compat::hex(cwrp.lParam) << Compat::hex(cwrp.lResult); diff --git a/DDrawCompat/Common/Log.h b/DDrawCompat/Common/Log.h index ac3260d..b4d1924 100644 --- a/DDrawCompat/Common/Log.h +++ b/DDrawCompat/Common/Log.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include #include @@ -186,7 +184,7 @@ namespace Compat class LogNull { public: - template LogNull& operator<<(const T&) { return *this; } + template LogNull& operator<<(const T&) { return *this; } }; typedef LogNull LogDebug; diff --git a/DDrawCompat/Common/VtableVisitor.h b/DDrawCompat/Common/VtableVisitor.h index f8f2df7..ef4906f 100644 --- a/DDrawCompat/Common/VtableVisitor.h +++ b/DDrawCompat/Common/VtableVisitor.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/AdapterCallbacks.h b/DDrawCompat/D3dDdi/AdapterCallbacks.h index a14d074..af9b885 100644 --- a/DDrawCompat/D3dDdi/AdapterCallbacks.h +++ b/DDrawCompat/D3dDdi/AdapterCallbacks.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/AdapterFuncs.h b/DDrawCompat/D3dDdi/AdapterFuncs.h index 0cd39cd..22bcf82 100644 --- a/DDrawCompat/D3dDdi/AdapterFuncs.h +++ b/DDrawCompat/D3dDdi/AdapterFuncs.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include #include diff --git a/DDrawCompat/D3dDdi/Device.h b/DDrawCompat/D3dDdi/Device.h index b9ff08b..df7a305 100644 --- a/DDrawCompat/D3dDdi/Device.h +++ b/DDrawCompat/D3dDdi/Device.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/DeviceCallbacks.h b/DDrawCompat/D3dDdi/DeviceCallbacks.h index 234e71e..494e964 100644 --- a/DDrawCompat/D3dDdi/DeviceCallbacks.h +++ b/DDrawCompat/D3dDdi/DeviceCallbacks.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/DeviceFuncs.h b/DDrawCompat/D3dDdi/DeviceFuncs.h index 63cf22c..b2e42f5 100644 --- a/DDrawCompat/D3dDdi/DeviceFuncs.h +++ b/DDrawCompat/D3dDdi/DeviceFuncs.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/Hooks.cpp b/DDrawCompat/D3dDdi/Hooks.cpp index 975b7b2..3e30bdc 100644 --- a/DDrawCompat/D3dDdi/Hooks.cpp +++ b/DDrawCompat/D3dDdi/Hooks.cpp @@ -1,5 +1,3 @@ -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/KernelModeThunks.cpp b/DDrawCompat/D3dDdi/KernelModeThunks.cpp index ad8e265..603e84a 100644 --- a/DDrawCompat/D3dDdi/KernelModeThunks.cpp +++ b/DDrawCompat/D3dDdi/KernelModeThunks.cpp @@ -1,5 +1,3 @@ -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/KernelModeThunks.h b/DDrawCompat/D3dDdi/KernelModeThunks.h index 4ca269d..d63d184 100644 --- a/DDrawCompat/D3dDdi/KernelModeThunks.h +++ b/DDrawCompat/D3dDdi/KernelModeThunks.h @@ -1,8 +1,5 @@ #pragma once -#define CINTERFACE -#define WIN32_LEAN_AND_MEAN - #include #include #include <../km/d3dkmthk.h> diff --git a/DDrawCompat/D3dDdi/Log/AdapterFuncsLog.h b/DDrawCompat/D3dDdi/Log/AdapterFuncsLog.h index de05b50..af7481b 100644 --- a/DDrawCompat/D3dDdi/Log/AdapterFuncsLog.h +++ b/DDrawCompat/D3dDdi/Log/AdapterFuncsLog.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/Log/DeviceCallbacksLog.h b/DDrawCompat/D3dDdi/Log/DeviceCallbacksLog.h index e307640..83d20c8 100644 --- a/DDrawCompat/D3dDdi/Log/DeviceCallbacksLog.h +++ b/DDrawCompat/D3dDdi/Log/DeviceCallbacksLog.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/Log/DeviceFuncsLog.h b/DDrawCompat/D3dDdi/Log/DeviceFuncsLog.h index 02292e9..e4fb17e 100644 --- a/DDrawCompat/D3dDdi/Log/DeviceFuncsLog.h +++ b/DDrawCompat/D3dDdi/Log/DeviceFuncsLog.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/Log/KernelModeThunksLog.h b/DDrawCompat/D3dDdi/Log/KernelModeThunksLog.h index 67a32ff..d80ae99 100644 --- a/DDrawCompat/D3dDdi/Log/KernelModeThunksLog.h +++ b/DDrawCompat/D3dDdi/Log/KernelModeThunksLog.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/OversizedResource.h b/DDrawCompat/D3dDdi/OversizedResource.h index bf7afc2..ea2e496 100644 --- a/DDrawCompat/D3dDdi/OversizedResource.h +++ b/DDrawCompat/D3dDdi/OversizedResource.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/RenderTargetResource.h b/DDrawCompat/D3dDdi/RenderTargetResource.h index 3be460b..7eee00b 100644 --- a/DDrawCompat/D3dDdi/RenderTargetResource.h +++ b/DDrawCompat/D3dDdi/RenderTargetResource.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/Visitors/AdapterCallbacksVisitor.h b/DDrawCompat/D3dDdi/Visitors/AdapterCallbacksVisitor.h index 5f13fd0..c4bda80 100644 --- a/DDrawCompat/D3dDdi/Visitors/AdapterCallbacksVisitor.h +++ b/DDrawCompat/D3dDdi/Visitors/AdapterCallbacksVisitor.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/Visitors/AdapterFuncsVisitor.h b/DDrawCompat/D3dDdi/Visitors/AdapterFuncsVisitor.h index 1548f8f..4136c5e 100644 --- a/DDrawCompat/D3dDdi/Visitors/AdapterFuncsVisitor.h +++ b/DDrawCompat/D3dDdi/Visitors/AdapterFuncsVisitor.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/Visitors/DeviceCallbacksVisitor.h b/DDrawCompat/D3dDdi/Visitors/DeviceCallbacksVisitor.h index a1c9467..65b1248 100644 --- a/DDrawCompat/D3dDdi/Visitors/DeviceCallbacksVisitor.h +++ b/DDrawCompat/D3dDdi/Visitors/DeviceCallbacksVisitor.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/D3dDdi/Visitors/DeviceFuncsVisitor.h b/DDrawCompat/D3dDdi/Visitors/DeviceFuncsVisitor.h index d4377c7..c2d9f8e 100644 --- a/DDrawCompat/D3dDdi/Visitors/DeviceFuncsVisitor.h +++ b/DDrawCompat/D3dDdi/Visitors/DeviceFuncsVisitor.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/DDraw/ActivateAppHandler.cpp b/DDrawCompat/DDraw/ActivateAppHandler.cpp index 7a1e9b4..83f7202 100644 --- a/DDrawCompat/DDraw/ActivateAppHandler.cpp +++ b/DDrawCompat/DDraw/ActivateAppHandler.cpp @@ -1,5 +1,3 @@ -#define CINTERFACE - #include #include "Common/Hook.h" diff --git a/DDrawCompat/DDraw/DirectDraw.h b/DDrawCompat/DDraw/DirectDraw.h index f1ad11b..9a7e232 100644 --- a/DDrawCompat/DDraw/DirectDraw.h +++ b/DDrawCompat/DDraw/DirectDraw.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include "Common/CompatPtr.h" diff --git a/DDrawCompat/DDraw/Hooks.cpp b/DDrawCompat/DDraw/Hooks.cpp index 4c1f250..3b9f873 100644 --- a/DDrawCompat/DDraw/Hooks.cpp +++ b/DDrawCompat/DDraw/Hooks.cpp @@ -1,5 +1,3 @@ -#define CINTERFACE - #include #include "Common/CompatPtr.h" diff --git a/DDrawCompat/DDraw/RealPrimarySurface.h b/DDrawCompat/DDraw/RealPrimarySurface.h index 798f0bf..0e67826 100644 --- a/DDrawCompat/DDraw/RealPrimarySurface.h +++ b/DDrawCompat/DDraw/RealPrimarySurface.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include "Common/CompatWeakPtr.h" diff --git a/DDrawCompat/DDraw/Repository.h b/DDrawCompat/DDraw/Repository.h index 40198b0..80b792a 100644 --- a/DDrawCompat/DDraw/Repository.h +++ b/DDrawCompat/DDraw/Repository.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include "Common/CompatRef.h" diff --git a/DDrawCompat/DDraw/Surfaces/PrimarySurface.cpp b/DDrawCompat/DDraw/Surfaces/PrimarySurface.cpp index 26fa8dc..c796e02 100644 --- a/DDrawCompat/DDraw/Surfaces/PrimarySurface.cpp +++ b/DDrawCompat/DDraw/Surfaces/PrimarySurface.cpp @@ -1,6 +1,3 @@ -#define CINTERFACE -#define _NO_DDRAWINT_NO_COM - #include #include "Common/CompatPtr.h" @@ -170,7 +167,7 @@ namespace DDraw { return CompatPtr::from(surface.get()); } - + if (FAILED(surface->GetAttachedSurface(surface, &caps, &surface.getRef()))) { return nullptr; diff --git a/DDrawCompat/DDraw/Surfaces/PrimarySurfaceImpl.h b/DDrawCompat/DDraw/Surfaces/PrimarySurfaceImpl.h index 9fe714c..a3e9be2 100644 --- a/DDrawCompat/DDraw/Surfaces/PrimarySurfaceImpl.h +++ b/DDrawCompat/DDraw/Surfaces/PrimarySurfaceImpl.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include "Common/CompatRef.h" diff --git a/DDrawCompat/DDraw/Surfaces/Surface.h b/DDrawCompat/DDraw/Surfaces/Surface.h index 5f940b2..67d60f6 100644 --- a/DDrawCompat/DDraw/Surfaces/Surface.h +++ b/DDrawCompat/DDraw/Surfaces/Surface.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/DDraw/Surfaces/SurfaceImpl.h b/DDrawCompat/DDraw/Surfaces/SurfaceImpl.h index 2b5b241..ef2e0d7 100644 --- a/DDrawCompat/DDraw/Surfaces/SurfaceImpl.h +++ b/DDrawCompat/DDraw/Surfaces/SurfaceImpl.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include diff --git a/DDrawCompat/DDraw/Types.h b/DDrawCompat/DDraw/Types.h index e83dde0..e50a740 100644 --- a/DDrawCompat/DDraw/Types.h +++ b/DDrawCompat/DDraw/Types.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include namespace DDraw diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index 90c69cb..cbbafc9 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -90,7 +90,7 @@ Level4 - PSAPI_VERSION=1;WIN32;_DEBUG;_WINDOWS;_USRDLL;DDRAWCOMPAT_EXPORTS;%(PreprocessorDefinitions) + CINTERFACE;_NO_DDRAWINT_NO_COM;PSAPI_VERSION=1;WIN32;_DEBUG;_WINDOWS;_USRDLL;DDRAWCOMPAT_EXPORTS;%(PreprocessorDefinitions) MultiThreadedDebug true false @@ -121,7 +121,7 @@ Level4 - PSAPI_VERSION=1;WIN32;NDEBUG;_WINDOWS;_USRDLL;DDRAWCOMPAT_EXPORTS;%(PreprocessorDefinitions) + CINTERFACE;_NO_DDRAWINT_NO_COM;PSAPI_VERSION=1;WIN32;NDEBUG;_WINDOWS;_USRDLL;DDRAWCOMPAT_EXPORTS;%(PreprocessorDefinitions) MultiThreaded true $(IntDir)%(RelativeDir) diff --git a/DDrawCompat/Direct3d/Hooks.cpp b/DDrawCompat/Direct3d/Hooks.cpp index 4359c4b..a7874d4 100644 --- a/DDrawCompat/Direct3d/Hooks.cpp +++ b/DDrawCompat/Direct3d/Hooks.cpp @@ -1,5 +1,3 @@ -#define CINTERFACE - #include #include diff --git a/DDrawCompat/Direct3d/Types.h b/DDrawCompat/Direct3d/Types.h index 988517a..3399c92 100644 --- a/DDrawCompat/Direct3d/Types.h +++ b/DDrawCompat/Direct3d/Types.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include namespace Direct3d diff --git a/DDrawCompat/Direct3d/Visitors/Direct3dDeviceVtblVisitor.h b/DDrawCompat/Direct3d/Visitors/Direct3dDeviceVtblVisitor.h index 2199ba0..19e18f8 100644 --- a/DDrawCompat/Direct3d/Visitors/Direct3dDeviceVtblVisitor.h +++ b/DDrawCompat/Direct3d/Visitors/Direct3dDeviceVtblVisitor.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include "Common/VtableVisitor.h" diff --git a/DDrawCompat/Direct3d/Visitors/Direct3dTextureVtblVisitor.h b/DDrawCompat/Direct3d/Visitors/Direct3dTextureVtblVisitor.h index 4418a91..48e4ccd 100644 --- a/DDrawCompat/Direct3d/Visitors/Direct3dTextureVtblVisitor.h +++ b/DDrawCompat/Direct3d/Visitors/Direct3dTextureVtblVisitor.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include "Common/VtableVisitor.h" diff --git a/DDrawCompat/Direct3d/Visitors/Direct3dVertexBufferVtblVisitor.h b/DDrawCompat/Direct3d/Visitors/Direct3dVertexBufferVtblVisitor.h index 8f72c2c..797526b 100644 --- a/DDrawCompat/Direct3d/Visitors/Direct3dVertexBufferVtblVisitor.h +++ b/DDrawCompat/Direct3d/Visitors/Direct3dVertexBufferVtblVisitor.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include "Common/VtableVisitor.h" diff --git a/DDrawCompat/Direct3d/Visitors/Direct3dViewportVtblVisitor.h b/DDrawCompat/Direct3d/Visitors/Direct3dViewportVtblVisitor.h index d752722..6d0b72c 100644 --- a/DDrawCompat/Direct3d/Visitors/Direct3dViewportVtblVisitor.h +++ b/DDrawCompat/Direct3d/Visitors/Direct3dViewportVtblVisitor.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include "Common/VtableVisitor.h" diff --git a/DDrawCompat/Direct3d/Visitors/Direct3dVtblVisitor.h b/DDrawCompat/Direct3d/Visitors/Direct3dVtblVisitor.h index 13f1952..1a501a8 100644 --- a/DDrawCompat/Direct3d/Visitors/Direct3dVtblVisitor.h +++ b/DDrawCompat/Direct3d/Visitors/Direct3dVtblVisitor.h @@ -1,7 +1,5 @@ #pragma once -#define CINTERFACE - #include #include "Common/VtableVisitor.h" diff --git a/DDrawCompat/Win32/Registry.cpp b/DDrawCompat/Win32/Registry.cpp index b16b9af..0d9ac73 100644 --- a/DDrawCompat/Win32/Registry.cpp +++ b/DDrawCompat/Win32/Registry.cpp @@ -2,45 +2,49 @@ #include #include #include - -#include +#include #include "Common/Hook.h" #include "Common/Log.h" #include "Win32/Registry.h" +typedef long NTSTATUS; + namespace { struct RegistryKey { HKEY key; - CStringW subKey; - CStringW value; + std::wstring subKey; + std::wstring value; - RegistryKey(HKEY key, CStringW subKey, CStringW value) : key(key), subKey(subKey), value(value) {} + RegistryKey(HKEY key, const std::wstring& subKey, const std::wstring& value) + : key(key), subKey(subKey), value(value) + { + } bool operator<(const RegistryKey& rhs) const { if (key < rhs.key) { return true; } if (key > rhs.key) { return false; } - const int subKeyComp = subKey.CompareNoCase(rhs.subKey); + const int subKeyComp = lstrcmpiW(subKey.c_str(), rhs.subKey.c_str()); if (subKeyComp < 0) { return true; } if (subKeyComp > 0) { return false; } - return value.CompareNoCase(rhs.value) < 0; + return lstrcmpiW(value.c_str(), rhs.value.c_str()); } bool operator==(const RegistryKey& rhs) const { return key == rhs.key && - 0 == subKey.CompareNoCase(rhs.subKey) && - 0 == value.CompareNoCase(rhs.value); + 0 == lstrcmpiW(subKey.c_str(), rhs.subKey.c_str()) && + 0 == lstrcmpiW(value.c_str(), rhs.value.c_str()); } }; std::map g_dwordValues; std::set g_unsetValues; - CStringW getKeyName(HKEY key) + std::wstring getKeyName(HKEY key) { enum KEY_INFORMATION_CLASS { @@ -77,11 +81,11 @@ namespace ULONG resultSize = 0; if (SUCCEEDED(ntQueryKey(key, KeyNameInformation, &keyName, sizeof(keyName), &resultSize))) { - return CStringW(keyName.Name, keyName.NameLength / 2); + return std::wstring(keyName.Name, keyName.NameLength / 2); } } - return CStringW(); + return std::wstring(); } LONG WINAPI regGetValueW(HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue, @@ -139,12 +143,14 @@ namespace if (hKey && lpValueName) { - const CStringW keyName = getKeyName(hKey); - const CStringW localMachinePrefix = "\\REGISTRY\\MACHINE\\"; - if (localMachinePrefix == keyName.Mid(0, localMachinePrefix.GetLength())) + const std::wstring keyName = getKeyName(hKey); + const std::wstring localMachinePrefix = L"\\REGISTRY\\MACHINE\\"; + if (localMachinePrefix == keyName.substr(0, localMachinePrefix.size())) { + std::wostringstream oss; + oss << lpValueName; auto it = g_unsetValues.find(RegistryKey(HKEY_LOCAL_MACHINE, - keyName.Mid(localMachinePrefix.GetLength()), lpValueName)); + keyName.substr(localMachinePrefix.size()), oss.str())); if (it != g_unsetValues.end()) { return ERROR_FILE_NOT_FOUND; @@ -174,13 +180,21 @@ namespace Win32 void setValue(HKEY key, const char* subKey, const char* valueName, DWORD value) { assert(key && subKey && valueName); - g_dwordValues[RegistryKey(key, subKey, valueName)] = value; + std::wostringstream subKeyW; + subKeyW << subKey; + std::wostringstream valueNameW; + valueNameW << valueName; + g_dwordValues[RegistryKey(key, subKeyW.str(), valueNameW.str())] = value; } void unsetValue(HKEY key, const char* subKey, const char* valueName) { assert(key && subKey && valueName); - g_unsetValues.insert(RegistryKey(key, subKey, valueName)); + std::wostringstream subKeyW; + subKeyW << subKey; + std::wostringstream valueNameW; + valueNameW << valueName; + g_unsetValues.insert(RegistryKey(key, subKeyW.str(), valueNameW.str())); } } }