Add AppDefaults app selection to control panel
[wine/gsoc-2012-control.git] / programs / iexplore / main.c
blob73fec2567fb725e513998896cadef30e04ac3b75
1 /*
2 * Internet Explorer wrapper
4 * Copyright 2006 Mike McCormack
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <windows.h>
22 #include <advpub.h>
23 #include <ole2.h>
24 #include <rpcproxy.h>
26 #include "wine/unicode.h"
27 #include "wine/debug.h"
29 extern DWORD WINAPI IEWinMain(const WCHAR*, int);
31 static BOOL check_native_ie(void)
33 DWORD handle, size;
34 LPWSTR file_desc;
35 UINT bytes;
36 void* buf;
37 BOOL ret;
39 static const WCHAR browseui_dllW[] = {'b','r','o','w','s','e','u','i','.','d','l','l',0};
40 static const WCHAR wineW[] = {'W','i','n','e',0};
41 static const WCHAR file_desc_strW[] =
42 {'\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
43 '\\','0','4','0','9','0','4','e','4',
44 '\\','F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0};
46 size = GetFileVersionInfoSizeW(browseui_dllW, &handle);
47 if(!size)
48 return TRUE;
50 buf = HeapAlloc(GetProcessHeap(), 0, size);
51 GetFileVersionInfoW(browseui_dllW, 0, size,buf);
53 ret = !VerQueryValueW(buf, file_desc_strW, (void**)&file_desc, &bytes) || !strstrW(file_desc, wineW);
55 HeapFree(GetProcessHeap(), 0, buf);
56 return ret;
59 static DWORD register_iexplore(BOOL doregister)
61 HRESULT hres;
63 if (check_native_ie()) {
64 WINE_MESSAGE("Native IE detected, not doing registration\n");
65 return 0;
68 hres = RegInstallA(NULL, doregister ? "RegisterIE" : "UnregisterIE", NULL);
69 return FAILED(hres);
72 int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE prev, WCHAR *cmdline, int show)
74 static const WCHAR regserverW[] = {'r','e','g','s','e','r','v','e','r',0};
75 static const WCHAR unregserverW[] = {'u','n','r','e','g','s','e','r','v','e','r',0};
77 if(*cmdline == '-' || *cmdline == '/') {
78 if(!strcmpiW(cmdline+1, regserverW))
79 return register_iexplore(TRUE);
80 if(!strcmpiW(cmdline+1, unregserverW))
81 return register_iexplore(FALSE);
84 return IEWinMain(cmdline, show);