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
25 #define NONAMELESSUNION
30 #include <wine/debug.h>
35 WINE_DEFAULT_DEBUG_CHANNEL(winecfg
);
38 PropSheetCallback (HWND hWnd
, UINT uMsg
, LPARAM lParam
)
43 * hWnd = NULL, lParam == dialog resource
48 case PSCB_INITIALIZED
:
49 /* Set the window icon */
50 SendMessageW( hWnd
, WM_SETICON
, ICON_BIG
,
51 (LPARAM
)LoadIconW( (HINSTANCE
)GetWindowLongPtrW(hWnd
, GWLP_HINSTANCE
),
52 MAKEINTRESOURCEW(IDI_WINECFG
) ));
61 #define NUM_PROPERTY_PAGES 7
64 doPropertySheet (HINSTANCE hInstance
, HWND hOwner
)
66 PROPSHEETPAGEW psp
[NUM_PROPERTY_PAGES
];
68 int pg
= 0; /* start with page 0 */
71 * Fill out the (Applications) PROPSHEETPAGE data structure
72 * for the property sheet
74 psp
[pg
].dwSize
= sizeof (PROPSHEETPAGEW
);
75 psp
[pg
].dwFlags
= PSP_USETITLE
;
76 psp
[pg
].hInstance
= hInstance
;
77 psp
[pg
].u
.pszTemplate
= MAKEINTRESOURCEW (IDD_APPCFG
);
78 psp
[pg
].u2
.pszIcon
= NULL
;
79 psp
[pg
].pfnDlgProc
= AppDlgProc
;
80 psp
[pg
].pszTitle
= load_string (IDS_TAB_APPLICATIONS
);
85 * Fill out the (Libraries) PROPSHEETPAGE data structure
86 * for the property sheet
88 psp
[pg
].dwSize
= sizeof (PROPSHEETPAGEW
);
89 psp
[pg
].dwFlags
= PSP_USETITLE
;
90 psp
[pg
].hInstance
= hInstance
;
91 psp
[pg
].u
.pszTemplate
= MAKEINTRESOURCEW (IDD_DLLCFG
);
92 psp
[pg
].u2
.pszIcon
= NULL
;
93 psp
[pg
].pfnDlgProc
= LibrariesDlgProc
;
94 psp
[pg
].pszTitle
= load_string (IDS_TAB_DLLS
);
99 * Fill out the (X11Drv) PROPSHEETPAGE data structure
100 * for the property sheet
102 psp
[pg
].dwSize
= sizeof (PROPSHEETPAGEW
);
103 psp
[pg
].dwFlags
= PSP_USETITLE
;
104 psp
[pg
].hInstance
= hInstance
;
105 psp
[pg
].u
.pszTemplate
= MAKEINTRESOURCEW (IDD_GRAPHCFG
);
106 psp
[pg
].u2
.pszIcon
= NULL
;
107 psp
[pg
].pfnDlgProc
= GraphDlgProc
;
108 psp
[pg
].pszTitle
= load_string (IDS_TAB_GRAPHICS
);
112 psp
[pg
].dwSize
= sizeof (PROPSHEETPAGEW
);
113 psp
[pg
].dwFlags
= PSP_USETITLE
;
114 psp
[pg
].hInstance
= hInstance
;
115 psp
[pg
].u
.pszTemplate
= MAKEINTRESOURCEW (IDD_DESKTOP_INTEGRATION
);
116 psp
[pg
].u2
.pszIcon
= NULL
;
117 psp
[pg
].pfnDlgProc
= ThemeDlgProc
;
118 psp
[pg
].pszTitle
= load_string (IDS_TAB_DESKTOP_INTEGRATION
);
122 psp
[pg
].dwSize
= sizeof (PROPSHEETPAGEW
);
123 psp
[pg
].dwFlags
= PSP_USETITLE
;
124 psp
[pg
].hInstance
= hInstance
;
125 psp
[pg
].u
.pszTemplate
= MAKEINTRESOURCEW (IDD_DRIVECFG
);
126 psp
[pg
].u2
.pszIcon
= NULL
;
127 psp
[pg
].pfnDlgProc
= DriveDlgProc
;
128 psp
[pg
].pszTitle
= load_string (IDS_TAB_DRIVES
);
132 psp
[pg
].dwSize
= sizeof (PROPSHEETPAGEW
);
133 psp
[pg
].dwFlags
= PSP_USETITLE
;
134 psp
[pg
].hInstance
= hInstance
;
135 psp
[pg
].u
.pszTemplate
= MAKEINTRESOURCEW (IDD_AUDIOCFG
);
136 psp
[pg
].u2
.pszIcon
= NULL
;
137 psp
[pg
].pfnDlgProc
= AudioDlgProc
;
138 psp
[pg
].pszTitle
= load_string (IDS_TAB_AUDIO
);
143 * Fill out the (General) 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_ABOUTCFG
);
150 psp
[pg
].u2
.pszIcon
= NULL
;
151 psp
[pg
].pfnDlgProc
= AboutDlgProc
;
152 psp
[pg
].pszTitle
= load_string (IDS_TAB_ABOUT
);
157 * Fill out the PROPSHEETHEADER
159 psh
.dwSize
= sizeof (PROPSHEETHEADERW
);
160 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_USEICONID
| PSH_USECALLBACK
;
161 psh
.hwndParent
= hOwner
;
162 psh
.hInstance
= hInstance
;
163 psh
.u
.pszIcon
= MAKEINTRESOURCEW (IDI_WINECFG
);
164 psh
.pszCaption
= load_string (IDS_WINECFG_TITLE
);
165 psh
.nPages
= NUM_PROPERTY_PAGES
;
167 psh
.pfnCallback
= PropSheetCallback
;
168 psh
.u2
.nStartPage
= 0;
171 * Display the modal property sheet
173 return PropertySheetW (&psh
);
176 /******************************************************************************
177 * Name : ProcessCmdLine
178 * Description: Checks command line parameters for 'autodetect drives' option
179 * Parameters : lpCmdLine - the command line
180 * Returns : TRUE - if '/D' was found. Drive autodetection was carried out.
181 * FALSE - no '/D' option found in command line
182 * Notes : This is a very simple implementation, which only works
183 * correctly if the one and only cmd line option is '/D' or
184 * no option at all. Has to be reworked, if more options are to
188 ProcessCmdLine(LPSTR lpCmdLine
)
190 if ((lpCmdLine
[0] == '/' || lpCmdLine
[0] == '-') &&
191 (lpCmdLine
[1] == 'D' || lpCmdLine
[1] == 'd'))
194 if (autodetect_drives()) {
195 apply_drive_changes();
203 /*****************************************************************************
205 * Description: Main windows entry point
206 * Parameters : hInstance
210 * Returns : Program exit code
213 WinMain (HINSTANCE hInstance
, HINSTANCE hPrev
, LPSTR szCmdLine
, int nShow
)
217 if (IsWow64Process( GetCurrentProcess(), &is_wow64
) && is_wow64
)
220 PROCESS_INFORMATION pi
;
221 WCHAR filename
[MAX_PATH
];
225 memset( &si
, 0, sizeof(si
) );
227 GetModuleFileNameW( 0, filename
, MAX_PATH
);
229 Wow64DisableWow64FsRedirection( &redir
);
230 if (CreateProcessW( filename
, GetCommandLineW(), NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
))
232 WINE_TRACE( "restarting %s\n", wine_dbgstr_w(filename
) );
233 WaitForSingleObject( pi
.hProcess
, INFINITE
);
234 GetExitCodeProcess( pi
.hProcess
, &exit_code
);
235 ExitProcess( exit_code
);
237 else WINE_ERR( "failed to restart 64-bit %s, err %d\n", wine_dbgstr_w(filename
), GetLastError() );
238 Wow64RevertWow64FsRedirection( redir
);
241 if (ProcessCmdLine(szCmdLine
)) {
245 if (initialize(hInstance
)) {
246 WINE_ERR("initialization failed, aborting\n");
251 * The next 9 lines should be all that is needed
252 * for the Wine Configuration property sheet
254 InitCommonControls ();
255 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
256 if (doPropertySheet (hInstance
, NULL
) > 0) {
259 WINE_TRACE("Cancel\n");