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 * DllRegisterServer (shdocvw.@)
92 HRESULT WINAPI
DllRegisterServer(void)
98 /***********************************************************************
99 * DllUnregisterServer (shdocvw.@)
101 HRESULT WINAPI
DllUnregisterServer(void)
107 /******************************************************************
108 * IEWinMain (SHDOCVW.101)
110 * Only returns on error.
112 DWORD WINAPI
IEWinMain(LPSTR szCommandLine
, int nShowWindow
)
114 DWORD (WINAPI
*pIEWinMain
)(const WCHAR
*,int);
118 TRACE("%s %d\n", debugstr_a(szCommandLine
), nShowWindow
);
120 pIEWinMain
= (void*)GetProcAddress(get_ieframe_instance(), MAKEINTRESOURCEA(101));
124 len
= MultiByteToWideChar(CP_ACP
, 0, szCommandLine
, -1, NULL
, 0);
125 cmdline
= heap_alloc(len
*sizeof(WCHAR
));
128 MultiByteToWideChar(CP_ACP
, 0, szCommandLine
, -1, cmdline
, len
);
130 ret
= pIEWinMain(cmdline
, nShowWindow
);
136 /*************************************************************************
139 BOOL WINAPI
DllMain(HINSTANCE hinst
, DWORD fdwReason
, LPVOID fImpLoad
)
141 TRACE("%p 0x%x %p\n", hinst
, fdwReason
, fImpLoad
);
144 case DLL_PROCESS_ATTACH
:
145 DisableThreadLibraryCalls(hinst
);
147 case DLL_PROCESS_DETACH
:
149 if (SHDOCVW_hshell32
) FreeLibrary(SHDOCVW_hshell32
);
150 if (ieframe_instance
) FreeLibrary(ieframe_instance
);
156 /*************************************************************************
157 * DllCanUnloadNow (SHDOCVW.@)
159 HRESULT WINAPI
DllCanUnloadNow(void)
161 return SHDOCVW_refCount
? S_FALSE
: S_OK
;
164 /***********************************************************************
165 * DllGetVersion (SHDOCVW.@)
167 HRESULT WINAPI
DllGetVersion(DLLVERSIONINFO
*info
)
169 if (info
->cbSize
!= sizeof(DLLVERSIONINFO
)) FIXME("support DLLVERSIONINFO2\n");
171 /* this is what IE6 on Windows 98 reports */
172 info
->dwMajorVersion
= 6;
173 info
->dwMinorVersion
= 0;
174 info
->dwBuildNumber
= 2600;
175 info
->dwPlatformID
= DLLVER_PLATFORM_WINDOWS
;
180 /*************************************************************************
181 * DllInstall (SHDOCVW.@)
183 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
185 FIXME("(%s, %s): stub!\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
190 /*************************************************************************
191 * SHDOCVW_LoadShell32
193 * makes sure the handle to shell32 is valid
195 static BOOL
SHDOCVW_LoadShell32(void)
197 if (SHDOCVW_hshell32
)
199 return ((SHDOCVW_hshell32
= LoadLibraryA("shell32.dll")) != NULL
);
202 /***********************************************************************
205 * Called by Win98 explorer.exe main binary, definitely has 0
208 DWORD WINAPI
WinList_Init(void)
210 FIXME("(), stub!\n");
214 /***********************************************************************
217 * Called by Win98 explorer.exe main binary, definitely has only one
220 static BOOL (WINAPI
*pShellDDEInit
)(BOOL start
) = NULL
;
222 BOOL WINAPI
ShellDDEInit(BOOL start
)
224 TRACE("(%d)\n", start
);
228 if (!SHDOCVW_LoadShell32())
230 pShellDDEInit
= (void *)GetProcAddress(SHDOCVW_hshell32
, (LPCSTR
)188);
234 return pShellDDEInit(start
);
239 /***********************************************************************
242 * Called by Win98 explorer.exe main binary, definitely has 0
245 DWORD WINAPI
RunInstallUninstallStubs(void)
247 FIXME("(), stub!\n");
251 /***********************************************************************
254 * Called by Emerge Desktop (alternative Windows Shell).
256 DWORD WINAPI
RunInstallUninstallStubs2(int arg
)
258 FIXME("(%d), stub!\n", arg
);
262 /***********************************************************************
263 * SetQueryNetSessionCount (SHDOCVW.@)
265 DWORD WINAPI
SetQueryNetSessionCount(DWORD arg
)
267 FIXME("(%u), stub!\n", arg
);
271 /**********************************************************************
272 * Some forwards (by ordinal) to SHLWAPI
275 static void* fetch_shlwapi_ordinal(UINT_PTR ord
)
279 if (!h
&& !(h
= GetModuleHandleW(L
"shlwapi.dll"))) return NULL
;
280 return (void*)GetProcAddress(h
, (const char*)ord
);
283 /******************************************************************
284 * StopWatchModeFORWARD (SHDOCVW.@)
286 void WINAPI
StopWatchModeFORWARD(void)
288 static void (WINAPI
*p
)(void);
290 if (p
|| (p
= fetch_shlwapi_ordinal(241))) p();
293 /******************************************************************
294 * StopWatchFlushFORWARD (SHDOCVW.@)
296 void WINAPI
StopWatchFlushFORWARD(void)
298 static void (WINAPI
*p
)(void);
300 if (p
|| (p
= fetch_shlwapi_ordinal(242))) p();
303 /******************************************************************
304 * StopWatchAFORWARD (SHDOCVW.@)
306 DWORD WINAPI
StopWatchAFORWARD(DWORD dwClass
, LPCSTR lpszStr
, DWORD dwUnknown
,
307 DWORD dwMode
, DWORD dwTimeStamp
)
309 static DWORD (WINAPI
*p
)(DWORD
, LPCSTR
, DWORD
, DWORD
, DWORD
);
311 if (p
|| (p
= fetch_shlwapi_ordinal(243)))
312 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
313 return ERROR_CALL_NOT_IMPLEMENTED
;
316 /******************************************************************
317 * StopWatchWFORWARD (SHDOCVW.@)
319 DWORD WINAPI
StopWatchWFORWARD(DWORD dwClass
, LPCWSTR lpszStr
, DWORD dwUnknown
,
320 DWORD dwMode
, DWORD dwTimeStamp
)
322 static DWORD (WINAPI
*p
)(DWORD
, LPCWSTR
, DWORD
, DWORD
, DWORD
);
324 if (p
|| (p
= fetch_shlwapi_ordinal(244)))
325 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
326 return ERROR_CALL_NOT_IMPLEMENTED
;
329 /******************************************************************
330 * URLSubRegQueryA (SHDOCVW.151)
332 HRESULT WINAPI
URLSubRegQueryA(LPCSTR regpath
, LPCSTR name
, DWORD type
,
333 LPSTR out
, DWORD outlen
, DWORD unknown
)
335 CHAR buffer
[INTERNET_MAX_URL_LENGTH
];
339 TRACE("(%s, %s, %d, %p, %d, %d)\n", debugstr_a(regpath
), debugstr_a(name
),
340 type
, out
, outlen
, unknown
);
342 if (!out
) return S_OK
;
344 len
= sizeof(buffer
);
345 res
= SHRegGetUSValueA(regpath
, name
, NULL
, buffer
, &len
, FALSE
, NULL
, 0);
347 lstrcpynA(out
, buffer
, outlen
);
354 /******************************************************************
355 * ParseURLFromOutsideSourceW (SHDOCVW.170)
357 DWORD WINAPI
ParseURLFromOutsideSourceW(LPCWSTR url
, LPWSTR out
, LPDWORD plen
, LPDWORD unknown
)
359 WCHAR buffer_in
[INTERNET_MAX_URL_LENGTH
];
360 WCHAR buffer_out
[INTERNET_MAX_URL_LENGTH
];
368 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_w(url
), out
, plen
, unknown
,
369 plen
? *plen
: 0, unknown
? *unknown
: 0);
371 if (!PathIsURLW(ptr
)) {
372 len
= ARRAY_SIZE(buffer_in
);
374 hr
= UrlApplySchemeW(ptr
, buffer_in
, &len
, URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
);
375 TRACE("got 0x%x with %s\n", hr
, debugstr_w(buffer_in
));
377 /* we parsed the url to buffer_in */
382 FIXME("call search hook for %s\n", debugstr_w(ptr
));
386 len
= ARRAY_SIZE(buffer_out
);
387 buffer_out
[0] = '\0';
388 hr
= UrlCanonicalizeW(ptr
, buffer_out
, &len
, URL_ESCAPE_SPACES_ONLY
);
389 needed
= lstrlenW(buffer_out
)+1;
390 TRACE("got 0x%x with %s (need %d)\n", hr
, debugstr_w(buffer_out
), needed
);
392 if (*plen
>= needed
) {
394 lstrcpyW(out
, buffer_out
);
402 TRACE("=> %d\n", res
);
406 /******************************************************************
407 * ParseURLFromOutsideSourceA (SHDOCVW.169)
409 * See ParseURLFromOutsideSourceW
411 DWORD WINAPI
ParseURLFromOutsideSourceA(LPCSTR url
, LPSTR out
, LPDWORD plen
, LPDWORD unknown
)
413 WCHAR buffer
[INTERNET_MAX_URL_LENGTH
];
419 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_a(url
), out
, plen
, unknown
,
420 plen
? *plen
: 0, unknown
? *unknown
: 0);
423 len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
424 urlW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
425 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
428 len
= ARRAY_SIZE(buffer
);
429 ParseURLFromOutsideSourceW(urlW
, buffer
, &len
, unknown
);
430 HeapFree(GetProcessHeap(), 0, urlW
);
432 needed
= WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, NULL
, 0, NULL
, NULL
);
435 if (*plen
>= needed
) {
437 WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, out
, *plen
, NULL
, NULL
);
445 TRACE("=> %d\n", res
);
449 /******************************************************************
450 * IEParseDisplayNameWithBCW (SHDOCVW.218)
452 HRESULT WINAPI
IEParseDisplayNameWithBCW(DWORD codepage
, LPCWSTR lpszDisplayName
, LPBC pbc
, LPITEMIDLIST
*ppidl
)
454 /* Guessing at parameter 3 based on IShellFolder's ParseDisplayName */
455 FIXME("stub: 0x%x %s %p %p\n",codepage
,debugstr_w(lpszDisplayName
),pbc
,ppidl
);
459 /******************************************************************
460 * SHRestricted2W (SHDOCVW.159)
462 DWORD WINAPI
SHRestricted2W(DWORD res
, LPCWSTR url
, DWORD reserved
)
464 FIXME("(%d %s %d) stub\n", res
, debugstr_w(url
), reserved
);
468 /******************************************************************
469 * SHRestricted2A (SHDOCVW.158)
473 DWORD WINAPI
SHRestricted2A(DWORD restriction
, LPCSTR url
, DWORD reserved
)
478 TRACE("(%d, %s, %d)\n", restriction
, debugstr_a(url
), reserved
);
480 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
481 urlW
= heap_alloc(len
* sizeof(WCHAR
));
482 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
484 res
= SHRestricted2W(restriction
, urlW
, reserved
);
489 /******************************************************************
490 * ImportPrivacySettings (SHDOCVW.@)
492 * Import global and/or per site privacy preferences from an xml file
495 * filename [I] XML file to use
496 * pGlobalPrefs [IO] PTR to a usage flag for the global privacy preferences
497 * pPerSitePrefs [IO] PTR to a usage flag for the per site privacy preferences
500 * Success: TRUE (the privacy preferences where updated)
501 * Failure: FALSE (the privacy preferences are unchanged)
504 * Set the flag to TRUE, when the related privacy preferences in the xml file
505 * should be used (parsed and overwrite the current settings).
506 * On return, the flag is TRUE, when the related privacy settings where used
509 BOOL WINAPI
ImportPrivacySettings(LPCWSTR filename
, BOOL
*pGlobalPrefs
, BOOL
* pPerSitePrefs
)
511 FIXME("(%s, %p->%d, %p->%d): stub\n", debugstr_w(filename
),
512 pGlobalPrefs
, pGlobalPrefs
? *pGlobalPrefs
: 0,
513 pPerSitePrefs
, pPerSitePrefs
? *pPerSitePrefs
: 0);
515 if (pGlobalPrefs
) *pGlobalPrefs
= FALSE
;
516 if (pPerSitePrefs
) *pPerSitePrefs
= FALSE
;
521 /******************************************************************
522 * ResetProfileSharing (SHDOCVW.164)
524 HRESULT WINAPI
ResetProfileSharing(HWND hwnd
)
526 FIXME("(%p) stub\n", hwnd
);
530 /******************************************************************
531 * InstallReg_RunDLL (SHDOCVW.@)
533 void WINAPI
InstallReg_RunDLL(HWND hwnd
, HINSTANCE handle
, LPCSTR cmdline
, INT show
)
535 FIXME("(%p %p %s %x)\n", hwnd
, handle
, debugstr_a(cmdline
), show
);
538 /******************************************************************
539 * DoFileDownload (SHDOCVW.@)
541 BOOL WINAPI
DoFileDownload(LPWSTR filename
)
543 FIXME("(%s) stub\n", debugstr_w(filename
));
547 /******************************************************************
548 * DoOrganizeFavDlgW (SHDOCVW.@)
550 BOOL WINAPI
DoOrganizeFavDlgW(HWND hwnd
, LPCWSTR initDir
)
552 FIXME("(%p %s) stub\n", hwnd
, debugstr_w(initDir
));
556 /******************************************************************
557 * DoOrganizeFavDlg (SHDOCVW.@)
559 BOOL WINAPI
DoOrganizeFavDlg(HWND hwnd
, LPCSTR initDir
)
561 LPWSTR initDirW
= NULL
;
564 TRACE("(%p %s)\n", hwnd
, debugstr_a(initDir
));
567 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, initDir
, -1, NULL
, 0);
568 initDirW
= heap_alloc(len
* sizeof(WCHAR
));
569 MultiByteToWideChar(CP_ACP
, 0, initDir
, -1, initDirW
, len
);
571 res
= DoOrganizeFavDlgW(hwnd
, initDirW
);