2003-03-31 21:41:55 +02:00
|
|
|
/*
|
|
|
|
* WineCfg main entry point
|
|
|
|
*
|
|
|
|
* Copyright 2002 Jaco Greeff
|
|
|
|
* Copyright 2003 Dimitrie O. Paun
|
2003-08-30 02:40:46 +02:00
|
|
|
* Copyright 2003 Mike Hearn
|
2003-03-31 21:41:55 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-03-31 21:41:55 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-01-19 11:55:01 +01:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2004-03-19 02:17:51 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
2006-01-19 11:55:01 +01:00
|
|
|
#include <windows.h>
|
2004-03-19 02:17:51 +01:00
|
|
|
#include <commctrl.h>
|
2005-03-09 17:41:30 +01:00
|
|
|
#include <objbase.h>
|
2004-03-19 02:17:51 +01:00
|
|
|
#include <wine/debug.h>
|
|
|
|
|
2003-03-31 21:41:55 +02:00
|
|
|
#include "resource.h"
|
|
|
|
#include "winecfg.h"
|
|
|
|
|
2003-08-30 02:27:08 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
|
|
|
|
|
2006-06-07 09:45:47 +02:00
|
|
|
static INT CALLBACK
|
2003-03-31 21:41:55 +02:00
|
|
|
PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* hWnd = NULL, lParam == dialog resource
|
|
|
|
*/
|
|
|
|
case PSCB_PRECREATE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PSCB_INITIALIZED:
|
2010-04-21 00:50:45 +02:00
|
|
|
/* Set the window icon */
|
|
|
|
SendMessageW( hWnd, WM_SETICON, ICON_BIG,
|
|
|
|
(LPARAM)LoadIconW( (HINSTANCE)GetWindowLongPtrW(hWnd, GWLP_HINSTANCE),
|
|
|
|
MAKEINTRESOURCEW(IDI_WINECFG) ));
|
2003-03-31 21:41:55 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-06-07 09:45:47 +02:00
|
|
|
return 0;
|
2003-03-31 21:41:55 +02:00
|
|
|
}
|
|
|
|
|
2005-08-24 12:59:40 +02:00
|
|
|
#define NUM_PROPERTY_PAGES 7
|
2004-01-20 03:07:35 +01:00
|
|
|
|
2005-06-02 17:11:32 +02:00
|
|
|
static INT_PTR
|
2003-03-31 21:41:55 +02:00
|
|
|
doPropertySheet (HINSTANCE hInstance, HWND hOwner)
|
|
|
|
{
|
2005-08-25 21:19:33 +02:00
|
|
|
PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
|
|
|
|
PROPSHEETHEADERW psh;
|
2004-02-07 02:01:34 +01:00
|
|
|
int pg = 0; /* start with page 0 */
|
2003-03-31 21:41:55 +02:00
|
|
|
|
|
|
|
/*
|
2003-09-30 02:27:55 +02:00
|
|
|
* Fill out the (Applications) PROPSHEETPAGE data structure
|
2003-03-31 21:41:55 +02:00
|
|
|
* for the property sheet
|
|
|
|
*/
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].dwFlags = PSP_USETITLE;
|
|
|
|
psp[pg].hInstance = hInstance;
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_APPCFG);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].u2.pszIcon = NULL;
|
|
|
|
psp[pg].pfnDlgProc = AppDlgProc;
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].pszTitle = load_string (IDS_TAB_APPLICATIONS);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].lParam = 0;
|
|
|
|
pg++;
|
2003-03-31 21:41:55 +02:00
|
|
|
|
|
|
|
/*
|
2003-09-30 02:27:55 +02:00
|
|
|
* Fill out the (Libraries) PROPSHEETPAGE data structure
|
2003-03-31 21:41:55 +02:00
|
|
|
* for the property sheet
|
|
|
|
*/
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].dwFlags = PSP_USETITLE;
|
|
|
|
psp[pg].hInstance = hInstance;
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DLLCFG);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].u2.pszIcon = NULL;
|
|
|
|
psp[pg].pfnDlgProc = LibrariesDlgProc;
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].pszTitle = load_string (IDS_TAB_DLLS);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].lParam = 0;
|
|
|
|
pg++;
|
2003-09-30 02:27:55 +02:00
|
|
|
|
2003-03-31 21:41:55 +02:00
|
|
|
/*
|
|
|
|
* Fill out the (X11Drv) PROPSHEETPAGE data structure
|
|
|
|
* for the property sheet
|
|
|
|
*/
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].dwFlags = PSP_USETITLE;
|
|
|
|
psp[pg].hInstance = hInstance;
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_GRAPHCFG);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].u2.pszIcon = NULL;
|
2004-07-30 03:35:13 +02:00
|
|
|
psp[pg].pfnDlgProc = GraphDlgProc;
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].pszTitle = load_string (IDS_TAB_GRAPHICS);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].lParam = 0;
|
|
|
|
pg++;
|
|
|
|
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
|
2005-08-24 12:59:40 +02:00
|
|
|
psp[pg].dwFlags = PSP_USETITLE;
|
|
|
|
psp[pg].hInstance = hInstance;
|
2006-02-14 13:09:30 +01:00
|
|
|
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DESKTOP_INTEGRATION);
|
2005-08-24 12:59:40 +02:00
|
|
|
psp[pg].u2.pszIcon = NULL;
|
|
|
|
psp[pg].pfnDlgProc = ThemeDlgProc;
|
2006-02-14 13:09:30 +01:00
|
|
|
psp[pg].pszTitle = load_string (IDS_TAB_DESKTOP_INTEGRATION);
|
2005-08-24 12:59:40 +02:00
|
|
|
psp[pg].lParam = 0;
|
|
|
|
pg++;
|
|
|
|
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].dwFlags = PSP_USETITLE;
|
|
|
|
psp[pg].hInstance = hInstance;
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DRIVECFG);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].u2.pszIcon = NULL;
|
|
|
|
psp[pg].pfnDlgProc = DriveDlgProc;
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].pszTitle = load_string (IDS_TAB_DRIVES);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].lParam = 0;
|
|
|
|
pg++;
|
|
|
|
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].dwFlags = PSP_USETITLE;
|
|
|
|
psp[pg].hInstance = hInstance;
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_AUDIOCFG);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].u2.pszIcon = NULL;
|
|
|
|
psp[pg].pfnDlgProc = AudioDlgProc;
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].pszTitle = load_string (IDS_TAB_AUDIO);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].lParam = 0;
|
|
|
|
pg++;
|
2003-03-31 21:41:55 +02:00
|
|
|
|
2004-02-07 02:01:34 +01:00
|
|
|
/*
|
|
|
|
* Fill out the (General) PROPSHEETPAGE data structure
|
|
|
|
* for the property sheet
|
|
|
|
*/
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].dwFlags = PSP_USETITLE;
|
|
|
|
psp[pg].hInstance = hInstance;
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_ABOUTCFG);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].u2.pszIcon = NULL;
|
|
|
|
psp[pg].pfnDlgProc = AboutDlgProc;
|
2005-08-25 21:19:33 +02:00
|
|
|
psp[pg].pszTitle = load_string (IDS_TAB_ABOUT);
|
2004-02-07 02:01:34 +01:00
|
|
|
psp[pg].lParam = 0;
|
|
|
|
pg++;
|
2004-01-20 03:07:35 +01:00
|
|
|
|
2003-03-31 21:41:55 +02:00
|
|
|
/*
|
|
|
|
* Fill out the PROPSHEETHEADER
|
|
|
|
*/
|
2005-08-25 21:19:33 +02:00
|
|
|
psh.dwSize = sizeof (PROPSHEETHEADERW);
|
2003-03-31 21:41:55 +02:00
|
|
|
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
|
|
|
|
psh.hwndParent = hOwner;
|
|
|
|
psh.hInstance = hInstance;
|
2010-04-21 00:50:45 +02:00
|
|
|
psh.u.pszIcon = MAKEINTRESOURCEW (IDI_WINECFG);
|
2005-08-25 21:19:33 +02:00
|
|
|
psh.pszCaption = load_string (IDS_WINECFG_TITLE);
|
2003-03-31 21:41:55 +02:00
|
|
|
psh.nPages = NUM_PROPERTY_PAGES;
|
2006-06-07 09:45:47 +02:00
|
|
|
psh.u3.ppsp = psp;
|
|
|
|
psh.pfnCallback = PropSheetCallback;
|
2003-09-30 02:27:55 +02:00
|
|
|
psh.u2.nStartPage = 0;
|
2003-03-31 21:41:55 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Display the modal property sheet
|
|
|
|
*/
|
2005-08-25 21:19:33 +02:00
|
|
|
return PropertySheetW (&psh);
|
2003-03-31 21:41:55 +02:00
|
|
|
}
|
|
|
|
|
2005-02-14 22:03:52 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : ProcessCmdLine
|
2020-04-16 16:06:27 +02:00
|
|
|
* Description: Checks command line parameters
|
2005-02-14 22:03:52 +01:00
|
|
|
* Parameters : lpCmdLine - the command line
|
2020-04-16 16:06:27 +02:00
|
|
|
* Returns : The return value to return from WinMain, or -1 to continue
|
|
|
|
* program execution.
|
2005-02-14 22:03:52 +01:00
|
|
|
*/
|
2020-04-16 16:06:27 +02:00
|
|
|
static int
|
2021-09-07 17:14:22 +02:00
|
|
|
ProcessCmdLine(LPWSTR lpCmdLine)
|
2005-02-14 22:03:52 +01:00
|
|
|
{
|
2020-04-16 16:06:27 +02:00
|
|
|
if (!(lpCmdLine[0] == '/' || lpCmdLine[0] == '-'))
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
2020-09-01 00:11:39 +02:00
|
|
|
if (lpCmdLine[1] == 'V' || lpCmdLine[1] == 'v')
|
2020-04-16 16:06:27 +02:00
|
|
|
{
|
2021-09-07 17:14:22 +02:00
|
|
|
if (wcslen(lpCmdLine) > 4)
|
2020-09-01 00:11:39 +02:00
|
|
|
return set_winver_from_string(&lpCmdLine[3]) ? 0 : 1;
|
|
|
|
|
|
|
|
print_current_winver();
|
|
|
|
return 0;
|
2020-04-16 16:06:27 +02:00
|
|
|
}
|
|
|
|
|
2020-04-16 16:06:47 +02:00
|
|
|
if (lpCmdLine[1] == '?')
|
|
|
|
{
|
|
|
|
printf("Usage: winecfg [options]\n\n");
|
|
|
|
printf("Options:\n");
|
|
|
|
printf(" [no option] Launch the graphical version of this program.\n");
|
2020-09-01 00:11:39 +02:00
|
|
|
printf(" /v Display the current global Windows version.\n");
|
2020-04-16 16:06:47 +02:00
|
|
|
printf(" /v version Set global Windows version to 'version'.\n");
|
|
|
|
printf(" /? Display this information and exit.\n\n");
|
|
|
|
printf("Valid versions for 'version':\n\n");
|
|
|
|
print_windows_versions();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-16 16:06:27 +02:00
|
|
|
return -1;
|
2005-02-14 22:03:52 +01:00
|
|
|
}
|
2003-03-31 21:41:55 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Name : WinMain
|
|
|
|
* Description: Main windows entry point
|
2003-06-18 05:30:39 +02:00
|
|
|
* Parameters : hInstance
|
2003-03-31 21:41:55 +02:00
|
|
|
* hPrev
|
|
|
|
* szCmdLine
|
|
|
|
* nShow
|
|
|
|
* Returns : Program exit code
|
|
|
|
*/
|
|
|
|
int WINAPI
|
2021-09-07 17:14:22 +02:00
|
|
|
wWinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPWSTR cmdline, int nShow)
|
2003-03-31 21:41:55 +02:00
|
|
|
{
|
2010-12-15 22:29:49 +01:00
|
|
|
BOOL is_wow64;
|
2020-04-16 16:06:27 +02:00
|
|
|
int cmd_ret;
|
2010-12-15 22:29:49 +01:00
|
|
|
|
|
|
|
if (IsWow64Process( GetCurrentProcess(), &is_wow64 ) && is_wow64)
|
|
|
|
{
|
|
|
|
STARTUPINFOW si;
|
|
|
|
PROCESS_INFORMATION pi;
|
2021-09-07 13:41:35 +02:00
|
|
|
WCHAR filename[] = L"C:\\windows\\system32\\winecfg.exe";
|
2010-12-15 22:29:49 +01:00
|
|
|
void *redir;
|
|
|
|
DWORD exit_code;
|
|
|
|
|
|
|
|
memset( &si, 0, sizeof(si) );
|
|
|
|
si.cb = sizeof(si);
|
|
|
|
|
|
|
|
Wow64DisableWow64FsRedirection( &redir );
|
|
|
|
if (CreateProcessW( filename, GetCommandLineW(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
|
|
|
|
{
|
|
|
|
WINE_TRACE( "restarting %s\n", wine_dbgstr_w(filename) );
|
|
|
|
WaitForSingleObject( pi.hProcess, INFINITE );
|
|
|
|
GetExitCodeProcess( pi.hProcess, &exit_code );
|
|
|
|
ExitProcess( exit_code );
|
|
|
|
}
|
2022-02-07 08:40:37 +01:00
|
|
|
else WINE_ERR( "failed to restart 64-bit %s, err %ld\n", wine_dbgstr_w(filename), GetLastError() );
|
2010-12-15 22:29:49 +01:00
|
|
|
Wow64RevertWow64FsRedirection( redir );
|
|
|
|
}
|
|
|
|
|
2013-10-16 23:38:33 +02:00
|
|
|
if (initialize(hInstance)) {
|
2003-09-08 20:58:07 +02:00
|
|
|
WINE_ERR("initialization failed, aborting\n");
|
|
|
|
ExitProcess(1);
|
|
|
|
}
|
2020-04-17 13:08:59 +02:00
|
|
|
|
2021-09-07 17:14:22 +02:00
|
|
|
cmd_ret = ProcessCmdLine(cmdline);
|
2020-09-01 00:10:22 +02:00
|
|
|
if (cmd_ret >= 0) return cmd_ret;
|
|
|
|
|
2003-03-31 21:41:55 +02:00
|
|
|
/*
|
2005-03-09 17:41:30 +01:00
|
|
|
* The next 9 lines should be all that is needed
|
2003-03-31 21:41:55 +02:00
|
|
|
* for the Wine Configuration property sheet
|
|
|
|
*/
|
|
|
|
InitCommonControls ();
|
2005-03-09 17:41:30 +01:00
|
|
|
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
2003-08-30 02:40:46 +02:00
|
|
|
if (doPropertySheet (hInstance, NULL) > 0) {
|
2003-08-30 02:27:08 +02:00
|
|
|
WINE_TRACE("OK\n");
|
2003-09-30 02:27:55 +02:00
|
|
|
} else {
|
2003-08-30 02:27:08 +02:00
|
|
|
WINE_TRACE("Cancel\n");
|
2003-09-30 02:27:55 +02:00
|
|
|
}
|
2005-03-09 17:41:30 +01:00
|
|
|
CoUninitialize();
|
2003-03-31 21:41:55 +02:00
|
|
|
ExitProcess (0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|