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
26 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw
);
39 LONG SHDOCVW_refCount
= 0;
41 static HMODULE SHDOCVW_hshell32
= 0;
42 static HINSTANCE ieframe_instance
;
44 static HINSTANCE
get_ieframe_instance(void)
47 ieframe_instance
= LoadLibraryW(L
"ieframe.dll");
49 return ieframe_instance
;
52 static HRESULT
get_ieframe_object(REFCLSID rclsid
, REFIID riid
, void **ppv
)
54 HINSTANCE ieframe_instance
;
56 static HRESULT (WINAPI
*ieframe_DllGetClassObject
)(REFCLSID
,REFIID
,void**);
58 if(!ieframe_DllGetClassObject
) {
59 ieframe_instance
= get_ieframe_instance();
61 return CLASS_E_CLASSNOTAVAILABLE
;
63 ieframe_DllGetClassObject
= (void*)GetProcAddress(ieframe_instance
, "DllGetClassObject");
64 if(!ieframe_DllGetClassObject
)
65 return CLASS_E_CLASSNOTAVAILABLE
;
68 return ieframe_DllGetClassObject(rclsid
, riid
, ppv
);
71 /*************************************************************************
72 * DllGetClassObject (SHDOCVW.@)
74 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, void **ppv
)
76 TRACE("(%s %s %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
78 if(IsEqualGUID(&CLSID_WebBrowser
, rclsid
)
79 || IsEqualGUID(&CLSID_WebBrowser_V1
, rclsid
)
80 || IsEqualGUID(&CLSID_InternetShortcut
, rclsid
)
81 || IsEqualGUID(&CLSID_CUrlHistory
, rclsid
)
82 || IsEqualGUID(&CLSID_TaskbarList
, rclsid
))
83 return get_ieframe_object(rclsid
, riid
, ppv
);
85 /* As a last resort, figure if the CLSID belongs to a 'Shell Instance Object' */
86 return SHDOCVW_GetShellInstanceObjectClassObject(rclsid
, riid
, ppv
);
89 /******************************************************************
90 * IEWinMain (SHDOCVW.101)
92 * Only returns on error.
94 DWORD WINAPI
IEWinMain(LPSTR szCommandLine
, int nShowWindow
)
96 DWORD (WINAPI
*pIEWinMain
)(const WCHAR
*,int);
100 TRACE("%s %d\n", debugstr_a(szCommandLine
), nShowWindow
);
102 pIEWinMain
= (void*)GetProcAddress(get_ieframe_instance(), MAKEINTRESOURCEA(101));
106 len
= MultiByteToWideChar(CP_ACP
, 0, szCommandLine
, -1, NULL
, 0);
107 cmdline
= heap_alloc(len
*sizeof(WCHAR
));
110 MultiByteToWideChar(CP_ACP
, 0, szCommandLine
, -1, cmdline
, len
);
112 ret
= pIEWinMain(cmdline
, nShowWindow
);
118 /*************************************************************************
121 BOOL WINAPI
DllMain(HINSTANCE hinst
, DWORD fdwReason
, LPVOID fImpLoad
)
123 TRACE("%p 0x%x %p\n", hinst
, fdwReason
, fImpLoad
);
126 case DLL_PROCESS_ATTACH
:
127 DisableThreadLibraryCalls(hinst
);
129 case DLL_PROCESS_DETACH
:
131 if (SHDOCVW_hshell32
) FreeLibrary(SHDOCVW_hshell32
);
132 if (ieframe_instance
) FreeLibrary(ieframe_instance
);
138 /*************************************************************************
139 * DllCanUnloadNow (SHDOCVW.@)
141 HRESULT WINAPI
DllCanUnloadNow(void)
143 return SHDOCVW_refCount
? S_FALSE
: S_OK
;
146 /***********************************************************************
147 * DllGetVersion (SHDOCVW.@)
149 HRESULT WINAPI
DllGetVersion(DLLVERSIONINFO
*info
)
151 if (info
->cbSize
!= sizeof(DLLVERSIONINFO
)) FIXME("support DLLVERSIONINFO2\n");
153 /* this is what IE6 on Windows 98 reports */
154 info
->dwMajorVersion
= 6;
155 info
->dwMinorVersion
= 0;
156 info
->dwBuildNumber
= 2600;
157 info
->dwPlatformID
= DLLVER_PLATFORM_WINDOWS
;
162 /*************************************************************************
163 * DllInstall (SHDOCVW.@)
165 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
167 FIXME("(%s, %s): stub!\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
172 /*************************************************************************
173 * SHDOCVW_LoadShell32
175 * makes sure the handle to shell32 is valid
177 static BOOL
SHDOCVW_LoadShell32(void)
179 if (SHDOCVW_hshell32
)
181 return ((SHDOCVW_hshell32
= LoadLibraryA("shell32.dll")) != NULL
);
184 /***********************************************************************
187 * Called by Win98 explorer.exe main binary, definitely has 0
190 DWORD WINAPI
WinList_Init(void)
192 FIXME("(), stub!\n");
196 /***********************************************************************
199 * Called by Win98 explorer.exe main binary, definitely has only one
202 static BOOL (WINAPI
*pShellDDEInit
)(BOOL start
) = NULL
;
204 BOOL WINAPI
ShellDDEInit(BOOL start
)
206 TRACE("(%d)\n", start
);
210 if (!SHDOCVW_LoadShell32())
212 pShellDDEInit
= (void *)GetProcAddress(SHDOCVW_hshell32
, (LPCSTR
)188);
216 return pShellDDEInit(start
);
221 /***********************************************************************
224 * Called by Win98 explorer.exe main binary, definitely has 0
227 DWORD WINAPI
RunInstallUninstallStubs(void)
229 FIXME("(), stub!\n");
233 /***********************************************************************
236 * Called by Emerge Desktop (alternative Windows Shell).
238 DWORD WINAPI
RunInstallUninstallStubs2(int arg
)
240 FIXME("(%d), stub!\n", arg
);
244 /***********************************************************************
245 * SetQueryNetSessionCount (SHDOCVW.@)
247 DWORD WINAPI
SetQueryNetSessionCount(DWORD arg
)
249 FIXME("(%u), stub!\n", arg
);
253 /**********************************************************************
254 * Some forwards (by ordinal) to SHLWAPI
257 static void* fetch_shlwapi_ordinal(UINT_PTR ord
)
261 if (!h
&& !(h
= GetModuleHandleW(L
"shlwapi.dll"))) return NULL
;
262 return (void*)GetProcAddress(h
, (const char*)ord
);
265 /******************************************************************
266 * StopWatchModeFORWARD (SHDOCVW.@)
268 void WINAPI
StopWatchModeFORWARD(void)
270 static void (WINAPI
*p
)(void);
272 if (p
|| (p
= fetch_shlwapi_ordinal(241))) p();
275 /******************************************************************
276 * StopWatchFlushFORWARD (SHDOCVW.@)
278 void WINAPI
StopWatchFlushFORWARD(void)
280 static void (WINAPI
*p
)(void);
282 if (p
|| (p
= fetch_shlwapi_ordinal(242))) p();
285 /******************************************************************
286 * StopWatchAFORWARD (SHDOCVW.@)
288 DWORD WINAPI
StopWatchAFORWARD(DWORD dwClass
, LPCSTR lpszStr
, DWORD dwUnknown
,
289 DWORD dwMode
, DWORD dwTimeStamp
)
291 static DWORD (WINAPI
*p
)(DWORD
, LPCSTR
, DWORD
, DWORD
, DWORD
);
293 if (p
|| (p
= fetch_shlwapi_ordinal(243)))
294 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
295 return ERROR_CALL_NOT_IMPLEMENTED
;
298 /******************************************************************
299 * StopWatchWFORWARD (SHDOCVW.@)
301 DWORD WINAPI
StopWatchWFORWARD(DWORD dwClass
, LPCWSTR lpszStr
, DWORD dwUnknown
,
302 DWORD dwMode
, DWORD dwTimeStamp
)
304 static DWORD (WINAPI
*p
)(DWORD
, LPCWSTR
, DWORD
, DWORD
, DWORD
);
306 if (p
|| (p
= fetch_shlwapi_ordinal(244)))
307 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
308 return ERROR_CALL_NOT_IMPLEMENTED
;
311 /******************************************************************
312 * URLSubRegQueryA (SHDOCVW.151)
314 HRESULT WINAPI
URLSubRegQueryA(LPCSTR regpath
, LPCSTR name
, DWORD type
,
315 LPSTR out
, DWORD outlen
, DWORD unknown
)
317 CHAR buffer
[INTERNET_MAX_URL_LENGTH
];
321 TRACE("(%s, %s, %d, %p, %d, %d)\n", debugstr_a(regpath
), debugstr_a(name
),
322 type
, out
, outlen
, unknown
);
324 if (!out
) return S_OK
;
326 len
= sizeof(buffer
);
327 res
= SHRegGetUSValueA(regpath
, name
, NULL
, buffer
, &len
, FALSE
, NULL
, 0);
329 lstrcpynA(out
, buffer
, outlen
);
336 /******************************************************************
337 * ParseURLFromOutsideSourceW (SHDOCVW.170)
339 DWORD WINAPI
ParseURLFromOutsideSourceW(LPCWSTR url
, LPWSTR out
, LPDWORD plen
, LPDWORD unknown
)
341 WCHAR buffer_in
[INTERNET_MAX_URL_LENGTH
];
342 WCHAR buffer_out
[INTERNET_MAX_URL_LENGTH
];
350 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_w(url
), out
, plen
, unknown
,
351 plen
? *plen
: 0, unknown
? *unknown
: 0);
353 if (!PathIsURLW(ptr
)) {
354 len
= ARRAY_SIZE(buffer_in
);
356 hr
= UrlApplySchemeW(ptr
, buffer_in
, &len
, URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
);
357 TRACE("got 0x%x with %s\n", hr
, debugstr_w(buffer_in
));
359 /* we parsed the url to buffer_in */
364 FIXME("call search hook for %s\n", debugstr_w(ptr
));
368 len
= ARRAY_SIZE(buffer_out
);
369 buffer_out
[0] = '\0';
370 hr
= UrlCanonicalizeW(ptr
, buffer_out
, &len
, URL_ESCAPE_SPACES_ONLY
);
371 needed
= lstrlenW(buffer_out
)+1;
372 TRACE("got 0x%x with %s (need %d)\n", hr
, debugstr_w(buffer_out
), needed
);
374 if (*plen
>= needed
) {
376 lstrcpyW(out
, buffer_out
);
384 TRACE("=> %d\n", res
);
388 /******************************************************************
389 * ParseURLFromOutsideSourceA (SHDOCVW.169)
391 * See ParseURLFromOutsideSourceW
393 DWORD WINAPI
ParseURLFromOutsideSourceA(LPCSTR url
, LPSTR out
, LPDWORD plen
, LPDWORD unknown
)
395 WCHAR buffer
[INTERNET_MAX_URL_LENGTH
];
401 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_a(url
), out
, plen
, unknown
,
402 plen
? *plen
: 0, unknown
? *unknown
: 0);
405 len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
406 urlW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
407 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
410 len
= ARRAY_SIZE(buffer
);
411 ParseURLFromOutsideSourceW(urlW
, buffer
, &len
, unknown
);
412 HeapFree(GetProcessHeap(), 0, urlW
);
414 needed
= WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, NULL
, 0, NULL
, NULL
);
417 if (*plen
>= needed
) {
419 WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, out
, *plen
, NULL
, NULL
);
427 TRACE("=> %d\n", res
);
431 /******************************************************************
432 * IEParseDisplayNameWithBCW (SHDOCVW.218)
434 HRESULT WINAPI
IEParseDisplayNameWithBCW(DWORD codepage
, LPCWSTR lpszDisplayName
, LPBC pbc
, LPITEMIDLIST
*ppidl
)
436 /* Guessing at parameter 3 based on IShellFolder's ParseDisplayName */
437 FIXME("stub: 0x%x %s %p %p\n",codepage
,debugstr_w(lpszDisplayName
),pbc
,ppidl
);
441 /******************************************************************
442 * SHRestricted2W (SHDOCVW.159)
444 DWORD WINAPI
SHRestricted2W(DWORD res
, LPCWSTR url
, DWORD reserved
)
446 FIXME("(%d %s %d) stub\n", res
, debugstr_w(url
), reserved
);
450 /******************************************************************
451 * SHRestricted2A (SHDOCVW.158)
455 DWORD WINAPI
SHRestricted2A(DWORD restriction
, LPCSTR url
, DWORD reserved
)
460 TRACE("(%d, %s, %d)\n", restriction
, debugstr_a(url
), reserved
);
462 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
463 urlW
= heap_alloc(len
* sizeof(WCHAR
));
464 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
466 res
= SHRestricted2W(restriction
, urlW
, reserved
);
471 /******************************************************************
472 * ImportPrivacySettings (SHDOCVW.@)
474 * Import global and/or per site privacy preferences from an xml file
477 * filename [I] XML file to use
478 * pGlobalPrefs [IO] PTR to a usage flag for the global privacy preferences
479 * pPerSitePrefs [IO] PTR to a usage flag for the per site privacy preferences
482 * Success: TRUE (the privacy preferences where updated)
483 * Failure: FALSE (the privacy preferences are unchanged)
486 * Set the flag to TRUE, when the related privacy preferences in the xml file
487 * should be used (parsed and overwrite the current settings).
488 * On return, the flag is TRUE, when the related privacy settings where used
491 BOOL WINAPI
ImportPrivacySettings(LPCWSTR filename
, BOOL
*pGlobalPrefs
, BOOL
* pPerSitePrefs
)
493 FIXME("(%s, %p->%d, %p->%d): stub\n", debugstr_w(filename
),
494 pGlobalPrefs
, pGlobalPrefs
? *pGlobalPrefs
: 0,
495 pPerSitePrefs
, pPerSitePrefs
? *pPerSitePrefs
: 0);
497 if (pGlobalPrefs
) *pGlobalPrefs
= FALSE
;
498 if (pPerSitePrefs
) *pPerSitePrefs
= FALSE
;
503 /******************************************************************
504 * ResetProfileSharing (SHDOCVW.164)
506 HRESULT WINAPI
ResetProfileSharing(HWND hwnd
)
508 FIXME("(%p) stub\n", hwnd
);
512 /******************************************************************
513 * InstallReg_RunDLL (SHDOCVW.@)
515 void WINAPI
InstallReg_RunDLL(HWND hwnd
, HINSTANCE handle
, LPCSTR cmdline
, INT show
)
517 FIXME("(%p %p %s %x)\n", hwnd
, handle
, debugstr_a(cmdline
), show
);
520 /******************************************************************
521 * DoFileDownload (SHDOCVW.@)
523 BOOL WINAPI
DoFileDownload(LPWSTR filename
)
525 FIXME("(%s) stub\n", debugstr_w(filename
));
529 /******************************************************************
530 * DoOrganizeFavDlgW (SHDOCVW.@)
532 BOOL WINAPI
DoOrganizeFavDlgW(HWND hwnd
, LPCWSTR initDir
)
534 FIXME("(%p %s) stub\n", hwnd
, debugstr_w(initDir
));
538 /******************************************************************
539 * DoOrganizeFavDlg (SHDOCVW.@)
541 BOOL WINAPI
DoOrganizeFavDlg(HWND hwnd
, LPCSTR initDir
)
543 LPWSTR initDirW
= NULL
;
546 TRACE("(%p %s)\n", hwnd
, debugstr_a(initDir
));
549 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, initDir
, -1, NULL
, 0);
550 initDirW
= heap_alloc(len
* sizeof(WCHAR
));
551 MultiByteToWideChar(CP_ACP
, 0, initDir
, -1, initDirW
, len
);
553 res
= DoOrganizeFavDlgW(hwnd
, initDirW
);