- Fix typo in error message
[wine/testsucceed.git] / dlls / shdocvw / shdocvw_main.c
blobce93e81d94bd5f94ab4abaf484b886172a5db095
1 /*
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
21 #include "config.h"
23 #include <stdarg.h>
24 #include <stdio.h>
25 #include <string.h>
27 #define COBJMACROS
28 #define COM_NO_WINDOWS_H
30 #include "windef.h"
31 #include "winbase.h"
32 #include "winreg.h"
33 #include "winuser.h"
34 #include "winnls.h"
35 #include "ole2.h"
36 #include "shlwapi.h"
38 #include "shdocvw.h"
39 #include "uuids.h"
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
44 #include "initguid.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
48 #define MOZILLA_ACTIVEX_MESSAGE "You need to install the Mozilla ActiveX control to\n" \
49 "use Wine's builtin CLSID_WebBrowser from SHDOCVW.DLL"
51 DEFINE_GUID( CLSID_MozillaBrowser, 0x1339B54C,0x3453,0x11D2,0x93,0xB9,0x00,0x00,0x00,0x00,0x00,0x00);
53 typedef HRESULT (WINAPI *fnGetClassObject)(REFCLSID rclsid, REFIID iid, LPVOID *ppv);
55 HINSTANCE shdocvw_hinstance = 0;
56 static HMODULE SHDOCVW_hshell32 = 0;
57 static HMODULE hMozCtl = (HMODULE)~0UL;
60 /* convert a guid to a wide character string */
61 static void SHDOCVW_guid2wstr( const GUID *guid, LPWSTR wstr )
63 char str[40];
65 sprintf(str, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
66 guid->Data1, guid->Data2, guid->Data3,
67 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
68 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
69 MultiByteToWideChar( CP_ACP, 0, str, -1, wstr, 40 );
72 static BOOL SHDOCVW_GetMozctlPath( LPWSTR szPath, DWORD sz )
74 DWORD r, type;
75 BOOL ret = FALSE;
76 HKEY hkey;
77 static const WCHAR szPre[] = {
78 'S','o','f','t','w','a','r','e','\\',
79 'C','l','a','s','s','e','s','\\',
80 'C','L','S','I','D','\\',0 };
81 static const WCHAR szPost[] = {
82 '\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2',0 };
83 WCHAR szRegPath[(sizeof(szPre)+sizeof(szPost))/sizeof(WCHAR)+40];
85 strcpyW( szRegPath, szPre );
86 SHDOCVW_guid2wstr( &CLSID_MozillaBrowser, &szRegPath[strlenW(szRegPath)] );
87 strcatW( szRegPath, szPost );
89 TRACE("key = %s\n", debugstr_w( szRegPath ) );
91 r = RegOpenKeyW( HKEY_LOCAL_MACHINE, szRegPath, &hkey );
92 if( r != ERROR_SUCCESS )
93 return FALSE;
95 r = RegQueryValueExW( hkey, NULL, NULL, &type, (LPBYTE)szPath, &sz );
96 ret = ( r == ERROR_SUCCESS ) && ( type == REG_SZ );
97 RegCloseKey( hkey );
99 return ret;
102 /*************************************************************************
103 * SHDOCVW DllMain
105 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
107 TRACE("%p 0x%lx %p\n", hinst, fdwReason, fImpLoad);
108 switch (fdwReason)
110 case DLL_PROCESS_ATTACH:
111 shdocvw_hinstance = hinst;
112 break;
113 case DLL_PROCESS_DETACH:
114 if (SHDOCVW_hshell32) FreeLibrary(SHDOCVW_hshell32);
115 if (hMozCtl && hMozCtl != (HMODULE)~0UL) FreeLibrary(hMozCtl);
116 break;
118 return TRUE;
121 /*************************************************************************
122 * DllCanUnloadNow (SHDOCVW.@)
124 HRESULT WINAPI SHDOCVW_DllCanUnloadNow(void)
126 FIXME("(void): stub\n");
128 return S_FALSE;
132 static BOOL SHDOCVW_TryLoadMozillaControl()
134 WCHAR szPath[MAX_PATH];
136 if( hMozCtl != (HMODULE)~0UL )
137 return hMozCtl ? TRUE : FALSE;
139 if( !SHDOCVW_GetMozctlPath( szPath, sizeof szPath ) )
141 MESSAGE(MOZILLA_ACTIVEX_MESSAGE "\n");
142 MessageBoxA(NULL, MOZILLA_ACTIVEX_MESSAGE, "Wine", MB_OK | MB_ICONEXCLAMATION);
143 hMozCtl = 0;
144 return FALSE;
146 hMozCtl = LoadLibraryExW(szPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
147 if( !hMozCtl )
149 ERR("Can't load the Mozilla ActiveX control\n");
150 return FALSE;
152 return TRUE;
155 /*************************************************************************
156 * DllGetClassObject (SHDOCVW.@)
158 HRESULT WINAPI SHDOCVW_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
160 TRACE("\n");
162 if( IsEqualGUID( &CLSID_WebBrowser, rclsid ) &&
163 SHDOCVW_TryLoadMozillaControl() )
165 HRESULT r;
166 fnGetClassObject pGetClassObject;
168 TRACE("WebBrowser class %s\n", debugstr_guid(rclsid) );
170 pGetClassObject = (fnGetClassObject)
171 GetProcAddress( hMozCtl, "DllGetClassObject" );
173 if( !pGetClassObject )
174 return CLASS_E_CLASSNOTAVAILABLE;
175 r = pGetClassObject( &CLSID_MozillaBrowser, riid, ppv );
177 TRACE("r = %08lx *ppv = %p\n", r, *ppv );
179 return r;
182 if (IsEqualGUID(&IID_IClassFactory, riid))
184 /* Pass back our shdocvw class factory */
185 *ppv = (LPVOID)&SHDOCVW_ClassFactory;
186 IClassFactory_AddRef((IClassFactory*)&SHDOCVW_ClassFactory);
188 return S_OK;
191 return CLASS_E_CLASSNOTAVAILABLE;
194 /***********************************************************************
195 * DllGetVersion (SHDOCVW.@)
197 HRESULT WINAPI SHDOCVW_DllGetVersion (DLLVERSIONINFO *info)
199 if (info->cbSize != sizeof(DLLVERSIONINFO)) FIXME("support DLLVERSIONINFO2\n");
201 /* this is what IE6 on Windows 98 reports */
202 info->dwMajorVersion = 6;
203 info->dwMinorVersion = 0;
204 info->dwBuildNumber = 2600;
205 info->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
207 return NOERROR;
210 /*************************************************************************
211 * DllInstall (SHDOCVW.@)
213 HRESULT WINAPI SHDOCVW_DllInstall(BOOL bInstall, LPCWSTR cmdline)
215 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
217 return S_OK;
220 /*************************************************************************
221 * SHDOCVW_LoadShell32
223 * makes sure the handle to shell32 is valid
225 BOOL SHDOCVW_LoadShell32(void)
227 if (SHDOCVW_hshell32)
228 return TRUE;
229 return ((SHDOCVW_hshell32 = LoadLibraryA("shell32.dll")) != NULL);
232 /***********************************************************************
233 * @ (SHDOCVW.110)
235 * Called by Win98 explorer.exe main binary, definitely has 0
236 * parameters.
238 DWORD WINAPI WinList_Init(void)
240 FIXME("(), stub!\n");
241 return 0x0deadfeed;
244 /***********************************************************************
245 * @ (SHDOCVW.118)
247 * Called by Win98 explorer.exe main binary, definitely has only one
248 * parameter.
250 static BOOL (WINAPI *pShellDDEInit)(BOOL start) = NULL;
252 BOOL WINAPI ShellDDEInit(BOOL start)
254 TRACE("(%d)\n", start);
256 if (!pShellDDEInit)
258 if (!SHDOCVW_LoadShell32())
259 return FALSE;
260 pShellDDEInit = GetProcAddress(SHDOCVW_hshell32, (LPCSTR)188);
263 if (pShellDDEInit)
264 return pShellDDEInit(start);
265 else
266 return FALSE;
269 /***********************************************************************
270 * @ (SHDOCVW.125)
272 * Called by Win98 explorer.exe main binary, definitely has 0
273 * parameters.
275 DWORD WINAPI RunInstallUninstallStubs(void)
277 FIXME("(), stub!\n");
278 return 0x0deadbee;