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
)
81 TRACE("(%s %s %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), 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
:
150 DisableThreadLibraryCalls(hinst
);
152 case DLL_PROCESS_DETACH
:
154 if (SHDOCVW_hshell32
) FreeLibrary(SHDOCVW_hshell32
);
155 if (ieframe_instance
) FreeLibrary(ieframe_instance
);
161 /*************************************************************************
162 * DllCanUnloadNow (SHDOCVW.@)
164 HRESULT WINAPI
DllCanUnloadNow(void)
166 return SHDOCVW_refCount
? S_FALSE
: S_OK
;
169 /***********************************************************************
170 * DllGetVersion (SHDOCVW.@)
172 HRESULT WINAPI
DllGetVersion(DLLVERSIONINFO
*info
)
174 if (info
->cbSize
!= sizeof(DLLVERSIONINFO
)) FIXME("support DLLVERSIONINFO2\n");
176 /* this is what IE6 on Windows 98 reports */
177 info
->dwMajorVersion
= 6;
178 info
->dwMinorVersion
= 0;
179 info
->dwBuildNumber
= 2600;
180 info
->dwPlatformID
= DLLVER_PLATFORM_WINDOWS
;
185 /*************************************************************************
186 * DllInstall (SHDOCVW.@)
188 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
190 FIXME("(%s, %s): stub!\n", bInstall
? "TRUE":"FALSE", debugstr_w(cmdline
));
195 /*************************************************************************
196 * SHDOCVW_LoadShell32
198 * makes sure the handle to shell32 is valid
200 static BOOL
SHDOCVW_LoadShell32(void)
202 if (SHDOCVW_hshell32
)
204 return ((SHDOCVW_hshell32
= LoadLibraryA("shell32.dll")) != NULL
);
207 /***********************************************************************
210 * Called by Win98 explorer.exe main binary, definitely has 0
213 DWORD WINAPI
WinList_Init(void)
215 FIXME("(), stub!\n");
219 /***********************************************************************
222 * Called by Win98 explorer.exe main binary, definitely has only one
225 static BOOL (WINAPI
*pShellDDEInit
)(BOOL start
) = NULL
;
227 BOOL WINAPI
ShellDDEInit(BOOL start
)
229 TRACE("(%d)\n", start
);
233 if (!SHDOCVW_LoadShell32())
235 pShellDDEInit
= (void *)GetProcAddress(SHDOCVW_hshell32
, (LPCSTR
)188);
239 return pShellDDEInit(start
);
244 /***********************************************************************
247 * Called by Win98 explorer.exe main binary, definitely has 0
250 DWORD WINAPI
RunInstallUninstallStubs(void)
252 FIXME("(), stub!\n");
256 /***********************************************************************
259 * Called by Emerge Desktop (alternative Windows Shell).
261 DWORD WINAPI
RunInstallUninstallStubs2(int arg
)
263 FIXME("(%d), stub!\n", arg
);
267 /***********************************************************************
268 * SetQueryNetSessionCount (SHDOCVW.@)
270 DWORD WINAPI
SetQueryNetSessionCount(DWORD arg
)
272 FIXME("(%u), stub!\n", arg
);
276 /**********************************************************************
277 * Some forwards (by ordinal) to SHLWAPI
280 static void* fetch_shlwapi_ordinal(UINT_PTR ord
)
282 static const WCHAR shlwapiW
[] = {'s','h','l','w','a','p','i','.','d','l','l','\0'};
285 if (!h
&& !(h
= GetModuleHandleW(shlwapiW
))) return NULL
;
286 return (void*)GetProcAddress(h
, (const char*)ord
);
289 /******************************************************************
290 * WhichPlatformFORWARD (SHDOCVW.@)
292 DWORD WINAPI
WhichPlatformFORWARD(void)
294 static DWORD (WINAPI
*p
)(void);
296 if (p
|| (p
= fetch_shlwapi_ordinal(276))) return p();
297 return 1; /* not integrated, see shlwapi.WhichPlatform */
300 /******************************************************************
301 * StopWatchModeFORWARD (SHDOCVW.@)
303 void WINAPI
StopWatchModeFORWARD(void)
305 static void (WINAPI
*p
)(void);
307 if (p
|| (p
= fetch_shlwapi_ordinal(241))) p();
310 /******************************************************************
311 * StopWatchFlushFORWARD (SHDOCVW.@)
313 void WINAPI
StopWatchFlushFORWARD(void)
315 static void (WINAPI
*p
)(void);
317 if (p
|| (p
= fetch_shlwapi_ordinal(242))) p();
320 /******************************************************************
321 * StopWatchAFORWARD (SHDOCVW.@)
323 DWORD WINAPI
StopWatchAFORWARD(DWORD dwClass
, LPCSTR lpszStr
, DWORD dwUnknown
,
324 DWORD dwMode
, DWORD dwTimeStamp
)
326 static DWORD (WINAPI
*p
)(DWORD
, LPCSTR
, DWORD
, DWORD
, DWORD
);
328 if (p
|| (p
= fetch_shlwapi_ordinal(243)))
329 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
330 return ERROR_CALL_NOT_IMPLEMENTED
;
333 /******************************************************************
334 * StopWatchWFORWARD (SHDOCVW.@)
336 DWORD WINAPI
StopWatchWFORWARD(DWORD dwClass
, LPCWSTR lpszStr
, DWORD dwUnknown
,
337 DWORD dwMode
, DWORD dwTimeStamp
)
339 static DWORD (WINAPI
*p
)(DWORD
, LPCWSTR
, DWORD
, DWORD
, DWORD
);
341 if (p
|| (p
= fetch_shlwapi_ordinal(244)))
342 return p(dwClass
, lpszStr
, dwUnknown
, dwMode
, dwTimeStamp
);
343 return ERROR_CALL_NOT_IMPLEMENTED
;
346 /******************************************************************
347 * URLSubRegQueryA (SHDOCVW.151)
349 HRESULT WINAPI
URLSubRegQueryA(LPCSTR regpath
, LPCSTR name
, DWORD type
,
350 LPSTR out
, DWORD outlen
, DWORD unknown
)
352 CHAR buffer
[INTERNET_MAX_URL_LENGTH
];
356 TRACE("(%s, %s, %d, %p, %d, %d)\n", debugstr_a(regpath
), debugstr_a(name
),
357 type
, out
, outlen
, unknown
);
359 if (!out
) return S_OK
;
361 len
= sizeof(buffer
);
362 res
= SHRegGetUSValueA(regpath
, name
, NULL
, buffer
, &len
, FALSE
, NULL
, 0);
364 lstrcpynA(out
, buffer
, outlen
);
371 /******************************************************************
372 * ParseURLFromOutsideSourceW (SHDOCVW.170)
374 DWORD WINAPI
ParseURLFromOutsideSourceW(LPCWSTR url
, LPWSTR out
, LPDWORD plen
, LPDWORD unknown
)
376 WCHAR buffer_in
[INTERNET_MAX_URL_LENGTH
];
377 WCHAR buffer_out
[INTERNET_MAX_URL_LENGTH
];
385 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_w(url
), out
, plen
, unknown
,
386 plen
? *plen
: 0, unknown
? *unknown
: 0);
388 if (!PathIsURLW(ptr
)) {
389 len
= sizeof(buffer_in
) / sizeof(buffer_in
[0]);
391 hr
= UrlApplySchemeW(ptr
, buffer_in
, &len
, URL_APPLY_GUESSSCHEME
| URL_APPLY_DEFAULT
);
392 TRACE("got 0x%x with %s\n", hr
, debugstr_w(buffer_in
));
394 /* we parsed the url to buffer_in */
399 FIXME("call search hook for %s\n", debugstr_w(ptr
));
403 len
= sizeof(buffer_out
) / sizeof(buffer_out
[0]);
404 buffer_out
[0] = '\0';
405 hr
= UrlCanonicalizeW(ptr
, buffer_out
, &len
, URL_ESCAPE_SPACES_ONLY
);
406 needed
= lstrlenW(buffer_out
)+1;
407 TRACE("got 0x%x with %s (need %d)\n", hr
, debugstr_w(buffer_out
), needed
);
409 if (*plen
>= needed
) {
411 lstrcpyW(out
, buffer_out
);
419 TRACE("=> %d\n", res
);
423 /******************************************************************
424 * ParseURLFromOutsideSourceA (SHDOCVW.169)
426 * See ParseURLFromOutsideSourceW
428 DWORD WINAPI
ParseURLFromOutsideSourceA(LPCSTR url
, LPSTR out
, LPDWORD plen
, LPDWORD unknown
)
430 WCHAR buffer
[INTERNET_MAX_URL_LENGTH
];
436 TRACE("(%s, %p, %p, %p) len: %d, unknown: 0x%x\n", debugstr_a(url
), out
, plen
, unknown
,
437 plen
? *plen
: 0, unknown
? *unknown
: 0);
440 len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
441 urlW
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
442 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
445 len
= sizeof(buffer
) / sizeof(buffer
[0]);
446 ParseURLFromOutsideSourceW(urlW
, buffer
, &len
, unknown
);
447 HeapFree(GetProcessHeap(), 0, urlW
);
449 needed
= WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, NULL
, 0, NULL
, NULL
);
452 if (*plen
>= needed
) {
454 WideCharToMultiByte(CP_ACP
, 0, buffer
, -1, out
, *plen
, NULL
, NULL
);
462 TRACE("=> %d\n", res
);
466 /******************************************************************
467 * IEParseDisplayNameWithBCW (SHDOCVW.218)
469 HRESULT WINAPI
IEParseDisplayNameWithBCW(DWORD codepage
, LPCWSTR lpszDisplayName
, LPBC pbc
, LPITEMIDLIST
*ppidl
)
471 /* Guessing at parameter 3 based on IShellFolder's ParseDisplayName */
472 FIXME("stub: 0x%x %s %p %p\n",codepage
,debugstr_w(lpszDisplayName
),pbc
,ppidl
);
476 /******************************************************************
477 * SHRestricted2W (SHDOCVW.159)
479 DWORD WINAPI
SHRestricted2W(DWORD res
, LPCWSTR url
, DWORD reserved
)
481 FIXME("(%d %s %d) stub\n", res
, debugstr_w(url
), reserved
);
485 /******************************************************************
486 * SHRestricted2A (SHDOCVW.158)
490 DWORD WINAPI
SHRestricted2A(DWORD restriction
, LPCSTR url
, DWORD reserved
)
495 TRACE("(%d, %s, %d)\n", restriction
, debugstr_a(url
), reserved
);
497 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, url
, -1, NULL
, 0);
498 urlW
= heap_alloc(len
* sizeof(WCHAR
));
499 MultiByteToWideChar(CP_ACP
, 0, url
, -1, urlW
, len
);
501 res
= SHRestricted2W(restriction
, urlW
, reserved
);
506 /******************************************************************
507 * ImportPrivacySettings (SHDOCVW.@)
509 * Import global and/or per site privacy preferences from an xml file
512 * filename [I] XML file to use
513 * pGlobalPrefs [IO] PTR to a usage flag for the global privacy preferences
514 * pPerSitePrefs [IO] PTR to a usage flag for the per site privacy preferences
517 * Success: TRUE (the privacy preferences where updated)
518 * Failure: FALSE (the privacy preferences are unchanged)
521 * Set the flag to TRUE, when the related privacy preferences in the xml file
522 * should be used (parsed and overwrite the current settings).
523 * On return, the flag is TRUE, when the related privacy settings where used
526 BOOL WINAPI
ImportPrivacySettings(LPCWSTR filename
, BOOL
*pGlobalPrefs
, BOOL
* pPerSitePrefs
)
528 FIXME("(%s, %p->%d, %p->%d): stub\n", debugstr_w(filename
),
529 pGlobalPrefs
, pGlobalPrefs
? *pGlobalPrefs
: 0,
530 pPerSitePrefs
, pPerSitePrefs
? *pPerSitePrefs
: 0);
532 if (pGlobalPrefs
) *pGlobalPrefs
= FALSE
;
533 if (pPerSitePrefs
) *pPerSitePrefs
= FALSE
;
538 /******************************************************************
539 * ResetProfileSharing (SHDOCVW.164)
541 HRESULT WINAPI
ResetProfileSharing(HWND hwnd
)
543 FIXME("(%p) stub\n", hwnd
);
547 /******************************************************************
548 * InstallReg_RunDLL (SHDOCVW.@)
550 void WINAPI
InstallReg_RunDLL(HWND hwnd
, HINSTANCE handle
, LPCSTR cmdline
, INT show
)
552 FIXME("(%p %p %s %x)\n", hwnd
, handle
, debugstr_a(cmdline
), show
);
555 /******************************************************************
556 * DoFileDownload (SHDOCVW.@)
558 BOOL WINAPI
DoFileDownload(LPWSTR filename
)
560 FIXME("(%s) stub\n", debugstr_w(filename
));
564 /******************************************************************
565 * DoOrganizeFavDlgW (SHDOCVW.@)
567 BOOL WINAPI
DoOrganizeFavDlgW(HWND hwnd
, LPCWSTR initDir
)
569 FIXME("(%p %s) stub\n", hwnd
, debugstr_w(initDir
));
573 /******************************************************************
574 * DoOrganizeFavDlg (SHDOCVW.@)
576 BOOL WINAPI
DoOrganizeFavDlg(HWND hwnd
, LPCSTR initDir
)
578 LPWSTR initDirW
= NULL
;
581 TRACE("(%p %s)\n", hwnd
, debugstr_a(initDir
));
584 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, initDir
, -1, NULL
, 0);
585 initDirW
= heap_alloc(len
* sizeof(WCHAR
));
586 MultiByteToWideChar(CP_ACP
, 0, initDir
, -1, initDirW
, len
);
588 res
= DoOrganizeFavDlgW(hwnd
, initDirW
);