Robert Shearman : ole32:
Move the opening of the AppId key for a clsid to a helper function.
Alexandre Julliard
julliard at wine.codeweavers.com
Sat Aug 26 13:47:41 CDT 2006
Module: wine
Branch: master
Commit: 83d24a640875c2e834e37e3bd7e03e1c6e497ee5
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=83d24a640875c2e834e37e3bd7e03e1c6e497ee5
Author: Robert Shearman <rob at codeweavers.com>
Date: Sat Aug 26 11:55:16 2006 +0100
ole32: Move the opening of the AppId key for a clsid to a helper function.
---
dlls/ole32/compobj.c | 37 +++++++++++++++++++++++++++++++++++++
dlls/ole32/compobj_private.h | 1 +
dlls/ole32/rpc.c | 17 ++---------------
3 files changed, 40 insertions(+), 15 deletions(-)
diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index 51e942b..4a61aca 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -1108,6 +1108,43 @@ HRESULT COM_OpenKeyForCLSID(REFCLSID cls
return S_OK;
}
+/* open HKCR\\AppId\\{string form of appid clsid} key */
+HRESULT COM_OpenKeyForAppIdFromCLSID(REFCLSID clsid, REGSAM access, HKEY *subkey)
+{
+ static const WCHAR szAppId[] = { 'A','p','p','I','d',0 };
+ static const WCHAR szAppIdKey[] = { 'A','p','p','I','d','\\',0 };
+ DWORD res;
+ WCHAR buf[CHARS_IN_GUID];
+ WCHAR keyname[ARRAYSIZE(szAppIdKey) + CHARS_IN_GUID];
+ DWORD size;
+ HKEY hkey;
+ DWORD type;
+ HRESULT hr;
+
+ /* read the AppID value under the class's key */
+ hr = COM_OpenKeyForCLSID(clsid, szAppId, KEY_READ, &hkey);
+ if (FAILED(hr))
+ return hr;
+
+ size = sizeof(buf);
+ res = RegQueryValueExW(hkey, NULL, NULL, &type, (LPBYTE)buf, &size);
+ RegCloseKey(hkey);
+ if (res == ERROR_FILE_NOT_FOUND)
+ return REGDB_E_KEYMISSING;
+ else if (res != ERROR_SUCCESS || type!=REG_SZ)
+ return REGDB_E_READREGDB;
+
+ strcpyW(keyname, szAppIdKey);
+ strcatW(keyname, buf);
+ res = RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, access, subkey);
+ if (res == ERROR_FILE_NOT_FOUND)
+ return REGDB_E_KEYMISSING;
+ else if (res != ERROR_SUCCESS)
+ return REGDB_E_READREGDB;
+
+ return S_OK;
+}
+
/******************************************************************************
* ProgIDFromCLSID [OLE32.@]
*
diff --git a/dlls/ole32/compobj_private.h b/dlls/ole32/compobj_private.h
index ac9243c..cb4dd64 100644
--- a/dlls/ole32/compobj_private.h
+++ b/dlls/ole32/compobj_private.h
@@ -178,6 +178,7 @@ extern void* StdGlobalInterfaceTableInst
extern HRESULT WINE_StringFromCLSID(const CLSID *id,LPSTR idstr);
HRESULT COM_OpenKeyForCLSID(REFCLSID clsid, LPCWSTR keyname, REGSAM access, HKEY *key);
+HRESULT COM_OpenKeyForAppIdFromCLSID(REFCLSID clsid, REGSAM access, HKEY *subkey);
HRESULT MARSHAL_GetStandardMarshalCF(LPVOID *ppv);
HRESULT FTMarshalCF_Create(REFIID riid, LPVOID *ppv);
diff --git a/dlls/ole32/rpc.c b/dlls/ole32/rpc.c
index 8decc2c..cf55b4c 100644
--- a/dlls/ole32/rpc.c
+++ b/dlls/ole32/rpc.c
@@ -796,9 +796,7 @@ static DWORD start_local_service(LPCWSTR
static HRESULT create_local_service(REFCLSID rclsid)
{
HRESULT hres;
- WCHAR buf[CHARS_IN_GUID], keyname[50];
- static const WCHAR szAppId[] = { 'A','p','p','I','d',0 };
- static const WCHAR szAppIdKey[] = { 'A','p','p','I','d','\\',0 };
+ WCHAR buf[CHARS_IN_GUID];
static const WCHAR szLocalService[] = { 'L','o','c','a','l','S','e','r','v','i','c','e',0 };
static const WCHAR szServiceParams[] = {'S','e','r','v','i','c','e','P','a','r','a','m','s',0};
HKEY hkey;
@@ -807,22 +805,11 @@ static HRESULT create_local_service(REFC
TRACE("Attempting to start Local service for %s\n", debugstr_guid(rclsid));
- /* read the AppID value under the class's key */
- hres = COM_OpenKeyForCLSID(rclsid, szAppId, KEY_READ, &hkey);
+ hres = COM_OpenKeyForAppIdFromCLSID(rclsid, KEY_READ, &hkey);
if (FAILED(hres))
return hres;
- sz = sizeof buf;
- r = RegQueryValueExW(hkey, NULL, NULL, &type, (LPBYTE)buf, &sz);
- RegCloseKey(hkey);
- if (r!=ERROR_SUCCESS || type!=REG_SZ)
- return hres;
/* read the LocalService and ServiceParameters values from the AppID key */
- strcpyW(keyname, szAppIdKey);
- strcatW(keyname, buf);
- r = RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &hkey);
- if (r!=ERROR_SUCCESS)
- return hres;
sz = sizeof buf;
r = RegQueryValueExW(hkey, szLocalService, NULL, &type, (LPBYTE)buf, &sz);
if (r==ERROR_SUCCESS && type==REG_SZ)
More information about the wine-cvs
mailing list