2 * Copyright 2013 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "wbemdisp_private.h"
22 #include <wbemdisp_classes.h>
24 static HINSTANCE instance
;
26 static HRESULT WINAPI
WinMGMTS_QueryInterface(IParseDisplayName
*iface
, REFIID riid
, void **ppv
)
28 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
29 TRACE("(IID_IUnknown %p)\n", ppv
);
31 }else if(IsEqualGUID(riid
, &IID_IParseDisplayName
)) {
32 TRACE("(IID_IParseDisplayName %p)\n", ppv
);
35 WARN("Unsupported riid %s\n", debugstr_guid(riid
));
40 IUnknown_AddRef((IUnknown
*)*ppv
);
44 static ULONG WINAPI
WinMGMTS_AddRef(IParseDisplayName
*iface
)
49 static ULONG WINAPI
WinMGMTS_Release(IParseDisplayName
*iface
)
54 static HRESULT WINAPI
WinMGMTS_ParseDisplayName(IParseDisplayName
*iface
, IBindCtx
*pbc
, LPOLESTR pszDisplayName
,
55 ULONG
*pchEaten
, IMoniker
**ppmkOut
)
57 FIXME("(%p %s %p %p)\n", pbc
, debugstr_w(pszDisplayName
), pchEaten
, ppmkOut
);
61 static const IParseDisplayNameVtbl WinMGMTSVtbl
= {
62 WinMGMTS_QueryInterface
,
65 WinMGMTS_ParseDisplayName
68 static IParseDisplayName winmgmts
= { &WinMGMTSVtbl
};
70 static HRESULT
WinMGMTS_create(void **ppv
)
78 IClassFactory IClassFactory_iface
;
79 HRESULT (*fnCreateInstance
)( LPVOID
* );
82 static inline struct factory
*impl_from_IClassFactory( IClassFactory
*iface
)
84 return CONTAINING_RECORD( iface
, struct factory
, IClassFactory_iface
);
87 static HRESULT WINAPI
factory_QueryInterface( IClassFactory
*iface
, REFIID riid
, LPVOID
*obj
)
89 if (IsEqualGUID( riid
, &IID_IUnknown
) || IsEqualGUID( riid
, &IID_IClassFactory
))
91 IClassFactory_AddRef( iface
);
95 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
99 static ULONG WINAPI
factory_AddRef( IClassFactory
*iface
)
104 static ULONG WINAPI
factory_Release( IClassFactory
*iface
)
109 static HRESULT WINAPI
factory_CreateInstance( IClassFactory
*iface
, LPUNKNOWN outer
, REFIID riid
,
112 struct factory
*factory
= impl_from_IClassFactory( iface
);
116 TRACE( "%p, %s, %p\n", outer
, debugstr_guid(riid
), obj
);
119 if (outer
) return CLASS_E_NOAGGREGATION
;
121 hr
= factory
->fnCreateInstance( (LPVOID
*)&unk
);
125 hr
= IUnknown_QueryInterface( unk
, riid
, obj
);
126 IUnknown_Release( unk
);
130 static HRESULT WINAPI
factory_LockServer( IClassFactory
*iface
, BOOL lock
)
132 FIXME( "%p, %d\n", iface
, lock
);
136 static const struct IClassFactoryVtbl factory_vtbl
=
138 factory_QueryInterface
,
141 factory_CreateInstance
,
145 static struct factory swbem_locator_cf
= { { &factory_vtbl
}, SWbemLocator_create
};
146 static struct factory winmgmts_cf
= { { &factory_vtbl
}, WinMGMTS_create
};
148 BOOL WINAPI
DllMain( HINSTANCE hinst
, DWORD reason
, LPVOID reserved
)
153 case DLL_WINE_PREATTACH
:
154 return FALSE
; /* prefer native version */
155 case DLL_PROCESS_ATTACH
:
157 DisableThreadLibraryCalls( hinst
);
163 HRESULT WINAPI
DllGetClassObject( REFCLSID rclsid
, REFIID iid
, LPVOID
*obj
)
165 IClassFactory
*cf
= NULL
;
167 TRACE( "%s, %s, %p\n", debugstr_guid(rclsid
), debugstr_guid(iid
), obj
);
169 if (IsEqualGUID( rclsid
, &CLSID_SWbemLocator
))
170 cf
= &swbem_locator_cf
.IClassFactory_iface
;
171 else if (IsEqualGUID( rclsid
, &CLSID_WinMGMTS
))
172 cf
= &winmgmts_cf
.IClassFactory_iface
;
174 return CLASS_E_CLASSNOTAVAILABLE
;
176 return IClassFactory_QueryInterface( cf
, iid
, obj
);
179 /***********************************************************************
180 * DllCanUnloadNow (WBEMDISP.@)
182 HRESULT WINAPI
DllCanUnloadNow(void)
187 /***********************************************************************
188 * DllRegisterServer (WBEMDISP.@)
190 HRESULT WINAPI
DllRegisterServer(void)
192 return __wine_register_resources( instance
);
195 /***********************************************************************
196 * DllUnregisterServer (WBEMDISP.@)
198 HRESULT WINAPI
DllUnregisterServer(void)
200 return __wine_unregister_resources( instance
);