dmband: Implement band track GUID_DownloadToAudioPath parameter.
[wine.git] / programs / winecfg / main.c
blobd218d79770c3ba3ea9b22230851edfeaa5dc8639
1 /*
2 * WineCfg main entry point
4 * Copyright 2002 Jaco Greeff
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2003 Mike Hearn
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
24 #define WIN32_LEAN_AND_MEAN
26 #include <windows.h>
27 #include <commctrl.h>
28 #include <objbase.h>
29 #include <wine/debug.h>
31 #include "resource.h"
32 #include "winecfg.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
36 static INT CALLBACK
37 PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
39 switch (uMsg)
42 * hWnd = NULL, lParam == dialog resource
44 case PSCB_PRECREATE:
45 break;
47 case PSCB_INITIALIZED:
48 /* Set the window icon */
49 SendMessageW( hWnd, WM_SETICON, ICON_BIG,
50 (LPARAM)LoadIconW( (HINSTANCE)GetWindowLongPtrW(hWnd, GWLP_HINSTANCE),
51 MAKEINTRESOURCEW(IDI_WINECFG) ));
52 break;
54 default:
55 break;
57 return 0;
60 #define NUM_PROPERTY_PAGES 7
62 static INT_PTR
63 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
65 PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
66 PROPSHEETHEADERW psh;
67 int pg = 0; /* start with page 0 */
70 * Fill out the (Applications) PROPSHEETPAGE data structure
71 * for the property sheet
73 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
74 psp[pg].dwFlags = PSP_USETITLE;
75 psp[pg].hInstance = hInstance;
76 psp[pg].pszTemplate = MAKEINTRESOURCEW (IDD_APPCFG);
77 psp[pg].pszIcon = NULL;
78 psp[pg].pfnDlgProc = AppDlgProc;
79 psp[pg].pszTitle = load_string (IDS_TAB_APPLICATIONS);
80 psp[pg].lParam = 0;
81 pg++;
84 * Fill out the (Libraries) PROPSHEETPAGE data structure
85 * for the property sheet
87 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
88 psp[pg].dwFlags = PSP_USETITLE;
89 psp[pg].hInstance = hInstance;
90 psp[pg].pszTemplate = MAKEINTRESOURCEW (IDD_DLLCFG);
91 psp[pg].pszIcon = NULL;
92 psp[pg].pfnDlgProc = LibrariesDlgProc;
93 psp[pg].pszTitle = load_string (IDS_TAB_DLLS);
94 psp[pg].lParam = 0;
95 pg++;
98 * Fill out the (X11Drv) PROPSHEETPAGE data structure
99 * for the property sheet
101 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
102 psp[pg].dwFlags = PSP_USETITLE;
103 psp[pg].hInstance = hInstance;
104 psp[pg].pszTemplate = MAKEINTRESOURCEW (IDD_GRAPHCFG);
105 psp[pg].pszIcon = NULL;
106 psp[pg].pfnDlgProc = GraphDlgProc;
107 psp[pg].pszTitle = load_string (IDS_TAB_GRAPHICS);
108 psp[pg].lParam = 0;
109 pg++;
111 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
112 psp[pg].dwFlags = PSP_USETITLE;
113 psp[pg].hInstance = hInstance;
114 psp[pg].pszTemplate = MAKEINTRESOURCEW (IDD_DESKTOP_INTEGRATION);
115 psp[pg].pszIcon = NULL;
116 psp[pg].pfnDlgProc = ThemeDlgProc;
117 psp[pg].pszTitle = load_string (IDS_TAB_DESKTOP_INTEGRATION);
118 psp[pg].lParam = 0;
119 pg++;
121 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
122 psp[pg].dwFlags = PSP_USETITLE;
123 psp[pg].hInstance = hInstance;
124 psp[pg].pszTemplate = MAKEINTRESOURCEW (IDD_DRIVECFG);
125 psp[pg].pszIcon = NULL;
126 psp[pg].pfnDlgProc = DriveDlgProc;
127 psp[pg].pszTitle = load_string (IDS_TAB_DRIVES);
128 psp[pg].lParam = 0;
129 pg++;
131 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
132 psp[pg].dwFlags = PSP_USETITLE;
133 psp[pg].hInstance = hInstance;
134 psp[pg].pszTemplate = MAKEINTRESOURCEW (IDD_AUDIOCFG);
135 psp[pg].pszIcon = NULL;
136 psp[pg].pfnDlgProc = AudioDlgProc;
137 psp[pg].pszTitle = load_string (IDS_TAB_AUDIO);
138 psp[pg].lParam = 0;
139 pg++;
142 * Fill out the (General) PROPSHEETPAGE data structure
143 * for the property sheet
145 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
146 psp[pg].dwFlags = PSP_USETITLE;
147 psp[pg].hInstance = hInstance;
148 psp[pg].pszTemplate = MAKEINTRESOURCEW (IDD_ABOUTCFG);
149 psp[pg].pszIcon = NULL;
150 psp[pg].pfnDlgProc = AboutDlgProc;
151 psp[pg].pszTitle = load_string (IDS_TAB_ABOUT);
152 psp[pg].lParam = 0;
153 pg++;
156 * Fill out the PROPSHEETHEADER
158 psh.dwSize = sizeof (PROPSHEETHEADERW);
159 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
160 psh.hwndParent = hOwner;
161 psh.hInstance = hInstance;
162 psh.pszIcon = MAKEINTRESOURCEW (IDI_WINECFG);
163 psh.pszCaption = load_string (IDS_WINECFG_TITLE);
164 psh.nPages = NUM_PROPERTY_PAGES;
165 psh.ppsp = psp;
166 psh.pfnCallback = PropSheetCallback;
167 psh.nStartPage = 0;
170 * Display the modal property sheet
172 return PropertySheetW (&psh);
175 /******************************************************************************
176 * Name : ProcessCmdLine
177 * Description: Checks command line parameters
178 * Parameters : lpCmdLine - the command line
179 * Returns : The return value to return from WinMain, or -1 to continue
180 * program execution.
182 static int
183 ProcessCmdLine(LPWSTR lpCmdLine)
185 if (!(lpCmdLine[0] == '/' || lpCmdLine[0] == '-'))
187 return -1;
189 if (lpCmdLine[1] == 'V' || lpCmdLine[1] == 'v')
191 if (wcslen(lpCmdLine) > 4)
192 return set_winver_from_string(&lpCmdLine[3]) ? 0 : 1;
194 print_current_winver();
195 return 0;
198 if (lpCmdLine[1] == '?')
200 printf("Usage: winecfg [options]\n\n");
201 printf("Options:\n");
202 printf(" [no option] Launch the graphical version of this program.\n");
203 printf(" /v Display the current global Windows version.\n");
204 printf(" /v version Set global Windows version to 'version'.\n");
205 printf(" /? Display this information and exit.\n\n");
206 printf("Valid versions for 'version':\n\n");
207 print_windows_versions();
209 return 0;
212 return -1;
215 /*****************************************************************************
216 * Name : WinMain
217 * Description: Main windows entry point
218 * Parameters : hInstance
219 * hPrev
220 * szCmdLine
221 * nShow
222 * Returns : Program exit code
224 int WINAPI
225 wWinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPWSTR cmdline, int nShow)
227 BOOL is_wow64;
228 int cmd_ret;
230 if (IsWow64Process( GetCurrentProcess(), &is_wow64 ) && is_wow64)
232 STARTUPINFOW si;
233 PROCESS_INFORMATION pi;
234 WCHAR filename[] = L"C:\\windows\\system32\\winecfg.exe";
235 void *redir;
236 DWORD exit_code;
238 memset( &si, 0, sizeof(si) );
239 si.cb = sizeof(si);
241 Wow64DisableWow64FsRedirection( &redir );
242 if (CreateProcessW( filename, GetCommandLineW(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
244 WINE_TRACE( "restarting %s\n", wine_dbgstr_w(filename) );
245 WaitForSingleObject( pi.hProcess, INFINITE );
246 GetExitCodeProcess( pi.hProcess, &exit_code );
247 ExitProcess( exit_code );
249 else WINE_ERR( "failed to restart 64-bit %s, err %ld\n", wine_dbgstr_w(filename), GetLastError() );
250 Wow64RevertWow64FsRedirection( redir );
253 if (initialize(hInstance)) {
254 WINE_ERR("initialization failed, aborting\n");
255 ExitProcess(1);
258 cmd_ret = ProcessCmdLine(cmdline);
259 if (cmd_ret >= 0) return cmd_ret;
262 * The next 9 lines should be all that is needed
263 * for the Wine Configuration property sheet
265 InitCommonControls ();
266 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
267 if (doPropertySheet (hInstance, NULL) > 0) {
268 WINE_TRACE("OK\n");
269 } else {
270 WINE_TRACE("Cancel\n");
272 CoUninitialize();
273 ExitProcess (0);
275 return 0;