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
:
59 static INT_PTR CALLBACK
60 AboutDlgProc (HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
67 switch(((LPNMHDR
)lParam
)->code
)
70 /*save registration info to registry */
71 owner
= get_text(hDlg
, IDC_ABT_OWNER
);
72 org
= get_text(hDlg
, IDC_ABT_ORG
);
74 set_reg_key(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows\\CurrentVersion",
75 "RegisteredOwner", owner
? owner
: "");
76 set_reg_key(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows\\CurrentVersion",
77 "RegisteredOrganization", org
? org
: "");
78 set_reg_key(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows NT\\CurrentVersion",
79 "RegisteredOwner", owner
? owner
: "");
80 set_reg_key(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows NT\\CurrentVersion",
81 "RegisteredOrganization", org
? org
: "");
84 HeapFree(GetProcessHeap(), 0, owner
);
85 HeapFree(GetProcessHeap(), 0, org
);
91 /* read owner and organization info from registry, load it into text box */
92 owner
= get_reg_key(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows NT\\CurrentVersion",
93 "RegisteredOwner", "");
94 org
= get_reg_key(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows NT\\CurrentVersion",
95 "RegisteredOrganization", "");
97 SetDlgItemText(hDlg
, IDC_ABT_OWNER
, owner
);
98 SetDlgItemText(hDlg
, IDC_ABT_ORG
, org
);
100 SendMessage(GetParent(hDlg
), PSM_UNCHANGED
, 0, 0);
102 HeapFree(GetProcessHeap(), 0, owner
);
103 HeapFree(GetProcessHeap(), 0, org
);
107 switch(HIWORD(wParam
))
110 /* enable apply button */
111 SendMessage(GetParent(hDlg
), PSM_CHANGED
, 0, 0);
119 #define NUM_PROPERTY_PAGES 7
122 doPropertySheet (HINSTANCE hInstance
, HWND hOwner
)
124 PROPSHEETPAGEW psp
[NUM_PROPERTY_PAGES
];
125 PROPSHEETHEADERW psh
;
126 int pg
= 0; /* start with page 0 */
129 * Fill out the (Applications) PROPSHEETPAGE data structure
130 * for the property sheet
132 psp
[pg
].dwSize
= sizeof (PROPSHEETPAGEW
);
133 psp
[pg
].dwFlags
= PSP_USETITLE
;
134 psp
[pg
].hInstance
= hInstance
;
135 psp
[pg
].u
.pszTemplate
= MAKEINTRESOURCEW (IDD_APPCFG
);
136 psp
[pg
].u2
.pszIcon
= NULL
;
137 psp
[pg
].pfnDlgProc
= AppDlgProc
;
138 psp
[pg
].pszTitle
= load_string (IDS_TAB_APPLICATIONS
);
143 * Fill out the (Libraries) PROPSHEETPAGE data structure
144 * for the property sheet
146 psp
[pg
].dwSize
= sizeof (PROPSHEETPAGEW
);
147 psp
[pg
].dwFlags
= PSP_USETITLE
;
148 psp
[pg
].hInstance
= hInstance
;
149 psp
[pg
].u
.pszTemplate
= MAKEINTRESOURCEW (IDD_DLLCFG
);
150 psp
[pg
].u2
.pszIcon
= NULL
;
151 psp
[pg
].pfnDlgProc
= LibrariesDlgProc
;
152 psp
[pg
].pszTitle
= load_string (IDS_TAB_DLLS
);
157 * Fill out the (X11Drv) PROPSHEETPAGE data structure
158 * for the property sheet
160 psp
[pg
].dwSize
= sizeof (PROPSHEETPAGEW
);
161 psp
[pg
].dwFlags
= PSP_USETITLE
;
162 psp
[pg
].hInstance
= hInstance
;
163 psp
[pg
].u
.pszTemplate
= MAKEINTRESOURCEW (IDD_GRAPHCFG
);
164 psp
[pg
].u2
.pszIcon
= NULL
;
165 psp
[pg
].pfnDlgProc
= GraphDlgProc
;
166 psp
[pg
].pszTitle
= load_string (IDS_TAB_GRAPHICS
);
170 psp
[pg
].dwSize
= sizeof (PROPSHEETPAGEW
);
171 psp
[pg
].dwFlags
= PSP_USETITLE
;
172 psp
[pg
].hInstance
= hInstance
;
173 psp
[pg
].u
.pszTemplate
= MAKEINTRESOURCEW (IDD_DESKTOP_INTEGRATION
);
174 psp
[pg
].u2
.pszIcon
= NULL
;
175 psp
[pg
].pfnDlgProc
= ThemeDlgProc
;
176 psp
[pg
].pszTitle
= load_string (IDS_TAB_DESKTOP_INTEGRATION
);
180 psp
[pg
].dwSize
= sizeof (PROPSHEETPAGEW
);
181 psp
[pg
].dwFlags
= PSP_USETITLE
;
182 psp
[pg
].hInstance
= hInstance
;
183 psp
[pg
].u
.pszTemplate
= MAKEINTRESOURCEW (IDD_DRIVECFG
);
184 psp
[pg
].u2
.pszIcon
= NULL
;
185 psp
[pg
].pfnDlgProc
= DriveDlgProc
;
186 psp
[pg
].pszTitle
= load_string (IDS_TAB_DRIVES
);
190 psp
[pg
].dwSize
= sizeof (PROPSHEETPAGEW
);
191 psp
[pg
].dwFlags
= PSP_USETITLE
;
192 psp
[pg
].hInstance
= hInstance
;
193 psp
[pg
].u
.pszTemplate
= MAKEINTRESOURCEW (IDD_AUDIOCFG
);
194 psp
[pg
].u2
.pszIcon
= NULL
;
195 psp
[pg
].pfnDlgProc
= AudioDlgProc
;
196 psp
[pg
].pszTitle
= load_string (IDS_TAB_AUDIO
);
201 * Fill out the (General) PROPSHEETPAGE data structure
202 * for the property sheet
204 psp
[pg
].dwSize
= sizeof (PROPSHEETPAGEW
);
205 psp
[pg
].dwFlags
= PSP_USETITLE
;
206 psp
[pg
].hInstance
= hInstance
;
207 psp
[pg
].u
.pszTemplate
= MAKEINTRESOURCEW (IDD_ABOUTCFG
);
208 psp
[pg
].u2
.pszIcon
= NULL
;
209 psp
[pg
].pfnDlgProc
= AboutDlgProc
;
210 psp
[pg
].pszTitle
= load_string (IDS_TAB_ABOUT
);
215 * Fill out the PROPSHEETHEADER
217 psh
.dwSize
= sizeof (PROPSHEETHEADERW
);
218 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_USEICONID
| PSH_USECALLBACK
;
219 psh
.hwndParent
= hOwner
;
220 psh
.hInstance
= hInstance
;
221 psh
.u
.pszIcon
= NULL
;
222 psh
.pszCaption
= load_string (IDS_WINECFG_TITLE
);
223 psh
.nPages
= NUM_PROPERTY_PAGES
;
225 psh
.pfnCallback
= PropSheetCallback
;
226 psh
.u2
.nStartPage
= 0;
229 * Display the modal property sheet
231 return PropertySheetW (&psh
);
234 /******************************************************************************
235 * Name : ProcessCmdLine
236 * Description: Checks command line parameters for 'autodetect drives' option
237 * Parameters : lpCmdLine - the command line
238 * Returns : TRUE - if '/D' was found. Drive autodetection was carried out.
239 * FALSE - no '/D' option found in command line
240 * Notes : This is a very simple implementation, which only works
241 * correctly if the one and only cmd line option is '/D' or
242 * no option at all. Has to be reworked, if more options are to
246 ProcessCmdLine(LPSTR lpCmdLine
)
248 if ((lpCmdLine
[0] == '/' || lpCmdLine
[0] == '-') &&
249 (lpCmdLine
[1] == 'D' || lpCmdLine
[1] == 'd'))
252 if (autodetect_drives()) {
253 apply_drive_changes();
261 /*****************************************************************************
263 * Description: Main windows entry point
264 * Parameters : hInstance
268 * Returns : Program exit code
271 WinMain (HINSTANCE hInstance
, HINSTANCE hPrev
, LPSTR szCmdLine
, int nShow
)
273 if (ProcessCmdLine(szCmdLine
)) {
277 if (initialize(hInstance
) != 0) {
278 WINE_ERR("initialization failed, aborting\n");
283 * The next 9 lines should be all that is needed
284 * for the Wine Configuration property sheet
286 InitCommonControls ();
287 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
288 if (doPropertySheet (hInstance
, NULL
) > 0) {
291 WINE_TRACE("Cancel\n");