Removed string resources from the settings.cpp file

This commit is contained in:
Alekhya Kommuru
2020-01-17 11:25:42 -08:00
parent 44ac22c0de
commit a504a75166
3 changed files with 43 additions and 136 deletions

View File

@@ -3,21 +3,21 @@
#include <commctrl.h>
#include "Settings.h"
#include "PowerRenameInterfaces.h"
#include "resource.h"
#include <common.h>
const wchar_t* c_rootRegPath = GET_RESOURCE_STRING(IDS_ROOT_PATH).c_str();
const wchar_t* c_mruSearchRegPath = GET_RESOURCE_STRING(IDS_SEARCH_PATH).c_str();
const wchar_t* c_mruReplaceRegPath = GET_RESOURCE_STRING(IDS_REPLACE_PATH).c_str();
const wchar_t* c_enabled = GET_RESOURCE_STRING(IDS_ENABLED).c_str();
const wchar_t* c_showIconOnMenu = GET_RESOURCE_STRING(IDS_SHOW_ICON).c_str();
const wchar_t* c_extendedContextMenuOnly = GET_RESOURCE_STRING(IDS_CONTEXT_MENU).c_str();
const wchar_t* c_persistState = GET_RESOURCE_STRING(IDS_PERSIST_STATE).c_str();
const wchar_t* c_maxMRUSize = GET_RESOURCE_STRING(IDS_MAX_MRU_SIZE).c_str();
const wchar_t* c_flags = GET_RESOURCE_STRING(IDS_FLAGS).c_str();
const wchar_t* c_searchText = GET_RESOURCE_STRING(IDS_SEARCH_TEXT).c_str();
const wchar_t* c_replaceText = GET_RESOURCE_STRING(IDS_REPLACE_TEXT).c_str();
const wchar_t* c_mruEnabled = GET_RESOURCE_STRING(IDS_MRU_ENABLED).c_str();
// Note: Not moving these strings to the resource file as these are internal and used as IDs
const wchar_t c_rootRegPath[] = L"Software\\Microsoft\\PowerRename";
const wchar_t c_mruSearchRegPath[] = L"SearchMRU";
const wchar_t c_mruReplaceRegPath[] = L"ReplaceMRU";
const wchar_t c_enabled[] = L"Enabled";
const wchar_t c_showIconOnMenu[] = L"ShowIcon";
const wchar_t c_extendedContextMenuOnly[] = L"ExtendedContextMenuOnly";
const wchar_t c_persistState[] = L"PersistState";
const wchar_t c_maxMRUSize[] = L"MaxMRUSize";
const wchar_t c_flags[] = L"Flags";
const wchar_t c_searchText[] = L"SearchText";
const wchar_t c_replaceText[] = L"ReplaceText";
const wchar_t c_mruEnabled[] = L"MRUEnabled";
const bool c_enabledDefault = true;
const bool c_showIconOnMenuDefault = true;
@@ -167,15 +167,15 @@ bool CSettings::GetRegStringValue(_In_ PCWSTR valueName, __out_ecount(cchBuf) PW
return (SUCCEEDED(HRESULT_FROM_WIN32(SHGetValue(HKEY_CURRENT_USER, c_rootRegPath, valueName, &type, value, &cb) == ERROR_SUCCESS)));
}
typedef int(CALLBACK* MRUCMPPROC)(LPCWSTR, LPCWSTR);
typedef int (CALLBACK* MRUCMPPROC)(LPCWSTR, LPCWSTR);
typedef struct {
DWORD cbSize;
UINT uMax;
UINT fFlags;
HKEY hKey;
LPCTSTR lpszSubKey;
typedef struct
{
DWORD cbSize;
UINT uMax;
UINT fFlags;
HKEY hKey;
LPCTSTR lpszSubKey;
MRUCMPPROC lpfnCompare;
} MRUINFO;
@@ -190,15 +190,21 @@ class CRenameMRU :
{
public:
// IUnknown
IFACEMETHODIMP_(ULONG) AddRef();
IFACEMETHODIMP_(ULONG) Release();
IFACEMETHODIMP_(ULONG)
AddRef();
IFACEMETHODIMP_(ULONG)
Release();
IFACEMETHODIMP QueryInterface(_In_ REFIID riid, _Outptr_ void** ppv);
// IEnumString
IFACEMETHODIMP Next(__in ULONG celt, __out_ecount_part(celt, *pceltFetched) LPOLESTR* rgelt, __out_opt ULONG* pceltFetched);
IFACEMETHODIMP Skip(__in ULONG) { return E_NOTIMPL; }
IFACEMETHODIMP Reset();
IFACEMETHODIMP Clone(__deref_out IEnumString** ppenum) { *ppenum = nullptr; return E_NOTIMPL; }
IFACEMETHODIMP Clone(__deref_out IEnumString** ppenum)
{
*ppenum = nullptr;
return E_NOTIMPL;
}
// IPowerRenameMRU
IFACEMETHODIMP AddMRUString(_In_ PCWSTR entry);
@@ -215,19 +221,20 @@ private:
int _EnumMRUList(_In_ int nItem, _Out_ void* lpData, _In_ UINT uLen);
void _FreeMRUList();
long m_refCount = 0;
HKEY m_hKey = NULL;
ULONG m_maxMRUSize = 0;
ULONG m_mruIndex = 0;
ULONG m_mruSize = 0;
long m_refCount = 0;
HKEY m_hKey = NULL;
ULONG m_maxMRUSize = 0;
ULONG m_mruIndex = 0;
ULONG m_mruSize = 0;
HANDLE m_mruHandle = NULL;
HMODULE m_hComctl32Dll = NULL;
PWSTR m_regPath = nullptr;
PWSTR m_regPath = nullptr;
};
CRenameMRU::CRenameMRU() :
m_refCount(1)
{}
{
}
CRenameMRU::~CRenameMRU()
{
@@ -270,12 +277,14 @@ HRESULT CRenameMRU::CreateInstance(_In_ PCWSTR regPathMRU, _In_ ULONG maxMRUSize
}
// IUnknown
IFACEMETHODIMP_(ULONG) CRenameMRU::AddRef()
IFACEMETHODIMP_(ULONG)
CRenameMRU::AddRef()
{
return InterlockedIncrement(&m_refCount);
}
IFACEMETHODIMP_(ULONG) CRenameMRU::Release()
IFACEMETHODIMP_(ULONG)
CRenameMRU::Release()
{
long refCount = InterlockedDecrement(&m_refCount);
@@ -466,7 +475,6 @@ void CRenameMRU::_FreeMRUList()
{
pfnFreeMRUList(m_mruHandle);
}
}
m_mruHandle = NULL;
}