2 * SHDOCVW - Internet Explorer Web Control
4 * Copyright 2001 John R. Sheets (for CodeWeavers)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #define COM_NO_WINDOWS_H
38 #include "wine/unicode.h"
39 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
46 DEFINE_GUID( CLSID_MozillaBrowser, 0x1339B54C,0x3453,0x11D2,0x93,0xB9,0x00,0x00,0x00,0x00,0x00,0x00);
48 typedef HRESULT (WINAPI *fnGetClassObject)(REFCLSID rclsid, REFIID iid, LPVOID *ppv);
50 HINSTANCE shdocvw_hinstance = 0;
51 static HMODULE SHDOCVW_hshell32 = 0;
52 static HMODULE hMozCtl = (HMODULE)~0UL;
55 /* convert a guid to a wide character string */
56 static void SHDOCVW_guid2wstr( const GUID *guid, LPWSTR wstr )
60 sprintf(str, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
61 guid->Data1, guid->Data2, guid->Data3,
62 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
63 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
64 MultiByteToWideChar( CP_ACP, 0, str, -1, wstr, 40 );
67 static BOOL SHDOCVW_GetMozctlPath( LPWSTR szPath, DWORD sz )
72 static const WCHAR szPre[] = {
73 'S','o','f','t','w','a','r','e','\\',
74 'C','l','a','s','s','e','s','\\',
75 'C','L','S','I','D','\\',0 };
76 static const WCHAR szPost[] = {
77 '\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2',0 };
78 WCHAR szRegPath[(sizeof(szPre)+sizeof(szPost))/sizeof(WCHAR)+40];
80 strcpyW( szRegPath, szPre );
81 SHDOCVW_guid2wstr( &CLSID_MozillaBrowser, &szRegPath[strlenW(szRegPath)] );
82 strcatW( szRegPath, szPost );
84 TRACE("key = %s\n", debugstr_w( szRegPath ) );
86 r = RegOpenKeyW( HKEY_LOCAL_MACHINE, szRegPath, &hkey );
87 if( r != ERROR_SUCCESS )
90 r = RegQueryValueExW( hkey, NULL, NULL, &type, (LPBYTE)szPath, &sz );
91 ret = ( r == ERROR_SUCCESS ) && ( type == REG_SZ );
97 /*************************************************************************
100 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
102 TRACE("%p 0x%lx %p\n", hinst, fdwReason, fImpLoad);
105 case DLL_PROCESS_ATTACH:
106 shdocvw_hinstance = hinst;
108 case DLL_PROCESS_DETACH:
109 if (SHDOCVW_hshell32) FreeLibrary(SHDOCVW_hshell32);
110 if (hMozCtl && hMozCtl != (HMODULE)~0UL) FreeLibrary(hMozCtl);
116 /*************************************************************************
117 * DllCanUnloadNow (SHDOCVW.@)
119 HRESULT WINAPI SHDOCVW_DllCanUnloadNow(void)
121 FIXME("(void): stub\n");
127 static BOOL SHDOCVW_TryLoadMozillaControl()
129 WCHAR szPath[MAX_PATH];
131 if( hMozCtl != (HMODULE)~0UL )
132 return hMozCtl ? TRUE : FALSE;
134 if( !SHDOCVW_GetMozctlPath( szPath, sizeof szPath ) )
136 MESSAGE("You need to install the Mozilla ActiveX control to\n");
137 MESSAGE("use Wine's builtin CLSID_WebBrowser from SHDOCVW.DLL\n");
140 hMozCtl = LoadLibraryExW(szPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
143 ERR("Can't load the Mozilla ActiveX control\n");
149 /*************************************************************************
150 * DllGetClassObject (SHDOCVW.@)
152 HRESULT WINAPI SHDOCVW_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
156 if( IsEqualGUID( &CLSID_WebBrowser, rclsid ) &&
157 SHDOCVW_TryLoadMozillaControl() )
160 fnGetClassObject pGetClassObject;
162 TRACE("WebBrowser class %s\n", debugstr_guid(rclsid) );
164 pGetClassObject = (fnGetClassObject)
165 GetProcAddress( hMozCtl, "DllGetClassObject" );
167 if( !pGetClassObject )
168 return CLASS_E_CLASSNOTAVAILABLE;
169 r = pGetClassObject( &CLSID_MozillaBrowser, riid, ppv );
171 TRACE("r = %08lx *ppv = %p\n", r, *ppv );
176 if (IsEqualGUID(&IID_IClassFactory, riid))
178 /* Pass back our shdocvw class factory */
179 *ppv = (LPVOID)&SHDOCVW_ClassFactory;
180 IClassFactory_AddRef((IClassFactory*)&SHDOCVW_ClassFactory);
185 return CLASS_E_CLASSNOTAVAILABLE;
188 /***********************************************************************
189 * DllGetVersion (SHDOCVW.@)
191 HRESULT WINAPI SHDOCVW_DllGetVersion (DLLVERSIONINFO *info)
193 if (info->cbSize != sizeof(DLLVERSIONINFO)) FIXME("support DLLVERSIONINFO2\n");
195 /* this is what IE6 on Windows 98 reports */
196 info->dwMajorVersion = 6;
197 info->dwMinorVersion = 0;
198 info->dwBuildNumber = 2600;
199 info->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
204 /*************************************************************************
205 * DllInstall (SHDOCVW.@)
207 HRESULT WINAPI SHDOCVW_DllInstall(BOOL bInstall, LPCWSTR cmdline)
209 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
214 /*************************************************************************
215 * SHDOCVW_LoadShell32
217 * makes sure the handle to shell32 is valid
219 BOOL SHDOCVW_LoadShell32(void)
221 if (SHDOCVW_hshell32)
223 return ((SHDOCVW_hshell32 = LoadLibraryA("shell32.dll")) != NULL);
226 /***********************************************************************
229 * Called by Win98 explorer.exe main binary, definitely has 0
232 DWORD WINAPI WinList_Init(void)
234 FIXME("(), stub!\n");
238 /***********************************************************************
241 * Called by Win98 explorer.exe main binary, definitely has only one
244 static BOOL (WINAPI *pShellDDEInit)(BOOL start) = NULL;
246 BOOL WINAPI ShellDDEInit(BOOL start)
248 TRACE("(%d)\n", start);
252 if (!SHDOCVW_LoadShell32())
254 pShellDDEInit = GetProcAddress(SHDOCVW_hshell32, (LPCSTR)188);
258 return pShellDDEInit(start);
263 /***********************************************************************
266 * Called by Win98 explorer.exe main binary, definitely has 0
269 DWORD WINAPI RunInstallUninstallStubs(void)
271 FIXME("(), stub!\n");