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
29 #include <wine/debug.h>
34 WINE_DEFAULT_DEBUG_CHANNEL(winecfg
);
37 PropSheetCallback (HWND hWnd
, UINT uMsg
, LPARAM lParam
)
42 * hWnd = NULL, lParam == dialog resource
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
) ));
60 #define NUM_PROPERTY_PAGES 7
63 doPropertySheet (HINSTANCE hInstance
, HWND hOwner
)
65 PROPSHEETPAGEW psp
[NUM_PROPERTY_PAGES
];
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
;
166 psh
.pfnCallback
= PropSheetCallback
;
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
183 ProcessCmdLine(LPWSTR lpCmdLine
)
185 if (!(lpCmdLine
[0] == '/' || lpCmdLine
[0] == '-'))
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();
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();
215 /*****************************************************************************
217 * Description: Main windows entry point
218 * Parameters : hInstance
222 * Returns : Program exit code
225 wWinMain (HINSTANCE hInstance
, HINSTANCE hPrev
, LPWSTR cmdline
, int nShow
)
230 if (IsWow64Process( GetCurrentProcess(), &is_wow64
) && is_wow64
)
233 PROCESS_INFORMATION pi
;
234 WCHAR filename
[] = L
"C:\\windows\\system32\\winecfg.exe";
238 memset( &si
, 0, 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");
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) {
270 WINE_TRACE("Cancel\n");