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)
46 static const WCHAR ieframe_dllW
[] = {'i','e','f','r','a','m','e','.','d','l','l',0};
49 ieframe_instance
= LoadLibraryW(ieframe_dllW
);
51 return ieframe_instance
;
54 static HRESULT
get_ieframe_object(REFCLSID rclsid
, REFIID riid
, void **ppv
)
56 HINSTANCE ieframe_instance
;
58 static HRESULT (WINAPI
*ieframe_DllGetClassObject
)(REFCLSID
,REFIID
,void**);
60 if(!ieframe_DllGetClassObject
) {
61 ieframe_instance
= get_ieframe_instance();
63 return CLASS_E_CLASSNOTAVAILABLE
;
65 ieframe_DllGetClassObject
= (void*)GetProcAddress(ieframe_instance
, "DllGetClassObject");
66 if(!ieframe_DllGetClassObject
)
67 return CLASS_E_CLASSNOTAVAILABLE
;
70 return ieframe_DllGetClassObject(rclsid
, riid
, ppv
);
73 /*************************************************************************
74 * DllGetClassObject (SHDOCVW.@)
76 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, void **ppv
)
78 TRACE("(%s %s %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
80 if(IsEqualGUID(&CLSID_WebBrowser
, rclsid
)
81 || IsEqualGUID(&CLSID_WebBrowser_V1
, rclsid
)
82 || IsEqualGUID(&CLSID_InternetShortcut
, rclsid
)
83 || IsEqualGUID(&CLSID_CUrlHistory
, rclsid
)
84 || IsEqualGUID(&CLSID_TaskbarList
, rclsid
))
85 return get_ieframe_object(rclsid
, riid
, ppv
);
87 /* As a last resort, figure if the CLSID belongs to a 'Shell Instance Object' */
88 return SHDOCVW_GetShellInstanceObjectClassObject(rclsid
, riid
, ppv
);
91 /***********************************************************************
92 * DllRegisterServer (shdocvw.@)
94 HRESULT WINAPI
DllRegisterServer(void)
100 /***********************************************************************
101 * DllUnregisterServer (shdocvw.@)
103 HRESULT WINAPI
DllUnregisterServer(void)
109 /******************************************************************
110 * IEWinMain (SHDOCVW.101)
112 * Only returns on error.
114 DWORD WINAPI
IEWinMain(LPSTR szCommandLine
, int nShowWindow
)
116 DWORD (WINAPI
*pIEWinMain
)(const WCHAR
*,int);
120 TRACE("%s %d\n", debugstr_a(szCommandLine
), nShowWindow
);
122 pIEWinMain
= (void*)GetProcAddress(get_ieframe_instance(), MAKEINTRESOURCEA(101));
126 len
= MultiByteToWideChar(CP_ACP
, 0, szCommandLine
, -1, NULL
, 0);
127 cmdline
= heap_alloc(len
*sizeof(WCHAR
));
130 MultiByteToWideChar(CP_ACP
, 0, szCommandLine
, -1, cmdline
, len
);
132 ret
= pIEWinMain(cmdline
, nShowWindow
);
138 /*************************************************************************
141 BOOL WINAPI
DllMain(HINSTANCE hinst
, DWORD fdwReason
, LPVOID fImpLoad
)
143 TRACE("%p 0x%x %p\n", hinst
, fdwReason
, fImpLoad
);
146 case DLL_PROCESS_ATTACH
:
147 DisableThreadLibraryCalls(hinst
);
149 case DLL_PROCESS_DETACH
:
151 if (SHDOCVW_hshell32
) FreeLibrary(SHDOCVW_hshell32
);
152 if (ieframe_instance
) FreeLibrary(ieframe_instance
);
158 /*************************************************************************
159 * DllCanUnloadNow (SHDOCVW.@)
161 HRESULT WINAPI
DllCanUnloadNow(void)
163 return SHDOCVW_refCount
? S_FALSE
: S_OK
;
166 /***********************************************************************
167 * DllGetVersion (SHDOCVW.@)
169 HRESULT WINAPI
DllGetVersion(DLLVERSIONINFO
*info
)
171 if (info
->cbSize
!= sizeof(DLLVERSIONINFO
)) FIXME("support DLLVERSIONINFO2\n");
173 /* this is what IE6 on Windows 98 reports */
174 info
->dwMajorVersion
= 6;
175 info
->dwMinorVersion
= 0;
176 info
->dwBuildNumber
= 2600;
177 info
->dwPlatformID
= DLLVER_PLATFORM_WINDOWS
;
182 /*************************************************************************
183 * DllInstall (SHDOCVW.@)
185 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
187 FIXME("(%s, %s): stub!\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
192 /*************************************************************************
193 * SHDOCVW_LoadShell32
195 * makes sure the handle to shell32 is valid
197 static BOOL
SHDOCVW_LoadShell32(void)
199 if (SHDOCVW_hshell32
)
201 return ((SHDOCVW_hshell32
= LoadLibraryA("shell32.dll")) != NULL
);
204 /***********************************************************************
207 * Called by Win98 explorer.exe main binary, definitely has 0
210 DWORD WINAPI
WinList_Init(void)
212 FIXME("(), stub!\n");
216 /***********************************************************************
219 * Called by Win98 explorer.exe main binary, definitely has only one
222 static BOOL (WINAPI
*pShellDDEInit
)(BOOL start
) = NULL
;
224 BOOL WINAPI
ShellDDEInit(BOOL start
)
226 TRACE("(%d)\n", start
);
230 if (!SHDOCVW_LoadShell32())
232 pShellDDEInit
= (void *)GetProcAddress(SHDOCVW_hshell32
, (LPCSTR
)188);
236 return pShellDDEInit(start
);
241 /***********************************************************************
244 * Called by Win98 explorer.exe main binary, definitely has 0
247 DWORD WINAPI
RunInstallUninstallStubs(void)
249 FIXME("(), stub!\n");
253 /***********************************************************************
256 * Called by Emerge Desktop (alternative Windows Shell).
258 DWORD WINAPI
RunInstallUninstallStubs2(int arg
)
260 FIXME("(%d), stub!\n", arg
);
264 /***********************************************************************
265 * SetQueryNetSessionCount (SHDOCVW.@)
267 DWORD WINAPI
SetQueryNetSessionCount(DWORD arg
)
269 FIXME("(%u), stub!\n", arg
);
273 /**********************************************************************
274 * Some forwards (by ordinal) to SHLWAPI
277 static void* fetch_shlwapi_ordinal(UINT_PTR ord
)
279 static const WCHAR shlwapiW
[] = {'s','h','l','w','a','p','i','.','d','l','l','\0'};
282 if (!h
&& !(h
= GetModuleHandleW(shlwapiW
))) return NULL
;
283 return (void*)GetProcAddress(h
, (const char*)ord
);
286 /******************************************************************
287 * WhichPlatformFORWARD (SHDOCVW.@)
289 DWORD WINAPI
WhichPlatformFORWARD(void)
291 static DWORD (WINAPI
*p
)(void);
293 if (p
|| (p
= fetch_shlwapi_ordinal(276))) return p();
294 return 1; /* not integrated, see shlwapi.WhichPlatform */
297 /******************************************************************
298 * StopWatchModeFORWARD (SHDOCVW.@)
300 void WINAPI
StopWatchModeFORWARD(void)
302 static void (WINAPI
*p
)(void);
304 if (p
|| (p
= fetch_shlwapi_ordinal(241))) p();
307 /******************************************************************
308 * StopWatchFlushFORWARD (SHDOCVW.@)
310 void WINAPI
StopWatchFlushFORWARD(void)
312 static void (WINAPI
*p
)(void);
314 if (p
|| (p
= fetch_shlwapi_ordinal(242))) p();
317 /******************************************************************
318 * StopWatchAFORWARD (SHDOCVW.@)
320 DWORD WINAPI
StopWatchAFORWARD(DWORD dwClass
, LPCSTR lpszStr
, DWORD dwUnknown
,
321 DWORD dwMode
, DWORD dwTimeStamp
)
323 static DWORD (WINAPI
*p
)(DWORD
, LPCSTR
, DWORD
, DWORD
, DWORD
);
325 if (p
|| (p
= fetch_shlwapi_ordinal(243)))
326 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
327 return ERROR_CALL_NOT_IMPLEMENTED
;
330 /******************************************************************
331 * StopWatchWFORWARD (SHDOCVW.@)
333 DWORD WINAPI
StopWatchWFORWARD(DWORD dwClass
, LPCWSTR lpszStr
, DWORD dwUnknown
,
334 DWORD dwMode
, DWORD dwTimeStamp
)
336 static DWORD (WINAPI
*p
)(DWORD
, LPCWSTR
, DWORD
, DWORD
, DWORD
);
338 if (p
|| (p
= fetch_shlwapi_ordinal(244)))
339 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
340 return ERROR_CALL_NOT_IMPLEMENTED
;
343 /******************************************************************
344 * URLSubRegQueryA (SHDOCVW.151)
346 HRESULT WINAPI
URLSubRegQueryA(LPCSTR regpath
, LPCSTR name
, DWORD type
,
347 LPSTR out
, DWORD outlen
, DWORD unknown
)
349 CHAR buffer
[INTERNET_MAX_URL_LENGTH
];
353 TRACE("(%s, %s, %d, %p, %d, %d)\n", debugstr_a(regpath
), debugstr_a(name
),
354 type
, out
, outlen
, unknown
);
356 if (!out
) return S_OK
;
358 len
= sizeof(buffer
);
359 res
= SHRegGetUSValueA(regpath
, name
, NULL
, buffer
, &len
, FALSE
, NULL
, 0);
361 lstrcpynA(out
, buffer
, outlen
);
368 /******************************************************************
369 * ParseURLFromOutsideSourceW (SHDOCVW.170)
371 DWORD WINAPI
ParseURLFromOutsideSourceW(LPCWSTR url
, LPWSTR out
, LPDWORD plen
, LPDWORD unknown
)
373 WCHAR buffer_in
[INTERNET_MAX_URL_LENGTH
];
374 WCHAR buffer_out
[INTERNET_MAX_URL_LENGTH
];
382 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_w(url
), out
, plen
, unknown
,
383 plen
? *plen
: 0, unknown
? *unknown
: 0);
385 if (!PathIsURLW(ptr
)) {
386 len
= ARRAY_SIZE(buffer_in
);
388 hr
= UrlApplySchemeW(ptr
, buffer_in
, &len
, URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
);
389 TRACE("got 0x%x with %s\n", hr
, debugstr_w(buffer_in
));
391 /* we parsed the url to buffer_in */
396 FIXME("call search hook for %s\n", debugstr_w(ptr
));
400 len
= ARRAY_SIZE(buffer_out
);
401 buffer_out
[0] = '\0';
402 hr
= UrlCanonicalizeW(ptr
, buffer_out
, &len
, URL_ESCAPE_SPACES_ONLY
);
403 needed
= lstrlenW(buffer_out
)+1;
404 TRACE("got 0x%x with %s (need %d)\n", hr
, debugstr_w(buffer_out
), needed
);
406 if (*plen
>= needed
) {
408 lstrcpyW(out
, buffer_out
);
416 TRACE("=> %d\n", res
);
420 /******************************************************************
421 * ParseURLFromOutsideSourceA (SHDOCVW.169)
423 * See ParseURLFromOutsideSourceW
425 DWORD WINAPI
ParseURLFromOutsideSourceA(LPCSTR url
, LPSTR out
, LPDWORD plen
, LPDWORD unknown
)
427 WCHAR buffer
[INTERNET_MAX_URL_LENGTH
];
433 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_a(url
), out
, plen
, unknown
,
434 plen
? *plen
: 0, unknown
? *unknown
: 0);
437 len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
438 urlW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
439 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
442 len
= ARRAY_SIZE(buffer
);
443 ParseURLFromOutsideSourceW(urlW
, buffer
, &len
, unknown
);
444 HeapFree(GetProcessHeap(), 0, urlW
);
446 needed
= WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, NULL
, 0, NULL
, NULL
);
449 if (*plen
>= needed
) {
451 WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, out
, *plen
, NULL
, NULL
);
459 TRACE("=> %d\n", res
);
463 /******************************************************************
464 * IEParseDisplayNameWithBCW (SHDOCVW.218)
466 HRESULT WINAPI
IEParseDisplayNameWithBCW(DWORD codepage
, LPCWSTR lpszDisplayName
, LPBC pbc
, LPITEMIDLIST
*ppidl
)
468 /* Guessing at parameter 3 based on IShellFolder's ParseDisplayName */
469 FIXME("stub: 0x%x %s %p %p\n",codepage
,debugstr_w(lpszDisplayName
),pbc
,ppidl
);
473 /******************************************************************
474 * SHRestricted2W (SHDOCVW.159)
476 DWORD WINAPI
SHRestricted2W(DWORD res
, LPCWSTR url
, DWORD reserved
)
478 FIXME("(%d %s %d) stub\n", res
, debugstr_w(url
), reserved
);
482 /******************************************************************
483 * SHRestricted2A (SHDOCVW.158)
487 DWORD WINAPI
SHRestricted2A(DWORD restriction
, LPCSTR url
, DWORD reserved
)
492 TRACE("(%d, %s, %d)\n", restriction
, debugstr_a(url
), reserved
);
494 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
495 urlW
= heap_alloc(len
* sizeof(WCHAR
));
496 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
498 res
= SHRestricted2W(restriction
, urlW
, reserved
);
503 /******************************************************************
504 * ImportPrivacySettings (SHDOCVW.@)
506 * Import global and/or per site privacy preferences from an xml file
509 * filename [I] XML file to use
510 * pGlobalPrefs [IO] PTR to a usage flag for the global privacy preferences
511 * pPerSitePrefs [IO] PTR to a usage flag for the per site privacy preferences
514 * Success: TRUE (the privacy preferences where updated)
515 * Failure: FALSE (the privacy preferences are unchanged)
518 * Set the flag to TRUE, when the related privacy preferences in the xml file
519 * should be used (parsed and overwrite the current settings).
520 * On return, the flag is TRUE, when the related privacy settings where used
523 BOOL WINAPI
ImportPrivacySettings(LPCWSTR filename
, BOOL
*pGlobalPrefs
, BOOL
* pPerSitePrefs
)
525 FIXME("(%s, %p->%d, %p->%d): stub\n", debugstr_w(filename
),
526 pGlobalPrefs
, pGlobalPrefs
? *pGlobalPrefs
: 0,
527 pPerSitePrefs
, pPerSitePrefs
? *pPerSitePrefs
: 0);
529 if (pGlobalPrefs
) *pGlobalPrefs
= FALSE
;
530 if (pPerSitePrefs
) *pPerSitePrefs
= FALSE
;
535 /******************************************************************
536 * ResetProfileSharing (SHDOCVW.164)
538 HRESULT WINAPI
ResetProfileSharing(HWND hwnd
)
540 FIXME("(%p) stub\n", hwnd
);
544 /******************************************************************
545 * InstallReg_RunDLL (SHDOCVW.@)
547 void WINAPI
InstallReg_RunDLL(HWND hwnd
, HINSTANCE handle
, LPCSTR cmdline
, INT show
)
549 FIXME("(%p %p %s %x)\n", hwnd
, handle
, debugstr_a(cmdline
), show
);
552 /******************************************************************
553 * DoFileDownload (SHDOCVW.@)
555 BOOL WINAPI
DoFileDownload(LPWSTR filename
)
557 FIXME("(%s) stub\n", debugstr_w(filename
));
561 /******************************************************************
562 * DoOrganizeFavDlgW (SHDOCVW.@)
564 BOOL WINAPI
DoOrganizeFavDlgW(HWND hwnd
, LPCWSTR initDir
)
566 FIXME("(%p %s) stub\n", hwnd
, debugstr_w(initDir
));
570 /******************************************************************
571 * DoOrganizeFavDlg (SHDOCVW.@)
573 BOOL WINAPI
DoOrganizeFavDlg(HWND hwnd
, LPCSTR initDir
)
575 LPWSTR initDirW
= NULL
;
578 TRACE("(%p %s)\n", hwnd
, debugstr_a(initDir
));
581 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, initDir
, -1, NULL
, 0);
582 initDirW
= heap_alloc(len
* sizeof(WCHAR
));
583 MultiByteToWideChar(CP_ACP
, 0, initDir
, -1, initDirW
, len
);
585 res
= DoOrganizeFavDlgW(hwnd
, initDirW
);