2 * Copyright 2011 Jacek Caban 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 "wshom_private.h"
23 static HINSTANCE wshom_instance
;
25 static ITypeLib
*typelib
;
26 static ITypeInfo
*typeinfos
[LAST_tid
];
28 static REFIID tid_ids
[] = {
36 static HRESULT
load_typelib(void)
41 hres
= LoadRegTypeLib(&LIBID_IWshRuntimeLibrary
, 1, 0, LOCALE_SYSTEM_DEFAULT
, &tl
);
43 ERR("LoadRegTypeLib failed: %08x\n", hres
);
47 if(InterlockedCompareExchangePointer((void**)&typelib
, tl
, NULL
))
52 HRESULT
get_typeinfo(tid_t tid
, ITypeInfo
**typeinfo
)
57 hres
= load_typelib();
64 hres
= ITypeLib_GetTypeInfoOfGuid(typelib
, tid_ids
[tid
], &ti
);
66 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids
[tid
]), hres
);
70 if(InterlockedCompareExchangePointer((void**)(typeinfos
+tid
), ti
, NULL
))
71 ITypeInfo_Release(ti
);
74 *typeinfo
= typeinfos
[tid
];
75 ITypeInfo_AddRef(*typeinfo
);
80 void release_typelib(void)
87 for(i
=0; i
< sizeof(typeinfos
)/sizeof(*typeinfos
); i
++)
89 ITypeInfo_Release(typeinfos
[i
]);
91 ITypeLib_Release(typelib
);
94 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
98 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
99 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
101 }else if(IsEqualGUID(&IID_IClassFactory
, riid
)) {
102 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
107 IUnknown_AddRef((IUnknown
*)*ppv
);
111 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
112 return E_NOINTERFACE
;
115 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
117 TRACE("(%p)\n", iface
);
121 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
123 TRACE("(%p)\n", iface
);
127 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL fLock
)
129 TRACE("(%p)->(%x)\n", iface
, fLock
);
133 static const IClassFactoryVtbl WshShellFactoryVtbl
= {
134 ClassFactory_QueryInterface
,
136 ClassFactory_Release
,
137 WshShellFactory_CreateInstance
,
138 ClassFactory_LockServer
141 static IClassFactory WshShellFactory
= { &WshShellFactoryVtbl
};
143 /******************************************************************
144 * DllMain (wshom.ocx.@)
146 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
148 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpv
);
152 case DLL_WINE_PREATTACH
:
153 return FALSE
; /* prefer native version */
154 case DLL_PROCESS_ATTACH
:
155 wshom_instance
= hInstDLL
;
156 DisableThreadLibraryCalls(wshom_instance
);
158 case DLL_PROCESS_DETACH
:
167 /***********************************************************************
168 * DllGetClassObject (wshom.ocx.@)
170 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
172 if(IsEqualGUID(&CLSID_WshShell
, rclsid
)) {
173 TRACE("(CLSID_WshShell %s %p)\n", debugstr_guid(riid
), ppv
);
174 return IClassFactory_QueryInterface(&WshShellFactory
, riid
, ppv
);
177 FIXME("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
178 return CLASS_E_CLASSNOTAVAILABLE
;
181 /***********************************************************************
182 * DllCanUnloadNow (wshom.ocx.@)
184 HRESULT WINAPI
DllCanUnloadNow(void)
189 /***********************************************************************
190 * DllRegisterServer (wshom.ocx.@)
192 HRESULT WINAPI
DllRegisterServer(void)
195 return __wine_register_resources(wshom_instance
);
198 /***********************************************************************
199 * DllUnregisterServer (wshom.ocx.@)
201 HRESULT WINAPI
DllUnregisterServer(void)
204 return __wine_unregister_resources(wshom_instance
);