From 3a2b1b6e42f21e1fcab5e8f7a7270b3aa8edd9ee Mon Sep 17 00:00:00 2001 From: Abey George Date: Sun, 31 Oct 1999 02:24:51 +0000 Subject: [PATCH] Implemented ProgIDFromCLSID. --- dlls/ole32/compobj.c | 51 +++++++++++++++++++++++++++++++++++++++++++ dlls/ole32/ole32.spec | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 0021cc2155e..420e068b3ce 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -857,6 +857,57 @@ StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax) return strlen(xguid); } +/****************************************************************************** + * ProgIDFromCLSID [OLE32.133] + * Converts a class id into the respective Program ID. (By using a registry lookup) + * RETURNS S_OK on success + * riid associated with the progid + */ + +HRESULT WINAPI ProgIDFromCLSID( + REFCLSID clsid, /* [in] class id as found in registry */ + LPOLESTR *lplpszProgID/* [out] associated Prog ID */ +) +{ + char strCLSID[50], *buf, *buf2; + DWORD buf2len; + HKEY xhkey; + LPMALLOC mllc; + HRESULT ret = S_OK; + + WINE_StringFromCLSID(clsid, strCLSID); + + buf = HeapAlloc(GetProcessHeap(), 0, strlen(strCLSID)+14); + sprintf(buf,"CLSID\\%s\\ProgID", strCLSID); + if (RegOpenKeyA(HKEY_CLASSES_ROOT, buf, &xhkey)) + ret = REGDB_E_CLASSNOTREG; + + HeapFree(GetProcessHeap(), 0, buf); + + if (ret == S_OK) + { + buf2 = HeapAlloc(GetProcessHeap(), 0, 255); + buf2len = 255; + if (RegQueryValueA(xhkey, NULL, buf2, &buf2len)) + ret = REGDB_E_CLASSNOTREG; + + if (ret == S_OK) + { + if (CoGetMalloc(0,&mllc)) + ret = E_OUTOFMEMORY; + else + { + *lplpszProgID = IMalloc_Alloc(mllc, (buf2len+1)*2); + lstrcpyAtoW(*lplpszProgID, buf2); + } + } + HeapFree(GetProcessHeap(), 0, buf2); + } + + RegCloseKey(xhkey); + return ret; +} + /****************************************************************************** * CLSIDFromProgID16 [COMPOBJ.61] * Converts a program id into the respective GUID. (By using a registry lookup) diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index 7114c706b5f..fdfc131721c 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -133,7 +133,7 @@ type win32 130 stdcall OleTranslateAccelerator(ptr ptr ptr) OleTranslateAccelerator 131 stdcall OleUninitialize() OleUninitialize 132 stub OpenOrCreateStream -133 stub ProgIDFromCLSID +133 stdcall ProgIDFromCLSID(wstr ptr) ProgIDFromCLSID 134 stdcall ReadClassStg(ptr ptr) ReadClassStg 135 stdcall ReadClassStm(ptr ptr) ReadClassStm 136 stdcall ReadFmtUserTypeStg(ptr ptr ptr) ReadFmtUserTypeStg