cmd: mkdir: Handle multiple arguments.
[wine] / programs / 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 #include <advpub.h>
23 #include <rpcproxy.h>
24
25 #include "wine/unicode.h"
26 #include "wine/debug.h"
27
28 extern DWORD WINAPI IEWinMain(LPSTR, int);
29
30 static BOOL check_native_ie(void)
31 {
32     DWORD handle, size;
33     LPWSTR file_desc;
34     UINT bytes;
35     void* buf;
36     BOOL ret;
37
38     static const WCHAR browseui_dllW[] = {'b','r','o','w','s','e','u','i','.','d','l','l',0};
39     static const WCHAR wineW[] = {'W','i','n','e',0};
40     static const WCHAR file_desc_strW[] =
41         {'\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
42          '\\','0','4','0','9','0','4','e','4',
43          '\\','F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0};
44
45     size = GetFileVersionInfoSizeW(browseui_dllW, &handle);
46     if(!size)
47         return TRUE;
48
49     buf = HeapAlloc(GetProcessHeap(), 0, size);
50     GetFileVersionInfoW(browseui_dllW, 0, size,buf);
51
52     ret = !VerQueryValueW(buf, file_desc_strW, (void**)&file_desc, &bytes) || !strstrW(file_desc, wineW);
53
54     HeapFree(GetProcessHeap(), 0, buf);
55     return ret;
56 }
57
58 static DWORD register_iexplore(BOOL doregister)
59 {
60     HRESULT hres;
61
62     if (check_native_ie()) {
63         WINE_MESSAGE("Native IE detected, not doing registration\n");
64         return 0;
65     }
66
67     hres = RegInstallA(NULL, doregister ? "RegisterIE" : "UnregisterIE", NULL);
68     return FAILED(hres);
69 }
70
71 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
72 {
73
74     if(*cmdline == '-' || *cmdline == '/') {
75         if(!strcasecmp(cmdline+1, "regserver"))
76             return register_iexplore(TRUE);
77         if(!strcasecmp(cmdline+1, "unregserver"))
78             return register_iexplore(FALSE);
79     }
80
81     return IEWinMain(cmdline, show);
82 }