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 static INT_PTR CALLBACK
64 AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
71 switch(((LPNMHDR)lParam)->code)
74 /*save registration info to registry */
75 owner = get_text(hDlg, IDC_ABT_OWNER);
76 org = get_text(hDlg, IDC_ABT_ORG);
78 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
79 "RegisteredOwner", owner ? owner : "");
80 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
81 "RegisteredOrganization", org ? org : "");
82 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
83 "RegisteredOwner", owner ? owner : "");
84 set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
85 "RegisteredOrganization", org ? org : "");
88 HeapFree(GetProcessHeap(), 0, owner);
89 HeapFree(GetProcessHeap(), 0, org);
95 /* read owner and organization info from registry, load it into text box */
96 owner = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
97 "RegisteredOwner", "");
98 org = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
99 "RegisteredOrganization", "");
101 SetDlgItemText(hDlg, IDC_ABT_OWNER, owner);
102 SetDlgItemText(hDlg, IDC_ABT_ORG, org);
104 SendMessage(GetParent(hDlg), PSM_UNCHANGED, 0, 0);
106 HeapFree(GetProcessHeap(), 0, owner);
107 HeapFree(GetProcessHeap(), 0, org);
111 switch(HIWORD(wParam))
114 /* enable apply button */
115 SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
123 #define NUM_PROPERTY_PAGES 7
126 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
128 PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
129 PROPSHEETHEADERW psh;
130 int pg = 0; /* start with page 0 */
133 * Fill out the (Applications) PROPSHEETPAGE data structure
134 * for the property sheet
136 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
137 psp[pg].dwFlags = PSP_USETITLE;
138 psp[pg].hInstance = hInstance;
139 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_APPCFG);
140 psp[pg].u2.pszIcon = NULL;
141 psp[pg].pfnDlgProc = AppDlgProc;
142 psp[pg].pszTitle = load_string (IDS_TAB_APPLICATIONS);
147 * Fill out the (Libraries) PROPSHEETPAGE data structure
148 * for the property sheet
150 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
151 psp[pg].dwFlags = PSP_USETITLE;
152 psp[pg].hInstance = hInstance;
153 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DLLCFG);
154 psp[pg].u2.pszIcon = NULL;
155 psp[pg].pfnDlgProc = LibrariesDlgProc;
156 psp[pg].pszTitle = load_string (IDS_TAB_DLLS);
161 * Fill out the (X11Drv) PROPSHEETPAGE data structure
162 * for the property sheet
164 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
165 psp[pg].dwFlags = PSP_USETITLE;
166 psp[pg].hInstance = hInstance;
167 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_GRAPHCFG);
168 psp[pg].u2.pszIcon = NULL;
169 psp[pg].pfnDlgProc = GraphDlgProc;
170 psp[pg].pszTitle = load_string (IDS_TAB_GRAPHICS);
174 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
175 psp[pg].dwFlags = PSP_USETITLE;
176 psp[pg].hInstance = hInstance;
177 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DESKTOP_INTEGRATION);
178 psp[pg].u2.pszIcon = NULL;
179 psp[pg].pfnDlgProc = ThemeDlgProc;
180 psp[pg].pszTitle = load_string (IDS_TAB_DESKTOP_INTEGRATION);
184 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
185 psp[pg].dwFlags = PSP_USETITLE;
186 psp[pg].hInstance = hInstance;
187 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DRIVECFG);
188 psp[pg].u2.pszIcon = NULL;
189 psp[pg].pfnDlgProc = DriveDlgProc;
190 psp[pg].pszTitle = load_string (IDS_TAB_DRIVES);
194 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
195 psp[pg].dwFlags = PSP_USETITLE;
196 psp[pg].hInstance = hInstance;
197 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_AUDIOCFG);
198 psp[pg].u2.pszIcon = NULL;
199 psp[pg].pfnDlgProc = AudioDlgProc;
200 psp[pg].pszTitle = load_string (IDS_TAB_AUDIO);
205 * Fill out the (General) PROPSHEETPAGE data structure
206 * for the property sheet
208 psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
209 psp[pg].dwFlags = PSP_USETITLE;
210 psp[pg].hInstance = hInstance;
211 psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_ABOUTCFG);
212 psp[pg].u2.pszIcon = NULL;
213 psp[pg].pfnDlgProc = AboutDlgProc;
214 psp[pg].pszTitle = load_string (IDS_TAB_ABOUT);
219 * Fill out the PROPSHEETHEADER
221 psh.dwSize = sizeof (PROPSHEETHEADERW);
222 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
223 psh.hwndParent = hOwner;
224 psh.hInstance = hInstance;
225 psh.u.pszIcon = MAKEINTRESOURCEW (IDI_WINECFG);
226 psh.pszCaption = load_string (IDS_WINECFG_TITLE);
227 psh.nPages = NUM_PROPERTY_PAGES;
229 psh.pfnCallback = PropSheetCallback;
230 psh.u2.nStartPage = 0;
233 * Display the modal property sheet
235 return PropertySheetW (&psh);
238 /******************************************************************************
239 * Name : ProcessCmdLine
240 * Description: Checks command line parameters for 'autodetect drives' option
241 * Parameters : lpCmdLine - the command line
242 * Returns : TRUE - if '/D' was found. Drive autodetection was carried out.
243 * FALSE - no '/D' option found in command line
244 * Notes : This is a very simple implementation, which only works
245 * correctly if the one and only cmd line option is '/D' or
246 * no option at all. Has to be reworked, if more options are to
250 ProcessCmdLine(LPSTR lpCmdLine)
252 if ((lpCmdLine[0] == '/' || lpCmdLine[0] == '-') &&
253 (lpCmdLine[1] == 'D' || lpCmdLine[1] == 'd'))
256 if (autodetect_drives()) {
257 apply_drive_changes();
265 /*****************************************************************************
267 * Description: Main windows entry point
268 * Parameters : hInstance
272 * Returns : Program exit code
275 WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
277 if (ProcessCmdLine(szCmdLine)) {
281 if (initialize(hInstance) != 0) {
282 WINE_ERR("initialization failed, aborting\n");
287 * The next 9 lines should be all that is needed
288 * for the Wine Configuration property sheet
290 InitCommonControls ();
291 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
292 if (doPropertySheet (hInstance, NULL) > 0) {
295 WINE_TRACE("Cancel\n");