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"
40 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw
);
42 LONG SHDOCVW_refCount
= 0;
44 static HMODULE SHDOCVW_hshell32
= 0;
45 static HINSTANCE ieframe_instance
;
47 static HINSTANCE
get_ieframe_instance(void)
49 static const WCHAR ieframe_dllW
[] = {'i','e','f','r','a','m','e','.','d','l','l',0};
52 ieframe_instance
= LoadLibraryW(ieframe_dllW
);
54 return ieframe_instance
;
57 static HRESULT
get_ieframe_object(REFCLSID rclsid
, REFIID riid
, void **ppv
)
59 HINSTANCE ieframe_instance
;
61 static HRESULT (WINAPI
*ieframe_DllGetClassObject
)(REFCLSID
,REFIID
,void**);
63 if(!ieframe_DllGetClassObject
) {
64 ieframe_instance
= get_ieframe_instance();
66 return CLASS_E_CLASSNOTAVAILABLE
;
68 ieframe_DllGetClassObject
= (void*)GetProcAddress(ieframe_instance
, "DllGetClassObject");
69 if(!ieframe_DllGetClassObject
)
70 return CLASS_E_CLASSNOTAVAILABLE
;
73 return ieframe_DllGetClassObject(rclsid
, riid
, ppv
);
76 /*************************************************************************
77 * DllGetClassObject (SHDOCVW.@)
79 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, void **ppv
)
83 if(IsEqualGUID(&CLSID_WebBrowser
, rclsid
)
84 || IsEqualGUID(&CLSID_WebBrowser_V1
, rclsid
)
85 || IsEqualGUID(&CLSID_InternetShortcut
, rclsid
)
86 || IsEqualGUID(&CLSID_CUrlHistory
, rclsid
)
87 || IsEqualGUID(&CLSID_TaskbarList
, rclsid
))
88 return get_ieframe_object(rclsid
, riid
, ppv
);
90 /* As a last resort, figure if the CLSID belongs to a 'Shell Instance Object' */
91 return SHDOCVW_GetShellInstanceObjectClassObject(rclsid
, riid
, ppv
);
94 /***********************************************************************
95 * DllRegisterServer (shdocvw.@)
97 HRESULT WINAPI
DllRegisterServer(void)
103 /***********************************************************************
104 * DllUnregisterServer (shdocvw.@)
106 HRESULT WINAPI
DllUnregisterServer(void)
112 /******************************************************************
113 * IEWinMain (SHDOCVW.101)
115 * Only returns on error.
117 DWORD WINAPI
IEWinMain(LPSTR szCommandLine
, int nShowWindow
)
119 DWORD (WINAPI
*pIEWinMain
)(const WCHAR
*,int);
123 TRACE("%s %d\n", debugstr_a(szCommandLine
), nShowWindow
);
125 pIEWinMain
= (void*)GetProcAddress(get_ieframe_instance(), MAKEINTRESOURCEA(101));
129 len
= MultiByteToWideChar(CP_ACP
, 0, szCommandLine
, -1, NULL
, 0);
130 cmdline
= heap_alloc(len
*sizeof(WCHAR
));
133 MultiByteToWideChar(CP_ACP
, 0, szCommandLine
, -1, cmdline
, len
);
135 ret
= pIEWinMain(cmdline
, nShowWindow
);
141 /*************************************************************************
144 BOOL WINAPI
DllMain(HINSTANCE hinst
, DWORD fdwReason
, LPVOID fImpLoad
)
146 TRACE("%p 0x%x %p\n", hinst
, fdwReason
, fImpLoad
);
149 case DLL_PROCESS_ATTACH
:
151 case DLL_PROCESS_DETACH
:
153 if (SHDOCVW_hshell32
) FreeLibrary(SHDOCVW_hshell32
);
154 if (ieframe_instance
) FreeLibrary(ieframe_instance
);
160 /*************************************************************************
161 * DllCanUnloadNow (SHDOCVW.@)
163 HRESULT WINAPI
DllCanUnloadNow(void)
165 return SHDOCVW_refCount
? S_FALSE
: S_OK
;
168 /***********************************************************************
169 * DllGetVersion (SHDOCVW.@)
171 HRESULT WINAPI
DllGetVersion(DLLVERSIONINFO
*info
)
173 if (info
->cbSize
!= sizeof(DLLVERSIONINFO
)) FIXME("support DLLVERSIONINFO2\n");
175 /* this is what IE6 on Windows 98 reports */
176 info
->dwMajorVersion
= 6;
177 info
->dwMinorVersion
= 0;
178 info
->dwBuildNumber
= 2600;
179 info
->dwPlatformID
= DLLVER_PLATFORM_WINDOWS
;
184 /*************************************************************************
185 * DllInstall (SHDOCVW.@)
187 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
189 FIXME("(%s, %s): stub!\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
194 /*************************************************************************
195 * SHDOCVW_LoadShell32
197 * makes sure the handle to shell32 is valid
199 static BOOL
SHDOCVW_LoadShell32(void)
201 if (SHDOCVW_hshell32
)
203 return ((SHDOCVW_hshell32
= LoadLibraryA("shell32.dll")) != NULL
);
206 /***********************************************************************
209 * Called by Win98 explorer.exe main binary, definitely has 0
212 DWORD WINAPI
WinList_Init(void)
214 FIXME("(), stub!\n");
218 /***********************************************************************
221 * Called by Win98 explorer.exe main binary, definitely has only one
224 static BOOL (WINAPI
*pShellDDEInit
)(BOOL start
) = NULL
;
226 BOOL WINAPI
ShellDDEInit(BOOL start
)
228 TRACE("(%d)\n", start
);
232 if (!SHDOCVW_LoadShell32())
234 pShellDDEInit
= (void *)GetProcAddress(SHDOCVW_hshell32
, (LPCSTR
)188);
238 return pShellDDEInit(start
);
243 /***********************************************************************
246 * Called by Win98 explorer.exe main binary, definitely has 0
249 DWORD WINAPI
RunInstallUninstallStubs(void)
251 FIXME("(), stub!\n");
255 /***********************************************************************
258 * Called by Emerge Desktop (alternative Windows Shell).
260 DWORD WINAPI
RunInstallUninstallStubs2(void)
262 FIXME("(), stub!\n");
266 /***********************************************************************
267 * SetQueryNetSessionCount (SHDOCVW.@)
269 DWORD WINAPI
SetQueryNetSessionCount(DWORD arg
)
271 FIXME("(%u), stub!\n", arg
);
275 /**********************************************************************
276 * Some forwards (by ordinal) to SHLWAPI
279 static void* fetch_shlwapi_ordinal(UINT_PTR ord
)
281 static const WCHAR shlwapiW
[] = {'s','h','l','w','a','p','i','.','d','l','l','\0'};
284 if (!h
&& !(h
= GetModuleHandleW(shlwapiW
))) return NULL
;
285 return (void*)GetProcAddress(h
, (const char*)ord
);
288 /******************************************************************
289 * WhichPlatformFORWARD (SHDOCVW.@)
291 DWORD WINAPI
WhichPlatformFORWARD(void)
293 static DWORD (WINAPI
*p
)(void);
295 if (p
|| (p
= fetch_shlwapi_ordinal(276))) return p();
296 return 1; /* not integrated, see shlwapi.WhichPlatform */
299 /******************************************************************
300 * StopWatchModeFORWARD (SHDOCVW.@)
302 void WINAPI
StopWatchModeFORWARD(void)
304 static void (WINAPI
*p
)(void);
306 if (p
|| (p
= fetch_shlwapi_ordinal(241))) p();
309 /******************************************************************
310 * StopWatchFlushFORWARD (SHDOCVW.@)
312 void WINAPI
StopWatchFlushFORWARD(void)
314 static void (WINAPI
*p
)(void);
316 if (p
|| (p
= fetch_shlwapi_ordinal(242))) p();
319 /******************************************************************
320 * StopWatchWFORWARD (SHDOCVW.@)
322 DWORD WINAPI
StopWatchWFORWARD(DWORD dwClass
, LPCWSTR lpszStr
, DWORD dwUnknown
,
323 DWORD dwMode
, DWORD dwTimeStamp
)
325 static DWORD (WINAPI
*p
)(DWORD
, LPCWSTR
, DWORD
, DWORD
, DWORD
);
327 if (p
|| (p
= fetch_shlwapi_ordinal(243)))
328 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
329 return ERROR_CALL_NOT_IMPLEMENTED
;
332 /******************************************************************
333 * StopWatchAFORWARD (SHDOCVW.@)
335 DWORD WINAPI
StopWatchAFORWARD(DWORD dwClass
, LPCSTR lpszStr
, DWORD dwUnknown
,
336 DWORD dwMode
, DWORD dwTimeStamp
)
338 static DWORD (WINAPI
*p
)(DWORD
, LPCSTR
, DWORD
, DWORD
, DWORD
);
340 if (p
|| (p
= fetch_shlwapi_ordinal(244)))
341 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
342 return ERROR_CALL_NOT_IMPLEMENTED
;
345 /******************************************************************
346 * URLSubRegQueryA (SHDOCVW.151)
348 HRESULT WINAPI
URLSubRegQueryA(LPCSTR regpath
, LPCSTR name
, DWORD type
,
349 LPSTR out
, DWORD outlen
, DWORD unknown
)
351 CHAR buffer
[INTERNET_MAX_URL_LENGTH
];
355 TRACE("(%s, %s, %d, %p, %d, %d)\n", debugstr_a(regpath
), debugstr_a(name
),
356 type
, out
, outlen
, unknown
);
358 if (!out
) return S_OK
;
360 len
= sizeof(buffer
);
361 res
= SHRegGetUSValueA(regpath
, name
, NULL
, buffer
, &len
, FALSE
, NULL
, 0);
363 lstrcpynA(out
, buffer
, outlen
);
370 /******************************************************************
371 * ParseURLFromOutsideSourceW (SHDOCVW.170)
373 DWORD WINAPI
ParseURLFromOutsideSourceW(LPCWSTR url
, LPWSTR out
, LPDWORD plen
, LPDWORD unknown
)
375 WCHAR buffer_in
[INTERNET_MAX_URL_LENGTH
];
376 WCHAR buffer_out
[INTERNET_MAX_URL_LENGTH
];
384 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_w(url
), out
, plen
, unknown
,
385 plen
? *plen
: 0, unknown
? *unknown
: 0);
387 if (!PathIsURLW(ptr
)) {
388 len
= sizeof(buffer_in
) / sizeof(buffer_in
[0]);
390 hr
= UrlApplySchemeW(ptr
, buffer_in
, &len
, URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
);
391 TRACE("got 0x%x with %s\n", hr
, debugstr_w(buffer_in
));
393 /* we parsed the url to buffer_in */
398 FIXME("call search hook for %s\n", debugstr_w(ptr
));
402 len
= sizeof(buffer_out
) / sizeof(buffer_out
[0]);
403 buffer_out
[0] = '\0';
404 hr
= UrlCanonicalizeW(ptr
, buffer_out
, &len
, URL_ESCAPE_SPACES_ONLY
);
405 needed
= lstrlenW(buffer_out
)+1;
406 TRACE("got 0x%x with %s (need %d)\n", hr
, debugstr_w(buffer_out
), needed
);
408 if (*plen
>= needed
) {
410 lstrcpyW(out
, buffer_out
);
418 TRACE("=> %d\n", res
);
422 /******************************************************************
423 * ParseURLFromOutsideSourceA (SHDOCVW.169)
425 * See ParseURLFromOutsideSourceW
427 DWORD WINAPI
ParseURLFromOutsideSourceA(LPCSTR url
, LPSTR out
, LPDWORD plen
, LPDWORD unknown
)
429 WCHAR buffer
[INTERNET_MAX_URL_LENGTH
];
435 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_a(url
), out
, plen
, unknown
,
436 plen
? *plen
: 0, unknown
? *unknown
: 0);
439 len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
440 urlW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
441 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
444 len
= sizeof(buffer
) / sizeof(buffer
[0]);
445 ParseURLFromOutsideSourceW(urlW
, buffer
, &len
, unknown
);
446 HeapFree(GetProcessHeap(), 0, urlW
);
448 needed
= WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, NULL
, 0, NULL
, NULL
);
451 if (*plen
>= needed
) {
453 WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, out
, *plen
, NULL
, NULL
);
461 TRACE("=> %d\n", res
);
465 /******************************************************************
466 * IEParseDisplayNameWithBCW (SHDOCVW.218)
468 HRESULT WINAPI
IEParseDisplayNameWithBCW(DWORD codepage
, LPCWSTR lpszDisplayName
, LPBC pbc
, LPITEMIDLIST
*ppidl
)
470 /* Guessing at parameter 3 based on IShellFolder's ParseDisplayName */
471 FIXME("stub: 0x%x %s %p %p\n",codepage
,debugstr_w(lpszDisplayName
),pbc
,ppidl
);
475 /******************************************************************
476 * SHRestricted2W (SHDOCVW.159)
478 DWORD WINAPI
SHRestricted2W(DWORD res
, LPCWSTR url
, DWORD reserved
)
480 FIXME("(%d %s %d) stub\n", res
, debugstr_w(url
), reserved
);
484 /******************************************************************
485 * SHRestricted2A (SHDOCVW.158)
489 DWORD WINAPI
SHRestricted2A(DWORD restriction
, LPCSTR url
, DWORD reserved
)
494 TRACE("(%d, %s, %d)\n", restriction
, debugstr_a(url
), reserved
);
496 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
497 urlW
= heap_alloc(len
* sizeof(WCHAR
));
498 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
500 res
= SHRestricted2W(restriction
, urlW
, reserved
);
505 /******************************************************************
506 * ImportPrivacySettings (SHDOCVW.@)
508 * Import global and/or per site privacy preferences from an xml file
511 * filename [I] XML file to use
512 * pGlobalPrefs [IO] PTR to a usage flag for the global privacy preferences
513 * pPerSitePrefs [IO] PTR to a usage flag for the per site privacy preferences
516 * Success: TRUE (the privacy preferences where updated)
517 * Failure: FALSE (the privacy preferences are unchanged)
520 * Set the flag to TRUE, when the related privacy preferences in the xml file
521 * should be used (parsed and overwrite the current settings).
522 * On return, the flag is TRUE, when the related privacy settings where used
525 BOOL WINAPI
ImportPrivacySettings(LPCWSTR filename
, BOOL
*pGlobalPrefs
, BOOL
* pPerSitePrefs
)
527 FIXME("(%s, %p->%d, %p->%d): stub\n", debugstr_w(filename
),
528 pGlobalPrefs
, pGlobalPrefs
? *pGlobalPrefs
: 0,
529 pPerSitePrefs
, pPerSitePrefs
? *pPerSitePrefs
: 0);
531 if (pGlobalPrefs
) *pGlobalPrefs
= FALSE
;
532 if (pPerSitePrefs
) *pPerSitePrefs
= FALSE
;
537 /******************************************************************
538 * ResetProfileSharing (SHDOCVW.164)
540 HRESULT WINAPI
ResetProfileSharing(HWND hwnd
)
542 FIXME("(%p) stub\n", hwnd
);
546 /******************************************************************
547 * InstallReg_RunDLL (SHDOCVW.@)
549 void WINAPI
InstallReg_RunDLL(HWND hwnd
, HINSTANCE handle
, LPCSTR cmdline
, INT show
)
551 FIXME("(%p %p %s %x)\n", hwnd
, handle
, debugstr_a(cmdline
), show
);