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
179 * Parameters : lpCmdLine - the command line
180 * Returns : The return value to return from WinMain, or -1 to continue
184 ProcessCmdLine(LPSTR lpCmdLine
)
186 if (!(lpCmdLine
[0] == '/' || lpCmdLine
[0] == '-'))
190 if ((lpCmdLine
[1] == 'V' || lpCmdLine
[1] == 'v') && (lstrlenA(lpCmdLine
) > 4))
192 return set_winver_from_string(&lpCmdLine
[3]) ? 0 : 1;
195 if (lpCmdLine
[1] == '?')
197 printf("Usage: winecfg [options]\n\n");
198 printf("Options:\n");
199 printf(" [no option] Launch the graphical version of this program.\n");
200 printf(" /v version Set global Windows version to 'version'.\n");
201 printf(" /? Display this information and exit.\n\n");
202 printf("Valid versions for 'version':\n\n");
203 print_windows_versions();
211 /*****************************************************************************
213 * Description: Main windows entry point
214 * Parameters : hInstance
218 * Returns : Program exit code
221 WinMain (HINSTANCE hInstance
, HINSTANCE hPrev
, LPSTR szCmdLine
, int nShow
)
226 if (IsWow64Process( GetCurrentProcess(), &is_wow64
) && is_wow64
)
229 PROCESS_INFORMATION pi
;
230 WCHAR filename
[MAX_PATH
];
234 memset( &si
, 0, sizeof(si
) );
236 GetModuleFileNameW( 0, filename
, MAX_PATH
);
238 Wow64DisableWow64FsRedirection( &redir
);
239 if (CreateProcessW( filename
, GetCommandLineW(), NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
))
241 WINE_TRACE( "restarting %s\n", wine_dbgstr_w(filename
) );
242 WaitForSingleObject( pi
.hProcess
, INFINITE
);
243 GetExitCodeProcess( pi
.hProcess
, &exit_code
);
244 ExitProcess( exit_code
);
246 else WINE_ERR( "failed to restart 64-bit %s, err %d\n", wine_dbgstr_w(filename
), GetLastError() );
247 Wow64RevertWow64FsRedirection( redir
);
250 cmd_ret
= ProcessCmdLine(szCmdLine
);
251 if (cmd_ret
>= 0) return cmd_ret
;
253 if (initialize(hInstance
)) {
254 WINE_ERR("initialization failed, aborting\n");
259 * The next 9 lines should be all that is needed
260 * for the Wine Configuration property sheet
262 InitCommonControls ();
263 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
264 if (doPropertySheet (hInstance
, NULL
) > 0) {
267 WINE_TRACE("Cancel\n");