Nikolay Sivov : ole32/comcat: Use wide string constants.

Alexandre Julliard julliard at winehq.org
Thu Sep 17 15:51:09 CDT 2020


Module: wine
Branch: master
Commit: b68b58e604ae84964999ff3546e672d68a5a8342
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b68b58e604ae84964999ff3546e672d68a5a8342

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu Sep 17 11:20:24 2020 +0300

ole32/comcat: Use wide string constants.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ole32/comcat.c | 51 +++++++++++++++------------------------------------
 1 file changed, 15 insertions(+), 36 deletions(-)

diff --git a/dlls/ole32/comcat.c b/dlls/ole32/comcat.c
index 467724c5ba..e258f8835b 100644
--- a/dlls/ole32/comcat.c
+++ b/dlls/ole32/comcat.c
@@ -67,14 +67,9 @@ static HRESULT CATIDEnumGUID_Construct(REFCLSID rclsid, LPCWSTR impl_req, IEnumC
 /**********************************************************************
  * File-scope string constants
  */
-static const WCHAR comcat_keyname[] = {
-    'C','o','m','p','o','n','e','n','t',' ','C','a','t','e','g','o','r','i','e','s',0 };
-static const WCHAR impl_keyname[] = {
-    'I','m','p','l','e','m','e','n','t','e','d',' ','C','a','t','e','g','o','r','i','e','s',0 };
-static const WCHAR req_keyname[] = {
-    'R','e','q','u','i','r','e','d',' ','C','a','t','e','g','o','r','i','e','s',0 };
-static const WCHAR clsid_keyname[] = { 'C','L','S','I','D',0 };
-
+static const WCHAR comcat_keyname[] = L"Component Categories";
+static const WCHAR impl_keyname[] = L"Implemented Categories";
+static const WCHAR req_keyname[] = L"Required Categories";
 
 /**********************************************************************
  * COMCAT_RegisterClassCategories
@@ -96,7 +91,7 @@ static HRESULT COMCAT_RegisterClassCategories(
     if (FAILED(res)) return res;
 
     /* Create (or open) the CLSID key. */
-    res = create_classes_key(HKEY_CLASSES_ROOT, clsid_keyname, KEY_READ|KEY_WRITE, &clsid_key);
+    res = create_classes_key(HKEY_CLASSES_ROOT, L"CLSID", KEY_READ|KEY_WRITE, &clsid_key);
     if (res != ERROR_SUCCESS) return E_FAIL;
 
     /* Create (or open) the class key. */
@@ -169,7 +164,6 @@ static HRESULT COMCAT_UnRegisterClassCategories(
 static HRESULT COMCAT_GetCategoryDesc(HKEY key, LCID lcid, PWCHAR pszDesc,
 				      ULONG buf_wchars)
 {
-    static const WCHAR fmt[] = { '%', 'l', 'X', 0 };
     WCHAR valname[5];
     HRESULT res;
     DWORD type, size = (buf_wchars - 1) * sizeof(WCHAR);
@@ -177,7 +171,7 @@ static HRESULT COMCAT_GetCategoryDesc(HKEY key, LCID lcid, PWCHAR pszDesc,
     if (pszDesc == NULL) return E_INVALIDARG;
 
     /* FIXME: lcid comparisons are more complex than this! */
-    wsprintfW(valname, fmt, lcid);
+    wsprintfW(valname, L"%lX", lcid);
     res = RegQueryValueExW(key, valname, 0, &type, (LPBYTE)pszDesc, &size);
     if (res != ERROR_SUCCESS || type != REG_SZ) {
 	FIXME("Simplified lcid comparison\n");
@@ -341,8 +335,8 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterCategories(
     res = create_classes_key(HKEY_CLASSES_ROOT, comcat_keyname, KEY_READ|KEY_WRITE, &comcat_key);
     if (res != ERROR_SUCCESS) return E_FAIL;
 
-    for (; cCategories; --cCategories, ++rgci) {
-	static const WCHAR fmt[] = { '%', 'l', 'X', 0 };
+    for (; cCategories; --cCategories, ++rgci)
+    {
 	WCHAR keyname[CHARS_IN_GUID];
 	WCHAR valname[9];
 	HKEY cat_key;
@@ -353,7 +347,7 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterCategories(
 	if (res != ERROR_SUCCESS) continue;
 
 	/* Set the value for this locale's description. */
-	wsprintfW(valname, fmt, rgci->lcid);
+	wsprintfW(valname, L"%lX", rgci->lcid);
         RegSetValueExW(cat_key, valname, 0, REG_SZ, (const BYTE*)rgci->szDescription,
 		       (lstrlenW(rgci->szDescription) + 1) * sizeof(WCHAR));
 
@@ -634,16 +628,12 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumImplCategoriesOfClass(
     REFCLSID rclsid,
     LPENUMCATID *ppenumCATID)
 {
-    static const WCHAR postfix[] = { '\\', 'I', 'm', 'p', 'l', 'e', 'm', 'e',
-			  'n', 't', 'e', 'd', ' ', 'C', 'a', 't',
-			  'e', 'g', 'o', 'r', 'i', 'e', 's', 0 };
-
     TRACE("%s\n",debugstr_guid(rclsid));
 
     if (rclsid == NULL || ppenumCATID == NULL)
 	return E_POINTER;
 
-    return CATIDEnumGUID_Construct(rclsid, postfix, ppenumCATID);
+    return CATIDEnumGUID_Construct(rclsid, L"\\Implemented Categories", ppenumCATID);
 }
 
 /**********************************************************************
@@ -654,16 +644,12 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumReqCategoriesOfClass(
     REFCLSID rclsid,
     LPENUMCATID *ppenumCATID)
 {
-    static const WCHAR postfix[] = { '\\', 'R', 'e', 'q', 'u', 'i', 'r', 'e',
-			  'd', ' ', 'C', 'a', 't', 'e', 'g', 'o',
-			  'r', 'i', 'e', 's', 0 };
-
     TRACE("%s\n",debugstr_guid(rclsid));
 
     if (rclsid == NULL || ppenumCATID == NULL)
 	return E_POINTER;
 
-    return CATIDEnumGUID_Construct(rclsid, postfix, ppenumCATID);
+    return CATIDEnumGUID_Construct(rclsid, L"\\Required Categories", ppenumCATID);
 }
 
 /**********************************************************************
@@ -855,9 +841,6 @@ static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Clone(
     IEnumCATEGORYINFO **ppenum)
 {
     IEnumCATEGORYINFOImpl *This = impl_from_IEnumCATEGORYINFO(iface);
-    static const WCHAR keyname[] = { 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n',
-                                     't', ' ', 'C', 'a', 't', 'e', 'g', 'o',
-                                     'r', 'i', 'e', 's', 0 };
     IEnumCATEGORYINFOImpl *new_this;
 
     TRACE("\n");
@@ -871,7 +854,7 @@ static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Clone(
     new_this->ref = 1;
     new_this->lcid = This->lcid;
     /* FIXME: could we more efficiently use DuplicateHandle? */
-    open_classes_key(HKEY_CLASSES_ROOT, keyname, KEY_READ, &new_this->key);
+    open_classes_key(HKEY_CLASSES_ROOT, comcat_keyname, KEY_READ, &new_this->key);
     new_this->next_index = This->next_index;
 
     *ppenum = &new_this->IEnumCATEGORYINFO_iface;
@@ -891,7 +874,6 @@ static const IEnumCATEGORYINFOVtbl COMCAT_IEnumCATEGORYINFO_Vtbl =
 
 static HRESULT EnumCATEGORYINFO_Construct(LCID lcid, IEnumCATEGORYINFO **ret)
 {
-    static const WCHAR keyname[] = {'C','o','m','p','o','n','e','n','t',' ','C','a','t','e','g','o','r','i','e','s',0};
     IEnumCATEGORYINFOImpl *This;
 
     *ret = NULL;
@@ -902,7 +884,7 @@ static HRESULT EnumCATEGORYINFO_Construct(LCID lcid, IEnumCATEGORYINFO **ret)
     This->IEnumCATEGORYINFO_iface.lpVtbl = &COMCAT_IEnumCATEGORYINFO_Vtbl;
     This->ref = 1;
     This->lcid = lcid;
-    open_classes_key(HKEY_CLASSES_ROOT, keyname, KEY_READ, &This->key);
+    open_classes_key(HKEY_CLASSES_ROOT, comcat_keyname, KEY_READ, &This->key);
 
     *ret = &This->IEnumCATEGORYINFO_iface;
     return S_OK;
@@ -1043,7 +1025,6 @@ static HRESULT WINAPI CLSIDEnumGUID_Clone(
     IEnumGUID *iface,
     IEnumGUID **ppenum)
 {
-    static const WCHAR keynameW[] = {'C','L','S','I','D',0};
     CLSID_IEnumGUIDImpl *This = impl_from_IEnumCLSID(iface);
     CLSID_IEnumGUIDImpl *cloned;
 
@@ -1067,7 +1048,7 @@ static HRESULT WINAPI CLSIDEnumGUID_Clone(
     memcpy(cloned->categories, This->categories, This->categories->size);
 
     cloned->key = NULL;
-    open_classes_key(HKEY_CLASSES_ROOT, keynameW, KEY_READ, &cloned->key);
+    open_classes_key(HKEY_CLASSES_ROOT, L"CLSID", KEY_READ, &cloned->key);
     cloned->next_index = This->next_index;
 
     *ppenum = &cloned->IEnumGUID_iface;
@@ -1087,7 +1068,6 @@ static const IEnumGUIDVtbl CLSIDEnumGUIDVtbl =
 
 static HRESULT CLSIDEnumGUID_Construct(struct class_categories *categories, IEnumCLSID **ret)
 {
-    static const WCHAR keyname[] = {'C','L','S','I','D',0};
     CLSID_IEnumGUIDImpl *This;
 
     *ret = NULL;
@@ -1098,7 +1078,7 @@ static HRESULT CLSIDEnumGUID_Construct(struct class_categories *categories, IEnu
     This->IEnumGUID_iface.lpVtbl = &CLSIDEnumGUIDVtbl;
     This->ref = 1;
     This->categories = categories;
-    open_classes_key(HKEY_CLASSES_ROOT, keyname, KEY_READ, &This->key);
+    open_classes_key(HKEY_CLASSES_ROOT, L"CLSID", KEY_READ, &This->key);
 
     *ret = &This->IEnumGUID_iface;
 
@@ -1265,7 +1245,6 @@ static const IEnumGUIDVtbl CATIDEnumGUIDVtbl =
 
 static HRESULT CATIDEnumGUID_Construct(REFCLSID rclsid, LPCWSTR postfix, IEnumGUID **ret)
 {
-    static const WCHAR prefixW[] = {'C','L','S','I','D','\\',0};
     WCHAR keyname[100], clsidW[CHARS_IN_GUID];
     CATID_IEnumGUIDImpl *This;
 
@@ -1278,7 +1257,7 @@ static HRESULT CATIDEnumGUID_Construct(REFCLSID rclsid, LPCWSTR postfix, IEnumGU
 
     This->IEnumGUID_iface.lpVtbl = &CATIDEnumGUIDVtbl;
     This->ref = 1;
-    lstrcpyW(keyname, prefixW);
+    lstrcpyW(keyname, L"CLSID\\");
     lstrcatW(keyname, clsidW);
     lstrcatW(keyname, postfix);
 




More information about the wine-cvs mailing list