combase: Move CLSIDFromString().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-08-10 11:12:52 +03:00 committed by Alexandre Julliard
parent d271b9ff73
commit b10d99a371
4 changed files with 24 additions and 71 deletions

View File

@ -1053,6 +1053,28 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, CLSID *clsid)
return clsid_from_string_reg(progid, clsid);
}
/******************************************************************************
* CLSIDFromString (combase.@)
*/
HRESULT WINAPI CLSIDFromString(LPCOLESTR str, LPCLSID clsid)
{
CLSID tmp_id;
HRESULT hr;
if (!clsid)
return E_INVALIDARG;
if (guid_from_string(str, clsid))
return S_OK;
/* It appears a ProgID is also valid */
hr = clsid_from_string_reg(str, &tmp_id);
if (SUCCEEDED(hr))
*clsid = tmp_id;
return hr;
}
static void init_multi_qi(DWORD count, MULTI_QI *mqi, HRESULT hr)
{
ULONG i;

View File

@ -68,7 +68,7 @@
@ stdcall CLIPFORMAT_UserUnmarshal(ptr ptr ptr)
@ stub CLSIDFromOle1Class
@ stdcall CLSIDFromProgID(wstr ptr)
@ stdcall CLSIDFromString(wstr ptr) ole32.CLSIDFromString
@ stdcall CLSIDFromString(wstr ptr)
@ stub CleanupOleStateInAllTls
@ stdcall CleanupTlsOleState(ptr)
@ stub ClearCleanupFlag

View File

@ -2257,75 +2257,6 @@ static BOOL guid_from_string(LPCWSTR s, GUID *id)
return FALSE;
}
/*****************************************************************************/
static HRESULT clsid_from_string_reg(LPCOLESTR progid, CLSID *clsid)
{
static const WCHAR clsidW[] = { '\\','C','L','S','I','D',0 };
WCHAR buf2[CHARS_IN_GUID];
LONG buf2len = sizeof(buf2);
HKEY xhkey;
WCHAR *buf;
memset(clsid, 0, sizeof(*clsid));
buf = HeapAlloc( GetProcessHeap(),0,(lstrlenW(progid)+8) * sizeof(WCHAR) );
if (!buf) return E_OUTOFMEMORY;
lstrcpyW( buf, progid );
lstrcatW( buf, clsidW );
if (open_classes_key(HKEY_CLASSES_ROOT, buf, MAXIMUM_ALLOWED, &xhkey))
{
HeapFree(GetProcessHeap(),0,buf);
WARN("couldn't open key for ProgID %s\n", debugstr_w(progid));
return CO_E_CLASSSTRING;
}
HeapFree(GetProcessHeap(),0,buf);
if (RegQueryValueW(xhkey,NULL,buf2,&buf2len))
{
RegCloseKey(xhkey);
WARN("couldn't query clsid value for ProgID %s\n", debugstr_w(progid));
return CO_E_CLASSSTRING;
}
RegCloseKey(xhkey);
return guid_from_string(buf2, clsid) ? S_OK : CO_E_CLASSSTRING;
}
/******************************************************************************
* CLSIDFromString [OLE32.@]
*
* Converts a unique identifier from its string representation into
* the GUID struct.
*
* PARAMS
* idstr [I] The string representation of the GUID.
* id [O] GUID converted from the string.
*
* RETURNS
* S_OK on success
* CO_E_CLASSSTRING if idstr is not a valid CLSID
*
* SEE ALSO
* StringFromCLSID
*/
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id )
{
HRESULT ret = CO_E_CLASSSTRING;
CLSID tmp_id;
if (!id)
return E_INVALIDARG;
if (guid_from_string(idstr, id))
return S_OK;
/* It appears a ProgID is also valid */
ret = clsid_from_string_reg(idstr, &tmp_id);
if(SUCCEEDED(ret))
*id = tmp_id;
return ret;
}
/******************************************************************************
* IIDFromString [OLE32.@]
*

View File

@ -5,7 +5,7 @@
@ stdcall CLIPFORMAT_UserUnmarshal(ptr ptr ptr) combase.CLIPFORMAT_UserUnmarshal
@ stdcall CLSIDFromProgID(wstr ptr) combase.CLSIDFromProgID
@ stdcall CLSIDFromProgIDEx(wstr ptr)
@ stdcall CLSIDFromString(wstr ptr)
@ stdcall CLSIDFromString(wstr ptr) combase.CLSIDFromString
@ stdcall CoAddRefServerProcess()
@ stdcall CoAllowSetForegroundWindow(ptr ptr)
@ stdcall CoBuildVersion()