diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 51e942b041..4a61aca58b 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -1108,6 +1108,43 @@ HRESULT COM_OpenKeyForCLSID(REFCLSID clsid, LPCWSTR keyname, REGSAM access, HKEY 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 ac9243caf5..cb4dd64a58 100644 --- a/dlls/ole32/compobj_private.h +++ b/dlls/ole32/compobj_private.h @@ -178,6 +178,7 @@ extern void* StdGlobalInterfaceTableInstance; 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 8decc2cbfa..cf55b4ca6e 100644 --- a/dlls/ole32/rpc.c +++ b/dlls/ole32/rpc.c @@ -796,9 +796,7 @@ static DWORD start_local_service(LPCWSTR name, DWORD num, LPCWSTR *params) 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(REFCLSID rclsid) 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)