2 * IParseDisplayName implementation for DEVENUM.dll
4 * Copyright (C) 2002 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 * - Implements IParseDisplayName interface which creates a moniker
22 * from a string in a special format
24 #include "devenum_private.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(devenum
);
30 static HRESULT WINAPI
devenum_parser_QueryInterface(IParseDisplayName
*iface
, REFIID riid
, void **ppv
)
32 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid
));
37 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
38 IsEqualGUID(riid
, &IID_IParseDisplayName
))
41 IParseDisplayName_AddRef(iface
);
45 FIXME("- no interface IID: %s\n", debugstr_guid(riid
));
50 static ULONG WINAPI
devenum_parser_AddRef(IParseDisplayName
*iface
)
56 return 2; /* non-heap based object */
59 static ULONG WINAPI
devenum_parser_Release(IParseDisplayName
*iface
)
63 DEVENUM_UnlockModule();
65 return 1; /* non-heap based object */
68 static HRESULT WINAPI
devenum_parser_ParseDisplayName(IParseDisplayName
*iface
,
69 IBindCtx
*pbc
, LPOLESTR name
, ULONG
*eaten
, IMoniker
**ret
)
71 struct moniker
*moniker
;
72 WCHAR buffer
[MAX_PATH
];
73 enum device_type type
;
76 TRACE("(%p, %s, %p, %p)\n", pbc
, debugstr_w(name
), eaten
, ret
);
80 *eaten
= wcslen(name
);
82 name
= wcschr(name
, ':') + 1;
84 if (!wcsncmp(name
, L
"sw:", 3))
89 else if (!wcsncmp(name
, L
"cm:", 3))
94 else if (!wcsncmp(name
, L
"dmo:", 4))
101 FIXME("unhandled device type %s\n", debugstr_w(name
));
105 if (type
== DEVICE_DMO
)
107 lstrcpynW(buffer
, name
, CHARS_IN_GUID
);
108 if (FAILED(CLSIDFromString(buffer
, &clsid
)))
111 lstrcpynW(buffer
, name
+ CHARS_IN_GUID
- 1, CHARS_IN_GUID
);
112 if (FAILED(CLSIDFromString(buffer
, &class)))
115 moniker
= dmo_moniker_create(class, clsid
);
119 lstrcpynW(buffer
, name
, CHARS_IN_GUID
);
120 if (CLSIDFromString(buffer
, &class) == S_OK
)
122 name
+= CHARS_IN_GUID
;
123 if (type
== DEVICE_FILTER
)
124 moniker
= filter_moniker_create(&class, name
);
126 moniker
= codec_moniker_create(&class, name
);
130 if (type
== DEVICE_FILTER
)
131 moniker
= filter_moniker_create(NULL
, name
);
133 moniker
= codec_moniker_create(NULL
, name
);
138 return E_OUTOFMEMORY
;
140 *ret
= &moniker
->IMoniker_iface
;
144 /**********************************************************************
145 * IParseDisplayName_Vtbl
147 static const IParseDisplayNameVtbl IParseDisplayName_Vtbl
=
149 devenum_parser_QueryInterface
,
150 devenum_parser_AddRef
,
151 devenum_parser_Release
,
152 devenum_parser_ParseDisplayName
,
155 /* The one instance of this class */
156 IParseDisplayName devenum_parser
= { &IParseDisplayName_Vtbl
};