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 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
32 #include <wine/debug.h>
37 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
40 PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
45 * hWnd = NULL, lParam == dialog resource
50 case PSCB_INITIALIZED:
51 /* Set the window icon */
52 SendMessageW( hWnd, WM_SETICON, ICON_BIG,
53 (LPARAM)LoadIconW( (HINSTANCE)GetWindowLongPtrW(hWnd, GWLP_HINSTANCE),
54 MAKEINTRESOURCEW(IDI_WINECFG) ));
63 #define NUM_PROPERTY_PAGES 7
66 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
68 PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
70 int pg = 0; /* start with page 0 */
73 * Fill out the (Applications) PROPSHEETPAGE data structure
74 * for the property sheet
76 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
77 psp[pg].dwFlags = PSP_USETITLE;
78 psp[pg].hInstance = hInstance;
79 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_APPCFG);
80 psp[pg].u2.pszIcon = NULL;
81 psp[pg].pfnDlgProc = AppDlgProc;
82 psp[pg].pszTitle = load_string (IDS_TAB_APPLICATIONS);
87 * Fill out the (Libraries) PROPSHEETPAGE data structure
88 * for the property sheet
90 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
91 psp[pg].dwFlags = PSP_USETITLE;
92 psp[pg].hInstance = hInstance;
93 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DLLCFG);
94 psp[pg].u2.pszIcon = NULL;
95 psp[pg].pfnDlgProc = LibrariesDlgProc;
96 psp[pg].pszTitle = load_string (IDS_TAB_DLLS);
101 * Fill out the (X11Drv) PROPSHEETPAGE data structure
102 * for the property sheet
104 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
105 psp[pg].dwFlags = PSP_USETITLE;
106 psp[pg].hInstance = hInstance;
107 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_GRAPHCFG);
108 psp[pg].u2.pszIcon = NULL;
109 psp[pg].pfnDlgProc = GraphDlgProc;
110 psp[pg].pszTitle = load_string (IDS_TAB_GRAPHICS);
114 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
115 psp[pg].dwFlags = PSP_USETITLE;
116 psp[pg].hInstance = hInstance;
117 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DESKTOP_INTEGRATION);
118 psp[pg].u2.pszIcon = NULL;
119 psp[pg].pfnDlgProc = ThemeDlgProc;
120 psp[pg].pszTitle = load_string (IDS_TAB_DESKTOP_INTEGRATION);
124 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
125 psp[pg].dwFlags = PSP_USETITLE;
126 psp[pg].hInstance = hInstance;
127 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DRIVECFG);
128 psp[pg].u2.pszIcon = NULL;
129 psp[pg].pfnDlgProc = DriveDlgProc;
130 psp[pg].pszTitle = load_string (IDS_TAB_DRIVES);
134 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
135 psp[pg].dwFlags = PSP_USETITLE;
136 psp[pg].hInstance = hInstance;
137 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_AUDIOCFG);
138 psp[pg].u2.pszIcon = NULL;
139 psp[pg].pfnDlgProc = AudioDlgProc;
140 psp[pg].pszTitle = load_string (IDS_TAB_AUDIO);
145 * Fill out the (General) PROPSHEETPAGE data structure
146 * for the property sheet
148 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
149 psp[pg].dwFlags = PSP_USETITLE;
150 psp[pg].hInstance = hInstance;
151 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_ABOUTCFG);
152 psp[pg].u2.pszIcon = NULL;
153 psp[pg].pfnDlgProc = AboutDlgProc;
154 psp[pg].pszTitle = load_string (IDS_TAB_ABOUT);
159 * Fill out the PROPSHEETHEADER
161 psh.dwSize = sizeof (PROPSHEETHEADERW);
162 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
163 psh.hwndParent = hOwner;
164 psh.hInstance = hInstance;
165 psh.u.pszIcon = MAKEINTRESOURCEW (IDI_WINECFG);
166 psh.pszCaption = load_string (IDS_WINECFG_TITLE);
167 psh.nPages = NUM_PROPERTY_PAGES;
169 psh.pfnCallback = PropSheetCallback;
170 psh.u2.nStartPage = 0;
173 * Display the modal property sheet
175 return PropertySheetW (&psh);
178 /******************************************************************************
179 * Name : ProcessCmdLine
180 * Description: Checks command line parameters for 'autodetect drives' option
181 * Parameters : lpCmdLine - the command line
182 * Returns : TRUE - if '/D' was found. Drive autodetection was carried out.
183 * FALSE - no '/D' option found in command line
184 * Notes : This is a very simple implementation, which only works
185 * correctly if the one and only cmd line option is '/D' or
186 * no option at all. Has to be reworked, if more options are to
190 ProcessCmdLine(LPSTR lpCmdLine)
192 if ((lpCmdLine[0] == '/' || lpCmdLine[0] == '-') &&
193 (lpCmdLine[1] == 'D' || lpCmdLine[1] == 'd'))
196 if (autodetect_drives()) {
197 apply_drive_changes();
205 /*****************************************************************************
207 * Description: Main windows entry point
208 * Parameters : hInstance
212 * Returns : Program exit code
215 WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
219 if (IsWow64Process( GetCurrentProcess(), &is_wow64 ) && is_wow64)
222 PROCESS_INFORMATION pi;
223 WCHAR filename[MAX_PATH];
227 memset( &si, 0, sizeof(si) );
229 GetModuleFileNameW( 0, filename, MAX_PATH );
231 Wow64DisableWow64FsRedirection( &redir );
232 if (CreateProcessW( filename, GetCommandLineW(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
234 WINE_TRACE( "restarting %s\n", wine_dbgstr_w(filename) );
235 WaitForSingleObject( pi.hProcess, INFINITE );
236 GetExitCodeProcess( pi.hProcess, &exit_code );
237 ExitProcess( exit_code );
239 else WINE_ERR( "failed to restart 64-bit %s, err %d\n", wine_dbgstr_w(filename), GetLastError() );
240 Wow64RevertWow64FsRedirection( redir );
243 if (ProcessCmdLine(szCmdLine)) {
247 if (initialize(hInstance) != 0) {
248 WINE_ERR("initialization failed, aborting\n");
253 * The next 9 lines should be all that is needed
254 * for the Wine Configuration property sheet
256 InitCommonControls ();
257 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
258 if (doPropertySheet (hInstance, NULL) > 0) {
261 WINE_TRACE("Cancel\n");