push a6a7df41ae272b3b1bf5fcfb544267c1e96afa99
[wine/hacks.git] / dlls / shdocvw / shdocvw_main.c
blobc9deff19cda66259ff57ee83f1372b6add89274d
1 /*
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
23 #include "config.h"
25 #include <stdarg.h>
26 #include <stdio.h>
28 #include "wine/unicode.h"
29 #include "wine/debug.h"
31 #include "shdocvw.h"
33 #include "winreg.h"
34 #include "shlwapi.h"
35 #include "wininet.h"
37 #include "initguid.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
41 LONG SHDOCVW_refCount = 0;
43 HINSTANCE shdocvw_hinstance = 0;
44 static HMODULE SHDOCVW_hshell32 = 0;
45 static ITypeInfo *wb_typeinfo = NULL;
47 HRESULT get_typeinfo(ITypeInfo **typeinfo)
49 ITypeLib *typelib;
50 HRESULT hres;
52 if(wb_typeinfo) {
53 *typeinfo = wb_typeinfo;
54 return S_OK;
57 hres = LoadRegTypeLib(&LIBID_SHDocVw, 1, 1, LOCALE_SYSTEM_DEFAULT, &typelib);
58 if(FAILED(hres)) {
59 ERR("LoadRegTypeLib failed: %08x\n", hres);
60 return hres;
63 hres = ITypeLib_GetTypeInfoOfGuid(typelib, &IID_IWebBrowser2, &wb_typeinfo);
64 ITypeLib_Release(typelib);
66 *typeinfo = wb_typeinfo;
67 return hres;
70 /*************************************************************************
71 * SHDOCVW DllMain
73 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
75 TRACE("%p 0x%x %p\n", hinst, fdwReason, fImpLoad);
76 switch (fdwReason)
78 case DLL_PROCESS_ATTACH:
79 shdocvw_hinstance = hinst;
80 register_iewindow_class();
81 break;
82 case DLL_PROCESS_DETACH:
83 if (SHDOCVW_hshell32) FreeLibrary(SHDOCVW_hshell32);
84 unregister_iewindow_class();
85 if(wb_typeinfo)
86 ITypeInfo_Release(wb_typeinfo);
87 break;
89 return TRUE;
92 /*************************************************************************
93 * DllCanUnloadNow (SHDOCVW.@)
95 HRESULT WINAPI DllCanUnloadNow(void)
97 return SHDOCVW_refCount ? S_FALSE : S_OK;
100 /***********************************************************************
101 * DllGetVersion (SHDOCVW.@)
103 HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *info)
105 if (info->cbSize != sizeof(DLLVERSIONINFO)) FIXME("support DLLVERSIONINFO2\n");
107 /* this is what IE6 on Windows 98 reports */
108 info->dwMajorVersion = 6;
109 info->dwMinorVersion = 0;
110 info->dwBuildNumber = 2600;
111 info->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
113 return NOERROR;
116 /*************************************************************************
117 * DllInstall (SHDOCVW.@)
119 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
121 FIXME("(%s, %s): stub!\n", bInstall ? "TRUE":"FALSE", debugstr_w(cmdline));
123 return S_OK;
126 /*************************************************************************
127 * SHDOCVW_LoadShell32
129 * makes sure the handle to shell32 is valid
131 static BOOL SHDOCVW_LoadShell32(void)
133 if (SHDOCVW_hshell32)
134 return TRUE;
135 return ((SHDOCVW_hshell32 = LoadLibraryA("shell32.dll")) != NULL);
138 /***********************************************************************
139 * @ (SHDOCVW.110)
141 * Called by Win98 explorer.exe main binary, definitely has 0
142 * parameters.
144 DWORD WINAPI WinList_Init(void)
146 FIXME("(), stub!\n");
147 return 0x0deadfeed;
150 /***********************************************************************
151 * @ (SHDOCVW.118)
153 * Called by Win98 explorer.exe main binary, definitely has only one
154 * parameter.
156 static BOOL (WINAPI *pShellDDEInit)(BOOL start) = NULL;
158 BOOL WINAPI ShellDDEInit(BOOL start)
160 TRACE("(%d)\n", start);
162 if (!pShellDDEInit)
164 if (!SHDOCVW_LoadShell32())
165 return FALSE;
166 pShellDDEInit = (void *)GetProcAddress(SHDOCVW_hshell32, (LPCSTR)188);
169 if (pShellDDEInit)
170 return pShellDDEInit(start);
171 else
172 return FALSE;
175 /***********************************************************************
176 * @ (SHDOCVW.125)
178 * Called by Win98 explorer.exe main binary, definitely has 0
179 * parameters.
181 DWORD WINAPI RunInstallUninstallStubs(void)
183 FIXME("(), stub!\n");
184 return 0x0deadbee;
187 /***********************************************************************
188 * SetQueryNetSessionCount (SHDOCVW.@)
190 DWORD WINAPI SetQueryNetSessionCount(DWORD arg)
192 FIXME("(%u), stub!\n", arg);
193 return 0;
196 /**********************************************************************
197 * OpenURL (SHDOCVW.@)
199 void WINAPI OpenURL(HWND hWnd, HINSTANCE hInst, LPCSTR lpcstrUrl, int nShowCmd)
201 FIXME("%p %p %s %d\n", hWnd, hInst, debugstr_a(lpcstrUrl), nShowCmd);
204 /**********************************************************************
205 * Some forwards (by ordinal) to SHLWAPI
208 static void* fetch_shlwapi_ordinal(unsigned ord)
210 static const WCHAR shlwapiW[] = {'s','h','l','w','a','p','i','.','d','l','l','\0'};
211 static HANDLE h;
213 if (!h && !(h = GetModuleHandleW(shlwapiW))) return NULL;
214 return (void*)GetProcAddress(h, (const char*)ord);
217 /******************************************************************
218 * WhichPlatformFORWARD (SHDOCVW.@)
220 DWORD WINAPI WhichPlatformFORWARD(void)
222 static DWORD (WINAPI *p)(void);
224 if (p || (p = fetch_shlwapi_ordinal(276))) return p();
225 return 1; /* not integrated, see shlwapi.WhichPlatform */
228 /******************************************************************
229 * StopWatchModeFORWARD (SHDOCVW.@)
231 void WINAPI StopWatchModeFORWARD(void)
233 static void (WINAPI *p)(void);
235 if (p || (p = fetch_shlwapi_ordinal(241))) p();
238 /******************************************************************
239 * StopWatchFlushFORWARD (SHDOCVW.@)
241 void WINAPI StopWatchFlushFORWARD(void)
243 static void (WINAPI *p)(void);
245 if (p || (p = fetch_shlwapi_ordinal(242))) p();
248 /******************************************************************
249 * StopWatchWFORWARD (SHDOCVW.@)
251 DWORD WINAPI StopWatchWFORWARD(DWORD dwClass, LPCWSTR lpszStr, DWORD dwUnknown,
252 DWORD dwMode, DWORD dwTimeStamp)
254 static DWORD (WINAPI *p)(DWORD, LPCWSTR, DWORD, DWORD, DWORD);
256 if (p || (p = fetch_shlwapi_ordinal(243)))
257 return p(dwClass, lpszStr, dwUnknown, dwMode, dwTimeStamp);
258 return ERROR_CALL_NOT_IMPLEMENTED;
261 /******************************************************************
262 * StopWatchAFORWARD (SHDOCVW.@)
264 DWORD WINAPI StopWatchAFORWARD(DWORD dwClass, LPCSTR lpszStr, DWORD dwUnknown,
265 DWORD dwMode, DWORD dwTimeStamp)
267 static DWORD (WINAPI *p)(DWORD, LPCSTR, DWORD, DWORD, DWORD);
269 if (p || (p = fetch_shlwapi_ordinal(244)))
270 return p(dwClass, lpszStr, dwUnknown, dwMode, dwTimeStamp);
271 return ERROR_CALL_NOT_IMPLEMENTED;
274 /******************************************************************
275 * URLSubRegQueryA (SHDOCVW.151)
277 HRESULT WINAPI URLSubRegQueryA(LPCSTR regpath, LPCSTR name, DWORD type,
278 LPSTR out, DWORD outlen, DWORD unknown)
280 CHAR buffer[INTERNET_MAX_URL_LENGTH];
281 DWORD len;
282 LONG res;
284 TRACE("(%s, %s, %d, %p, %d, %d)\n", debugstr_a(regpath), debugstr_a(name),
285 type, out, outlen, unknown);
287 if (!out) return S_OK;
289 len = sizeof(buffer);
290 res = SHRegGetUSValueA(regpath, name, NULL, buffer, &len, FALSE, NULL, 0);
291 if (!res) {
292 lstrcpynA(out, buffer, outlen);
293 return S_OK;
296 return E_FAIL;