[SNDVOL32] Add the small line dialog
[reactos.git] / base / applications / iexplore / main.c
1 /*
2 * Internet Explorer wrapper
3 *
4 * Copyright 2006 Mike McCormack
5 *
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.
10 *
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.
15 *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 //#include <windows.h>
22
23 #include <stdarg.h>
24
25 #define WIN32_NO_STATUS
26 #define _INC_WINDOWS
27 #define COM_NO_WINDOWS_H
28
29 #include <windef.h>
30 #include <winbase.h>
31 #include <winuser.h>
32 #include <winreg.h>
33 #include <winver.h>
34
35 #include <advpub.h>
36 //#include <ole2.h>
37 //#include <rpcproxy.h>
38
39 #include <wine/unicode.h>
40 #include <wine/debug.h>
41
42 extern DWORD WINAPI IEWinMain(const WCHAR*, int);
43
44 static BOOL check_native_ie(void)
45 {
46 DWORD handle, size;
47 LPWSTR file_desc;
48 UINT bytes;
49 void* buf;
50 BOOL ret = TRUE;
51 LPWORD translation;
52
53 static const WCHAR browseui_dllW[] = {'b','r','o','w','s','e','u','i','.','d','l','l',0};
54 static const WCHAR wineW[] = {'W','i','n','e',0};
55 static const WCHAR translationW[] =
56 {'\\','V','a','r','F','i','l','e','I','n','f','o',
57 '\\','T','r','a','n','s','l','a','t','i','o','n',0};
58 static const WCHAR file_desc_fmtW[] =
59 {'\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
60 '\\','%','0','4','x','%','0','4','x',
61 '\\','F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0};
62 WCHAR file_desc_strW[48];
63
64 size = GetFileVersionInfoSizeW(browseui_dllW, &handle);
65 if(!size)
66 return TRUE;
67
68 buf = HeapAlloc(GetProcessHeap(), 0, size);
69 GetFileVersionInfoW(browseui_dllW, 0, size,buf);
70 if (VerQueryValueW(buf, translationW, (void **)&translation, &bytes))
71 {
72 wsprintfW(file_desc_strW, file_desc_fmtW, translation[0], translation[1]);
73 ret = !VerQueryValueW(buf, file_desc_strW, (void**)&file_desc, &bytes) || !strstrW(file_desc, wineW);
74 }
75
76 HeapFree(GetProcessHeap(), 0, buf);
77 return ret;
78 }
79
80 static DWORD register_iexplore(BOOL doregister)
81 {
82 HRESULT hres;
83
84 if (check_native_ie()) {
85 WINE_MESSAGE("Native IE detected, not doing registration\n");
86 return 0;
87 }
88
89 hres = RegInstallA(NULL, doregister ? "RegisterIE" : "UnregisterIE", NULL);
90 return FAILED(hres);
91 }
92
93 int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE prev, WCHAR *cmdline, int show)
94 {
95 static const WCHAR regserverW[] = {'r','e','g','s','e','r','v','e','r',0};
96 static const WCHAR unregserverW[] = {'u','n','r','e','g','s','e','r','v','e','r',0};
97
98 if(*cmdline == '-' || *cmdline == '/') {
99 if(!strcmpiW(cmdline+1, regserverW))
100 return register_iexplore(TRUE);
101 if(!strcmpiW(cmdline+1, unregserverW))
102 return register_iexplore(FALSE);
103 }
104
105 return IEWinMain(cmdline, show);
106 }