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
)
54 return 2; /* non-heap based object */
57 static ULONG WINAPI
devenum_parser_Release(IParseDisplayName
*iface
)
61 return 1; /* non-heap based object */
64 static HRESULT WINAPI
devenum_parser_ParseDisplayName(IParseDisplayName
*iface
,
65 IBindCtx
*pbc
, LPOLESTR name
, ULONG
*eaten
, IMoniker
**ret
)
67 struct moniker
*moniker
;
68 WCHAR buffer
[MAX_PATH
];
69 enum device_type type
;
72 TRACE("(%p, %s, %p, %p)\n", pbc
, debugstr_w(name
), eaten
, ret
);
76 *eaten
= wcslen(name
);
78 name
= wcschr(name
, ':') + 1;
80 if (!wcsncmp(name
, L
"sw:", 3))
85 else if (!wcsncmp(name
, L
"cm:", 3))
90 else if (!wcsncmp(name
, L
"dmo:", 4))
97 FIXME("unhandled device type %s\n", debugstr_w(name
));
101 if (type
== DEVICE_DMO
)
103 lstrcpynW(buffer
, name
, CHARS_IN_GUID
);
104 if (FAILED(CLSIDFromString(buffer
, &clsid
)))
107 lstrcpynW(buffer
, name
+ CHARS_IN_GUID
- 1, CHARS_IN_GUID
);
108 if (FAILED(CLSIDFromString(buffer
, &class)))
111 moniker
= dmo_moniker_create(class, clsid
);
115 lstrcpynW(buffer
, name
, CHARS_IN_GUID
);
116 if (CLSIDFromString(buffer
, &class) == S_OK
)
118 name
+= CHARS_IN_GUID
;
119 if (type
== DEVICE_FILTER
)
120 moniker
= filter_moniker_create(&class, name
);
122 moniker
= codec_moniker_create(&class, name
);
126 if (type
== DEVICE_FILTER
)
127 moniker
= filter_moniker_create(NULL
, name
);
129 moniker
= codec_moniker_create(NULL
, name
);
134 return E_OUTOFMEMORY
;
136 *ret
= &moniker
->IMoniker_iface
;
140 /**********************************************************************
141 * IParseDisplayName_Vtbl
143 static const IParseDisplayNameVtbl IParseDisplayName_Vtbl
=
145 devenum_parser_QueryInterface
,
146 devenum_parser_AddRef
,
147 devenum_parser_Release
,
148 devenum_parser_ParseDisplayName
,
151 /* The one instance of this class */
152 IParseDisplayName devenum_parser
= { &IParseDisplayName_Vtbl
};