2 * SHDOCVW - Internet Explorer Web Control
4 * Copyright 2001 John R. Sheets (for CodeWeavers)
5 * Copyright 2004 Mike McCormack (for CodeWeavers)
6 * Copyright 2008 Detlef Riekenberg
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/unicode.h"
29 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
41 LONG SHDOCVW_refCount = 0;
43 HINSTANCE shdocvw_hinstance = 0;
44 static HMODULE SHDOCVW_hshell32 = 0;
45 static ITypeInfo *wb_typeinfo = NULL;
47 HRESULT get_typeinfo(ITypeInfo **typeinfo)
53 *typeinfo = wb_typeinfo;
57 hres = LoadRegTypeLib(&LIBID_SHDocVw, 1, 1, LOCALE_SYSTEM_DEFAULT, &typelib);
59 ERR("LoadRegTypeLib failed: %08x\n", hres);
63 hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IWebBrowser2, &wb_typeinfo);
64 ITypeLib_Release(typelib);
66 *typeinfo = wb_typeinfo;
70 const char *debugstr_variant(const VARIANT *v)
81 return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v));
83 return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v));
85 return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v)));
87 return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v));
89 return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v));
91 return wine_dbg_sprintf("{vt %d}", V_VT(v));
95 /*************************************************************************
98 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
100 TRACE("%p 0x%x %p\n", hinst, fdwReason, fImpLoad);
103 case DLL_PROCESS_ATTACH:
104 shdocvw_hinstance = hinst;
105 register_iewindow_class();
107 case DLL_PROCESS_DETACH:
108 if (SHDOCVW_hshell32) FreeLibrary(SHDOCVW_hshell32);
109 unregister_iewindow_class();
111 ITypeInfo_Release(wb_typeinfo);
117 /*************************************************************************
118 * DllCanUnloadNow (SHDOCVW.@)
120 HRESULT WINAPI DllCanUnloadNow(void)
122 return SHDOCVW_refCount ? S_FALSE : S_OK;
125 /***********************************************************************
126 * DllGetVersion (SHDOCVW.@)
128 HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *info)
130 if (info->cbSize != sizeof(DLLVERSIONINFO)) FIXME("support DLLVERSIONINFO2\n");
132 /* this is what IE6 on Windows 98 reports */
133 info->dwMajorVersion = 6;
134 info->dwMinorVersion = 0;
135 info->dwBuildNumber = 2600;
136 info->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
141 /*************************************************************************
142 * DllInstall (SHDOCVW.@)
144 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
146 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
151 /*************************************************************************
152 * SHDOCVW_LoadShell32
154 * makes sure the handle to shell32 is valid
156 static BOOL SHDOCVW_LoadShell32(void)
158 if (SHDOCVW_hshell32)
160 return ((SHDOCVW_hshell32 = LoadLibraryA("shell32.dll")) != NULL);
163 /***********************************************************************
166 * Called by Win98 explorer.exe main binary, definitely has 0
169 DWORD WINAPI WinList_Init(void)
171 FIXME("(), stub!\n");
175 /***********************************************************************
178 * Called by Win98 explorer.exe main binary, definitely has only one
181 static BOOL (WINAPI *pShellDDEInit)(BOOL start) = NULL;
183 BOOL WINAPI ShellDDEInit(BOOL start)
185 TRACE("(%d)\n", start);
189 if (!SHDOCVW_LoadShell32())
191 pShellDDEInit = (void *)GetProcAddress(SHDOCVW_hshell32, (LPCSTR)188);
195 return pShellDDEInit(start);
200 /***********************************************************************
203 * Called by Win98 explorer.exe main binary, definitely has 0
206 DWORD WINAPI RunInstallUninstallStubs(void)
208 FIXME("(), stub!\n");
212 /***********************************************************************
213 * SetQueryNetSessionCount (SHDOCVW.@)
215 DWORD WINAPI SetQueryNetSessionCount(DWORD arg)
217 FIXME("(%u), stub!\n", arg);
221 /**********************************************************************
222 * OpenURL (SHDOCVW.@)
224 void WINAPI OpenURL(HWND hWnd, HINSTANCE hInst, LPCSTR lpcstrUrl, int nShowCmd)
226 FIXME("%p %p %s %d\n", hWnd, hInst, debugstr_a(lpcstrUrl), nShowCmd);
229 /**********************************************************************
230 * Some forwards (by ordinal) to SHLWAPI
233 static void* fetch_shlwapi_ordinal(UINT_PTR ord)
235 static const WCHAR shlwapiW[] = {'s','h','l','w','a','p','i','.','d','l','l','\0'};
238 if (!h && !(h = GetModuleHandleW(shlwapiW))) return NULL;
239 return (void*)GetProcAddress(h, (const char*)ord);
242 /******************************************************************
243 * WhichPlatformFORWARD (SHDOCVW.@)
245 DWORD WINAPI WhichPlatformFORWARD(void)
247 static DWORD (WINAPI *p)(void);
249 if (p || (p = fetch_shlwapi_ordinal(276))) return p();
250 return 1; /* not integrated, see shlwapi.WhichPlatform */
253 /******************************************************************
254 * StopWatchModeFORWARD (SHDOCVW.@)
256 void WINAPI StopWatchModeFORWARD(void)
258 static void (WINAPI *p)(void);
260 if (p || (p = fetch_shlwapi_ordinal(241))) p();
263 /******************************************************************
264 * StopWatchFlushFORWARD (SHDOCVW.@)
266 void WINAPI StopWatchFlushFORWARD(void)
268 static void (WINAPI *p)(void);
270 if (p || (p = fetch_shlwapi_ordinal(242))) p();
273 /******************************************************************
274 * StopWatchWFORWARD (SHDOCVW.@)
276 DWORD WINAPI StopWatchWFORWARD(DWORD dwClass, LPCWSTR lpszStr, DWORD dwUnknown,
277 DWORD dwMode, DWORD dwTimeStamp)
279 static DWORD (WINAPI *p)(DWORD, LPCWSTR, DWORD, DWORD, DWORD);
281 if (p || (p = fetch_shlwapi_ordinal(243)))
282 return p(dwClass, lpszStr, dwUnknown, dwMode, dwTimeStamp);
283 return ERROR_CALL_NOT_IMPLEMENTED;
286 /******************************************************************
287 * StopWatchAFORWARD (SHDOCVW.@)
289 DWORD WINAPI StopWatchAFORWARD(DWORD dwClass, LPCSTR lpszStr, DWORD dwUnknown,
290 DWORD dwMode, DWORD dwTimeStamp)
292 static DWORD (WINAPI *p)(DWORD, LPCSTR, DWORD, DWORD, DWORD);
294 if (p || (p = fetch_shlwapi_ordinal(244)))
295 return p(dwClass, lpszStr, dwUnknown, dwMode, dwTimeStamp);
296 return ERROR_CALL_NOT_IMPLEMENTED;
299 /******************************************************************
300 * URLSubRegQueryA (SHDOCVW.151)
302 HRESULT WINAPI URLSubRegQueryA(LPCSTR regpath, LPCSTR name, DWORD type,
303 LPSTR out, DWORD outlen, DWORD unknown)
305 CHAR buffer[INTERNET_MAX_URL_LENGTH];
309 TRACE("(%s, %s, %d, %p, %d, %d)\n", debugstr_a(regpath), debugstr_a(name),
310 type, out, outlen, unknown);
312 if (!out) return S_OK;
314 len = sizeof(buffer);
315 res = SHRegGetUSValueA(regpath, name, NULL, buffer, &len, FALSE, NULL, 0);
317 lstrcpynA(out, buffer, outlen);
324 /******************************************************************
325 * ParseURLFromOutsideSourceW (SHDOCVW.170)
327 DWORD WINAPI ParseURLFromOutsideSourceW(LPCWSTR url, LPWSTR out, LPDWORD plen, LPDWORD unknown)
329 WCHAR buffer_in[INTERNET_MAX_URL_LENGTH];
330 WCHAR buffer_out[INTERNET_MAX_URL_LENGTH];
338 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_w(url), out, plen, unknown,
339 plen ? *plen : 0, unknown ? *unknown : 0);
341 if (!PathIsURLW(ptr)) {
342 len = sizeof(buffer_in) / sizeof(buffer_in[0]);
344 hr = UrlApplySchemeW(ptr, buffer_in, &len, URL_APPLY_GUESSSCHEME);
345 TRACE("got 0x%x with %s\n", hr, debugstr_w(buffer_in));
347 /* when we can't guess the scheme, use the default scheme */
348 len = sizeof(buffer_in) / sizeof(buffer_in[0]);
349 hr = UrlApplySchemeW(ptr, buffer_in, &len, URL_APPLY_DEFAULT);
353 /* we parsed the url to buffer_in */
358 FIXME("call search hook for %s\n", debugstr_w(ptr));
362 len = sizeof(buffer_out) / sizeof(buffer_out[0]);
363 buffer_out[0] = '\0';
364 hr = UrlCanonicalizeW(ptr, buffer_out, &len, URL_ESCAPE_SPACES_ONLY);
365 needed = lstrlenW(buffer_out)+1;
366 TRACE("got 0x%x with %s (need %d)\n", hr, debugstr_w(buffer_out), needed);
368 if (*plen >= needed) {
370 lstrcpyW(out, buffer_out);
378 TRACE("=> %d\n", res);
382 /******************************************************************
383 * ParseURLFromOutsideSourceA (SHDOCVW.169)
385 * See ParseURLFromOutsideSourceW
387 DWORD WINAPI ParseURLFromOutsideSourceA(LPCSTR url, LPSTR out, LPDWORD plen, LPDWORD unknown)
389 WCHAR buffer[INTERNET_MAX_URL_LENGTH];
395 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_a(url), out, plen, unknown,
396 plen ? *plen : 0, unknown ? *unknown : 0);
399 len = MultiByteToWideChar(CP_ACP, 0, url, -1, NULL, 0);
400 urlW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
401 MultiByteToWideChar(CP_ACP, 0, url, -1, urlW, len);
404 len = sizeof(buffer) / sizeof(buffer[0]);
405 res = ParseURLFromOutsideSourceW(urlW, buffer, &len, unknown);
406 HeapFree(GetProcessHeap(), 0, urlW);
408 needed = WideCharToMultiByte(CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL);
411 if (*plen >= needed) {
413 WideCharToMultiByte(CP_ACP, 0, buffer, -1, out, *plen, NULL, NULL);
421 TRACE("=> %d\n", res);
425 /******************************************************************
426 * IEParseDisplayNameWithBCW (SHDOCVW.218)
428 HRESULT WINAPI IEParseDisplayNameWithBCW(DWORD codepage, LPCWSTR lpszDisplayName, LPBC pbc, LPITEMIDLIST *ppidl)
430 /* Guessing at parameter 3 based on IShellFolder's ParseDisplayName */
431 FIXME("stub: 0x%x %s %p %p\n",codepage,debugstr_w(lpszDisplayName),pbc,ppidl);
435 /******************************************************************
436 * SHRestricted2W (SHDOCVW.159)
438 DWORD WINAPI SHRestricted2W(DWORD res, LPCWSTR url, DWORD reserved)
440 FIXME("(%d %s %d) stub\n", res, debugstr_w(url), reserved);
444 /******************************************************************
445 * SHRestricted2A (SHDOCVW.158)
449 DWORD WINAPI SHRestricted2A(DWORD restriction, LPCSTR url, DWORD reserved)
454 TRACE("(%d, %s, %d)\n", restriction, debugstr_a(url), reserved);
456 DWORD len = MultiByteToWideChar(CP_ACP, 0, url, -1, NULL, 0);
457 urlW = heap_alloc(len * sizeof(WCHAR));
458 MultiByteToWideChar(CP_ACP, 0, url, -1, urlW, len);
460 res = SHRestricted2W(restriction, urlW, reserved);