2003-07-01 06:30:30 +02:00
|
|
|
/*
|
|
|
|
* IParseDisplayName implementation for DEVENUM.dll
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Robert Shearman
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-07-01 06:30:30 +02:00
|
|
|
*
|
|
|
|
* NOTES ON THIS FILE:
|
|
|
|
* - Implements IParseDisplayName interface which creates a moniker
|
|
|
|
* from a string in a special format
|
|
|
|
*/
|
|
|
|
#include "devenum_private.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(devenum);
|
|
|
|
|
2012-04-03 00:22:12 +02:00
|
|
|
static HRESULT WINAPI DEVENUM_IParseDisplayName_QueryInterface(IParseDisplayName *iface,
|
|
|
|
REFIID riid, void **ppv)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
|
|
|
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
|
|
|
|
|
2012-04-03 00:22:12 +02:00
|
|
|
if (!ppv)
|
|
|
|
return E_POINTER;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IParseDisplayName))
|
|
|
|
{
|
2012-04-03 00:22:12 +02:00
|
|
|
*ppv = iface;
|
|
|
|
IParseDisplayName_AddRef(iface);
|
|
|
|
return S_OK;
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2010-01-11 23:47:51 +01:00
|
|
|
FIXME("- no interface IID: %s\n", debugstr_guid(riid));
|
2012-04-03 00:22:12 +02:00
|
|
|
*ppv = NULL;
|
2003-07-01 06:30:30 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2012-04-03 00:22:12 +02:00
|
|
|
static ULONG WINAPI DEVENUM_IParseDisplayName_AddRef(IParseDisplayName *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
2004-12-07 15:37:11 +01:00
|
|
|
DEVENUM_LockModule();
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2004-12-07 15:37:11 +01:00
|
|
|
return 2; /* non-heap based object */
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2012-04-03 00:22:12 +02:00
|
|
|
static ULONG WINAPI DEVENUM_IParseDisplayName_Release(IParseDisplayName *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
2004-12-07 15:37:11 +01:00
|
|
|
DEVENUM_UnlockModule();
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2004-12-07 15:37:11 +01:00
|
|
|
return 1; /* non-heap based object */
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* DEVENUM_IParseDisplayName_ParseDisplayName
|
|
|
|
*
|
|
|
|
* Creates a moniker referenced to by the display string argument
|
|
|
|
*
|
|
|
|
* POSSIBLE BUGS:
|
2003-12-30 22:52:45 +01:00
|
|
|
* Might not handle more complicated strings properly (ie anything
|
|
|
|
* not in "@device:sw:{CLSID1}\<filter name or CLSID>" format
|
2003-07-01 06:30:30 +02:00
|
|
|
*/
|
2012-04-03 00:22:12 +02:00
|
|
|
static HRESULT WINAPI DEVENUM_IParseDisplayName_ParseDisplayName(IParseDisplayName *iface,
|
|
|
|
IBindCtx *pbc, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
|
|
|
LPOLESTR pszBetween = NULL;
|
|
|
|
LPOLESTR pszClass = NULL;
|
|
|
|
MediaCatMoniker * pMoniker = NULL;
|
|
|
|
CLSID clsidDevice;
|
|
|
|
HRESULT res = S_OK;
|
2008-06-29 14:07:32 +02:00
|
|
|
WCHAR wszRegKeyName[MAX_PATH];
|
|
|
|
HKEY hbasekey;
|
2005-04-18 12:30:55 +02:00
|
|
|
int classlen;
|
2008-06-29 14:07:32 +02:00
|
|
|
static const WCHAR wszRegSeparator[] = {'\\', 0 };
|
2003-12-30 22:52:45 +01:00
|
|
|
|
2003-07-01 06:30:30 +02:00
|
|
|
TRACE("(%p, %s, %p, %p)\n", pbc, debugstr_w(pszDisplayName), pchEaten, ppmkOut);
|
|
|
|
|
|
|
|
*ppmkOut = NULL;
|
|
|
|
if (pchEaten)
|
|
|
|
*pchEaten = strlenW(pszDisplayName);
|
|
|
|
|
|
|
|
pszDisplayName = strchrW(pszDisplayName, '{');
|
|
|
|
pszBetween = strchrW(pszDisplayName, '}') + 2;
|
|
|
|
|
|
|
|
/* size = pszBetween - pszDisplayName - 1 (for '\\' after CLSID)
|
|
|
|
* + 1 (for NULL character)
|
|
|
|
*/
|
2005-04-18 12:30:55 +02:00
|
|
|
classlen = (int)(pszBetween - pszDisplayName - 1);
|
|
|
|
pszClass = CoTaskMemAlloc((classlen + 1) * sizeof(WCHAR));
|
2003-07-01 06:30:30 +02:00
|
|
|
if (!pszClass)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2005-04-18 12:30:55 +02:00
|
|
|
memcpy(pszClass, pszDisplayName, classlen * sizeof(WCHAR));
|
|
|
|
pszClass[classlen] = 0;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
TRACE("Device CLSID: %s\n", debugstr_w(pszClass));
|
|
|
|
|
|
|
|
res = CLSIDFromString(pszClass, &clsidDevice);
|
|
|
|
|
|
|
|
if (SUCCEEDED(res))
|
|
|
|
{
|
2008-06-29 14:07:32 +02:00
|
|
|
res = DEVENUM_GetCategoryKey(&clsidDevice, &hbasekey, wszRegKeyName, MAX_PATH);
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(res))
|
|
|
|
{
|
|
|
|
pMoniker = DEVENUM_IMediaCatMoniker_Construct();
|
|
|
|
if (pMoniker)
|
|
|
|
{
|
2008-06-29 14:07:32 +02:00
|
|
|
strcatW(wszRegKeyName, wszRegSeparator);
|
|
|
|
strcatW(wszRegKeyName, pszBetween);
|
|
|
|
|
|
|
|
if (RegCreateKeyW(hbasekey, wszRegKeyName, &pMoniker->hkey) == ERROR_SUCCESS)
|
2012-04-03 00:18:39 +02:00
|
|
|
*ppmkOut = &pMoniker->IMoniker_iface;
|
2003-07-01 06:30:30 +02:00
|
|
|
else
|
|
|
|
{
|
2012-04-03 00:18:39 +02:00
|
|
|
IMoniker_Release(&pMoniker->IMoniker_iface);
|
2003-07-01 06:30:30 +02:00
|
|
|
res = MK_E_NOOBJECT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-07 03:05:08 +02:00
|
|
|
CoTaskMemFree(pszClass);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2006-10-08 18:58:22 +02:00
|
|
|
TRACE("-- returning: %x\n", res);
|
2003-07-01 06:30:30 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* IParseDisplayName_Vtbl
|
|
|
|
*/
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IParseDisplayNameVtbl IParseDisplayName_Vtbl =
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
|
|
|
DEVENUM_IParseDisplayName_QueryInterface,
|
|
|
|
DEVENUM_IParseDisplayName_AddRef,
|
|
|
|
DEVENUM_IParseDisplayName_Release,
|
|
|
|
DEVENUM_IParseDisplayName_ParseDisplayName
|
|
|
|
};
|
|
|
|
|
|
|
|
/* The one instance of this class */
|
2012-04-04 10:43:12 +02:00
|
|
|
IParseDisplayName DEVENUM_ParseDisplayName = { &IParseDisplayName_Vtbl };
|