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
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(ieframe
);
30 HINSTANCE ieframe_instance
;
32 const char *debugstr_variant(const VARIANT
*v
)
43 return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v
));
45 return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v
));
47 return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v
)));
49 return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v
));
51 return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v
));
53 return wine_dbg_sprintf("{vt %d}", V_VT(v
));
57 static ITypeLib
*typelib
;
58 static ITypeInfo
*typeinfos
[LAST_tid
];
60 static REFIID tid_ids
[] = {
61 #define XIID(iface) &IID_ ## iface,
62 #define XCLSID(class) &CLSID_ ## class,
68 static HRESULT
load_typelib(void)
73 hres
= LoadRegTypeLib(&LIBID_SHDocVw
, 1, 1, LOCALE_SYSTEM_DEFAULT
, &tl
);
75 ERR("LoadRegTypeLib failed: %08x\n", hres
);
79 if(InterlockedCompareExchangePointer((void**)&typelib
, tl
, NULL
))
84 HRESULT
get_typeinfo(tid_t tid
, ITypeInfo
**typeinfo
)
89 hres
= load_typelib();
96 hres
= ITypeLib_GetTypeInfoOfGuid(typelib
, tid_ids
[tid
], &ti
);
98 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids
[tid
]), hres
);
102 if(InterlockedCompareExchangePointer((void**)(typeinfos
+tid
), ti
, NULL
))
103 ITypeInfo_Release(ti
);
106 *typeinfo
= typeinfos
[tid
];
110 static void release_typelib(void)
117 for(i
=0; i
< sizeof(typeinfos
)/sizeof(*typeinfos
); i
++) {
119 ITypeInfo_Release(typeinfos
[i
]);
122 ITypeLib_Release(typelib
);
125 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
129 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
130 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
132 }else if(IsEqualGUID(&IID_IClassFactory
, riid
)) {
133 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
138 IUnknown_AddRef((IUnknown
*)*ppv
);
142 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
143 return E_NOINTERFACE
;
146 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
148 TRACE("(%p)\n", iface
);
152 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
154 TRACE("(%p)\n", iface
);
158 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL fLock
)
160 TRACE("(%p)->(%x)\n", iface
, fLock
);
164 static const IClassFactoryVtbl WebBrowserFactoryVtbl
= {
165 ClassFactory_QueryInterface
,
167 ClassFactory_Release
,
169 ClassFactory_LockServer
172 static IClassFactory WebBrowserFactory
= { &WebBrowserFactoryVtbl
};
174 static const IClassFactoryVtbl WebBrowserV1FactoryVtbl
= {
175 ClassFactory_QueryInterface
,
177 ClassFactory_Release
,
179 ClassFactory_LockServer
182 static IClassFactory WebBrowserV1Factory
= { &WebBrowserV1FactoryVtbl
};
184 static const IClassFactoryVtbl InternetShortcutFactoryVtbl
= {
185 ClassFactory_QueryInterface
,
187 ClassFactory_Release
,
188 InternetShortcut_Create
,
189 ClassFactory_LockServer
192 static IClassFactory InternetShortcutFactory
= { &InternetShortcutFactoryVtbl
};
194 static const IClassFactoryVtbl CUrlHistoryFactoryVtbl
= {
195 ClassFactory_QueryInterface
,
197 ClassFactory_Release
,
199 ClassFactory_LockServer
202 static IClassFactory CUrlHistoryFactory
= { &CUrlHistoryFactoryVtbl
};
204 /******************************************************************
205 * DllMain (ieframe.@)
207 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
209 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpv
);
213 case DLL_WINE_PREATTACH
:
214 return FALSE
; /* prefer native version */
215 case DLL_PROCESS_ATTACH
:
216 ieframe_instance
= hInstDLL
;
217 register_iewindow_class();
218 DisableThreadLibraryCalls(ieframe_instance
);
220 case DLL_PROCESS_DETACH
:
221 unregister_iewindow_class();
228 /***********************************************************************
229 * DllGetClassObject (ieframe.@)
231 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
233 if(IsEqualGUID(&CLSID_WebBrowser
, rclsid
)) {
234 TRACE("(CLSID_WebBrowser %s %p)\n", debugstr_guid(riid
), ppv
);
235 return IClassFactory_QueryInterface(&WebBrowserFactory
, riid
, ppv
);
238 if(IsEqualGUID(&CLSID_WebBrowser_V1
, rclsid
)) {
239 TRACE("(CLSID_WebBrowser_V1 %s %p)\n", debugstr_guid(riid
), ppv
);
240 return IClassFactory_QueryInterface(&WebBrowserV1Factory
, riid
, ppv
);
243 if(IsEqualGUID(rclsid
, &CLSID_InternetShortcut
)) {
244 TRACE("(CLSID_InternetShortcut %s %p)\n", debugstr_guid(riid
), ppv
);
245 return IClassFactory_QueryInterface(&InternetShortcutFactory
, riid
, ppv
);
248 if(IsEqualGUID(&CLSID_CUrlHistory
, rclsid
)) {
249 TRACE("(CLSID_CUrlHistory %s %p)\n", debugstr_guid(riid
), ppv
);
250 return IClassFactory_QueryInterface(&CUrlHistoryFactory
, riid
, ppv
);
253 FIXME("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
254 return CLASS_E_CLASSNOTAVAILABLE
;
257 static const IClassFactoryVtbl InternetExplorerFactoryVtbl
= {
258 ClassFactory_QueryInterface
,
260 ClassFactory_Release
,
261 InternetExplorer_Create
,
262 ClassFactory_LockServer
265 static IClassFactory InternetExplorerFactory
= { &InternetExplorerFactoryVtbl
};
267 HRESULT
register_class_object(BOOL do_reg
)
274 hres
= CoRegisterClassObject(&CLSID_InternetExplorer
,
275 (IUnknown
*)&InternetExplorerFactory
, CLSCTX_SERVER
,
276 REGCLS_MULTIPLEUSE
|REGCLS_SUSPENDED
, &cookie
);
278 ERR("failed to register object %08x\n", hres
);
282 hres
= CoResumeClassObjects();
286 ERR("failed to resume object %08x\n", hres
);
289 return CoRevokeClassObject(cookie
);
292 /***********************************************************************
293 * DllCanUnloadNow (ieframe.@)
295 HRESULT WINAPI
DllCanUnloadNow(void)
298 return module_ref
? S_FALSE
: S_OK
;
301 /***********************************************************************
302 * DllRegisterServer (ieframe.@)
304 HRESULT WINAPI
DllRegisterServer(void)
307 return __wine_register_resources(ieframe_instance
);
310 /***********************************************************************
311 * DllUnregisterServer (ieframe.@)
313 HRESULT WINAPI
DllUnregisterServer(void)
316 return __wine_unregister_resources(ieframe_instance
);
319 /***********************************************************************
320 * IEGetWriteableHKCU (ieframe.@)
322 HRESULT WINAPI
IEGetWriteableHKCU(HKEY
*pkey
)
324 FIXME("(%p) stub\n", pkey
);