Commit b10d99a3 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

combase: Move CLSIDFromString().

parent d271b9ff
...@@ -1053,6 +1053,28 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, CLSID *clsid) ...@@ -1053,6 +1053,28 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, CLSID *clsid)
return clsid_from_string_reg(progid, 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) static void init_multi_qi(DWORD count, MULTI_QI *mqi, HRESULT hr)
{ {
ULONG i; ULONG i;
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
@ stdcall CLIPFORMAT_UserUnmarshal(ptr ptr ptr) @ stdcall CLIPFORMAT_UserUnmarshal(ptr ptr ptr)
@ stub CLSIDFromOle1Class @ stub CLSIDFromOle1Class
@ stdcall CLSIDFromProgID(wstr ptr) @ stdcall CLSIDFromProgID(wstr ptr)
@ stdcall CLSIDFromString(wstr ptr) ole32.CLSIDFromString @ stdcall CLSIDFromString(wstr ptr)
@ stub CleanupOleStateInAllTls @ stub CleanupOleStateInAllTls
@ stdcall CleanupTlsOleState(ptr) @ stdcall CleanupTlsOleState(ptr)
@ stub ClearCleanupFlag @ stub ClearCleanupFlag
......
...@@ -2257,75 +2257,6 @@ static BOOL guid_from_string(LPCWSTR s, GUID *id) ...@@ -2257,75 +2257,6 @@ static BOOL guid_from_string(LPCWSTR s, GUID *id)
return FALSE; 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.@] * IIDFromString [OLE32.@]
* *
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
@ stdcall CLIPFORMAT_UserUnmarshal(ptr ptr ptr) combase.CLIPFORMAT_UserUnmarshal @ stdcall CLIPFORMAT_UserUnmarshal(ptr ptr ptr) combase.CLIPFORMAT_UserUnmarshal
@ stdcall CLSIDFromProgID(wstr ptr) combase.CLSIDFromProgID @ stdcall CLSIDFromProgID(wstr ptr) combase.CLSIDFromProgID
@ stdcall CLSIDFromProgIDEx(wstr ptr) @ stdcall CLSIDFromProgIDEx(wstr ptr)
@ stdcall CLSIDFromString(wstr ptr) @ stdcall CLSIDFromString(wstr ptr) combase.CLSIDFromString
@ stdcall CoAddRefServerProcess() @ stdcall CoAddRefServerProcess()
@ stdcall CoAllowSetForegroundWindow(ptr ptr) @ stdcall CoAllowSetForegroundWindow(ptr ptr)
@ stdcall CoBuildVersion() @ stdcall CoBuildVersion()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment