- Fix the return values from QueryPathOfRegTypeLib.

- Open registry key with least access rights necessary.
- Documentation updates.
This commit is contained in:
Robert Shearman 2005-06-01 11:03:29 +00:00 committed by Alexandre Julliard
parent 61d862540b
commit 9ddf17bfa7
1 changed files with 65 additions and 31 deletions

View File

@ -192,38 +192,55 @@ static WCHAR *get_lcid_subkey( LCID lcid, SYSKIND syskind, WCHAR *buffer )
return buffer; return buffer;
} }
int TLB_ReadTypeLib(LPCWSTR file, INT index, ITypeLib2 **ppTypelib);
/**************************************************************************** /****************************************************************************
* QueryPathOfRegTypeLib [OLEAUT32.164] * QueryPathOfRegTypeLib [OLEAUT32.164]
*
* Gets the path to a registered type library.
*
* PARAMS
* guid [I] referenced guid
* wMaj [I] major version
* wMin [I] minor version
* lcid [I] locale id
* path [O] path of typelib
*
* RETURNS * RETURNS
* path of typelib * Success: S_OK.
* Failure: If the type library is not registered then TYPE_E_LIBNOTREGISTERED
* or TYPE_E_REGISTRYACCESS if the type library registration key couldn't be
* opened.
*/ */
HRESULT WINAPI HRESULT WINAPI QueryPathOfRegTypeLib(
QueryPathOfRegTypeLib( REFGUID guid,
REFGUID guid, /* [in] referenced guid */ WORD wMaj,
WORD wMaj, /* [in] major version */ WORD wMin,
WORD wMin, /* [in] minor version */ LCID lcid,
LCID lcid, /* [in] locale id */ LPBSTR path )
LPBSTR path ) /* [out] path of typelib */
{ {
HRESULT hr = E_FAIL; HRESULT hr = TYPE_E_LIBNOTREGISTERED;
LCID myLCID = lcid; LCID myLCID = lcid;
HKEY hkey; HKEY hkey;
WCHAR buffer[60]; WCHAR buffer[60];
WCHAR Path[MAX_PATH]; WCHAR Path[MAX_PATH];
LONG res;
if ( !HIWORD(guid) ) TRACE_(typelib)("(%s, %x.%x, 0x%lx, %p)\n", debugstr_guid(guid), wMaj, wMin, lcid, path);
{
FIXME("(guid %p,%d,%d,0x%04lx,%p),stub!\n", guid, wMaj, wMin, lcid, path);
return E_FAIL;
}
get_typelib_key( guid, wMaj, wMin, buffer ); get_typelib_key( guid, wMaj, wMin, buffer );
if (RegOpenKeyW( HKEY_CLASSES_ROOT, buffer, &hkey ) != ERROR_SUCCESS) res = RegOpenKeyExW( HKEY_CLASSES_ROOT, buffer, 0, KEY_READ, &hkey );
if (res == ERROR_FILE_NOT_FOUND)
{ {
TRACE_(typelib)("%s not found\n", debugstr_w(buffer)); TRACE_(typelib)("%s not found\n", debugstr_w(buffer));
return E_FAIL; return TYPE_E_LIBNOTREGISTERED;
}
else if (res != ERROR_SUCCESS)
{
TRACE_(typelib)("failed to open %s for read access\n", debugstr_w(buffer));
return TYPE_E_REGISTRYACCESS;
} }
while (hr != S_OK) while (hr != S_OK)
@ -258,6 +275,7 @@ QueryPathOfRegTypeLib(
} }
} }
RegCloseKey( hkey ); RegCloseKey( hkey );
TRACE_(typelib)("-- 0x%08lx\n", hr);
return hr; return hr;
} }
@ -274,22 +292,24 @@ HRESULT WINAPI CreateTypeLib(
FIXME("(%d,%s,%p), stub!\n",syskind,debugstr_w(szFile),ppctlib); FIXME("(%d,%s,%p), stub!\n",syskind,debugstr_w(szFile),ppctlib);
return E_FAIL; return E_FAIL;
} }
/****************************************************************************** /******************************************************************************
* LoadTypeLib [OLEAUT32.161] * LoadTypeLib [OLEAUT32.161]
* Loads and registers a type library *
* NOTES * Loads a type library
* Docs: OLECHAR FAR* szFile *
* Docs: iTypeLib FAR* FAR* pptLib * PARAMS
* szFile [I] Name of file to load from.
* pptLib [O] Pointer that receives ITypeLib object on success.
* *
* RETURNS * RETURNS
* Success: S_OK * Success: S_OK
* Failure: Status * Failure: Status
*
* SEE
* LoadTypeLibEx, LoadRegTypeLib, CreateTypeLib.
*/ */
int TLB_ReadTypeLib(LPCWSTR file, INT index, ITypeLib2 **ppTypelib); HRESULT WINAPI LoadTypeLib(const OLECHAR *szFile, ITypeLib * *pptLib)
HRESULT WINAPI LoadTypeLib(
const OLECHAR *szFile,/* [in] Name of file to load from */
ITypeLib * *pptLib) /* [out] Pointer to pointer to loaded type library */
{ {
TRACE("(%s,%p)\n",debugstr_w(szFile), pptLib); TRACE("(%s,%p)\n",debugstr_w(szFile), pptLib);
return LoadTypeLibEx(szFile, REGKIND_DEFAULT, pptLib); return LoadTypeLibEx(szFile, REGKIND_DEFAULT, pptLib);
@ -297,6 +317,7 @@ HRESULT WINAPI LoadTypeLib(
/****************************************************************************** /******************************************************************************
* LoadTypeLibEx [OLEAUT32.183] * LoadTypeLibEx [OLEAUT32.183]
*
* Loads and optionally registers a type library * Loads and optionally registers a type library
* *
* RETURNS * RETURNS
@ -368,13 +389,27 @@ HRESULT WINAPI LoadTypeLibEx(
/****************************************************************************** /******************************************************************************
* LoadRegTypeLib [OLEAUT32.162] * LoadRegTypeLib [OLEAUT32.162]
*
* Loads a registered type library.
*
* PARAMS
* rguid [I] GUID of the registered type library.
* wVerMajor [I] major version.
* wVerMinor [I] minor version.
* lcid [I] locale ID.
* ppTLib [O] pointer that receives an ITypeLib object on success.
*
* RETURNS
* Success: S_OK.
* Failure: Any HRESULT code returned from QueryPathOfRegTypeLib or
* LoadTypeLib.
*/ */
HRESULT WINAPI LoadRegTypeLib( HRESULT WINAPI LoadRegTypeLib(
REFGUID rguid, /* [in] referenced guid */ REFGUID rguid,
WORD wVerMajor, /* [in] major version */ WORD wVerMajor,
WORD wVerMinor, /* [in] minor version */ WORD wVerMinor,
LCID lcid, /* [in] locale id */ LCID lcid,
ITypeLib **ppTLib) /* [out] path of typelib */ ITypeLib **ppTLib)
{ {
BSTR bstr=NULL; BSTR bstr=NULL;
HRESULT res=QueryPathOfRegTypeLib( rguid, wVerMajor, wVerMinor, lcid, &bstr); HRESULT res=QueryPathOfRegTypeLib( rguid, wVerMajor, wVerMinor, lcid, &bstr);
@ -5062,7 +5097,6 @@ static HRESULT WINAPI ITypeInfo_fnGetRefTypeInfo(
ITypeInfoImpl *This = (ITypeInfoImpl *)iface; ITypeInfoImpl *This = (ITypeInfoImpl *)iface;
HRESULT result = E_FAIL; HRESULT result = E_FAIL;
if (hRefType == -1 && if (hRefType == -1 &&
(((ITypeInfoImpl*) This)->TypeAttr.typekind == TKIND_DISPATCH) && (((ITypeInfoImpl*) This)->TypeAttr.typekind == TKIND_DISPATCH) &&
(((ITypeInfoImpl*) This)->TypeAttr.wTypeFlags & TYPEFLAG_FDUAL)) (((ITypeInfoImpl*) This)->TypeAttr.wTypeFlags & TYPEFLAG_FDUAL))