winecfg: Add command-line switch -C to setup default configuration
Vitaliy Margolen
wine-patch at kievinfo.com
Tue Nov 1 00:31:13 CST 2005
For now that's only windows version.
Vitaliy Margolen
changelog:
winecfg
- Add command-line switch -C to setup default configuration
-------------- next part --------------
Index: programs/winecfg/appdefaults.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/appdefaults.c,v
retrieving revision 1.21
diff -u -p -r1.21 appdefaults.c
--- programs/winecfg/appdefaults.c 28 Oct 2005 09:38:11 -0000 1.21
+++ programs/winecfg/appdefaults.c 1 Nov 2005 06:26:11 -0000
@@ -61,24 +61,20 @@ static const struct
#define NB_VERSIONS (sizeof(win_versions)/sizeof(win_versions[0]))
-static void update_comboboxes(HWND dialog)
+int get_configured_win_version(char *app)
{
- int i;
-
char *winver;
+ int i, ver = 0;
/* retrieve the registry values */
winver = get_reg_key(config_key, keypath(""), "Version", "");
-
if (*winver == '\0')
{
HeapFree(GetProcessHeap(), 0, winver);
-
- if (current_app) /* no explicit setting */
+ if (app) /* no explicit setting */
{
+ return ver;
WINE_TRACE("setting winver combobox to default\n");
- SendDlgItemMessage (dialog, IDC_WINVER, CB_SETCURSEL, 0, 0);
- return;
}
winver = strdupA("win2k");
}
@@ -89,14 +85,20 @@ static void update_comboboxes(HWND dialo
{
if (!strcasecmp (win_versions[i].szVersion, winver))
{
- SendDlgItemMessage (dialog, IDC_WINVER, CB_SETCURSEL,
- (WPARAM) i + (current_app?1:0), 0);
+ ver = i + (current_app ? 1 : 0);
WINE_TRACE("match with %s\n", win_versions[i].szVersion);
break;
}
}
HeapFree(GetProcessHeap(), 0, winver);
+ return ver;
+}
+
+static void update_comboboxes(HWND dialog)
+{
+ SendDlgItemMessage (dialog, IDC_WINVER, CB_SETCURSEL,
+ get_configured_win_version(current_app), 0);
}
static void
@@ -308,6 +310,61 @@ static void on_remove_app_click(HWND dia
SendMessage(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
}
+void set_window_version(int version_id)
+{
+ static const char szKey9x[] = "Software\\Microsoft\\Windows\\CurrentVersion";
+ static const char szKeyNT[] = "Software\\Microsoft\\Windows NT\\CurrentVersion";
+ static const char szKeyProdNT[] = "System\\CurrentControlSet\\Control\\ProductOptions";
+ static const char szKeyWindNT[] = "System\\CurrentControlSet\\Control\\Windows";
+ static const char szKeyEnvNT[] = "System\\CurrentControlSet\\Control\\Session Manager\\Environment";
+ char Buffer[40];
+
+ switch (win_versions[version_id].dwPlatformId)
+ {
+ case VER_PLATFORM_WIN32_WINDOWS:
+ snprintf(Buffer, sizeof(Buffer), "%ld.%ld.%ld", win_versions[version_id].dwMajorVersion,
+ win_versions[version_id].dwMinorVersion, win_versions[version_id].dwBuildNumber);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "VersionNumber", Buffer);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "SubVersionNumber", win_versions[version_id].szCSDVersion);
+
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CSDVersion", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentVersion", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentBuildNumber", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyProdNT, "ProductType", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyWindNT, "CSDVersion", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyEnvNT, "OS", NULL);
+ break;
+
+ case VER_PLATFORM_WIN32_NT:
+ snprintf(Buffer, sizeof(Buffer), "%ld.%ld", win_versions[version_id].dwMajorVersion,
+ win_versions[version_id].dwMinorVersion);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentVersion", Buffer);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CSDVersion", win_versions[version_id].szCSDVersion);
+ snprintf(Buffer, sizeof(Buffer), "%ld", win_versions[version_id].dwBuildNumber);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentBuildNumber", Buffer);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyProdNT, "ProductType", win_versions[version_id].szProductType);
+ set_reg_key_dword(HKEY_LOCAL_MACHINE, szKeyWindNT, "CSDVersion",
+ MAKEWORD( win_versions[version_id].wServicePackMinor,
+ win_versions[version_id].wServicePackMajor ));
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyEnvNT, "OS", "Windows_NT");
+
+ set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "VersionNumber", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "SubVersionNumber", NULL);
+ break;
+
+ case VER_PLATFORM_WIN32s:
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CSDVersion", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentVersion", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentBuildNumber", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyProdNT, "ProductType", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyWindNT, "CSDVersion", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyEnvNT, "OS", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "VersionNumber", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "SubVersionNumber", NULL);
+ break;
+ }
+}
+
static void on_winver_change(HWND dialog)
{
int selection = SendDlgItemMessage(dialog, IDC_WINVER, CB_GETCURSEL, 0, 0);
@@ -325,59 +382,7 @@ static void on_winver_change(HWND dialog
}
/* global version only */
if (!current_app)
- {
- static const char szKey9x[] = "Software\\Microsoft\\Windows\\CurrentVersion";
- static const char szKeyNT[] = "Software\\Microsoft\\Windows NT\\CurrentVersion";
- static const char szKeyProdNT[] = "System\\CurrentControlSet\\Control\\ProductOptions";
- static const char szKeyWindNT[] = "System\\CurrentControlSet\\Control\\Windows";
- static const char szKeyEnvNT[] = "System\\CurrentControlSet\\Control\\Session Manager\\Environment";
- char Buffer[40];
-
- switch (win_versions[selection].dwPlatformId)
- {
- case VER_PLATFORM_WIN32_WINDOWS:
- snprintf(Buffer, sizeof(Buffer), "%ld.%ld.%ld", win_versions[selection].dwMajorVersion,
- win_versions[selection].dwMinorVersion, win_versions[selection].dwBuildNumber);
- set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "VersionNumber", Buffer);
- set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "SubVersionNumber", win_versions[selection].szCSDVersion);
-
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CSDVersion", NULL);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentVersion", NULL);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentBuildNumber", NULL);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyProdNT, "ProductType", NULL);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyWindNT, "CSDVersion", NULL);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyEnvNT, "OS", NULL);
- break;
-
- case VER_PLATFORM_WIN32_NT:
- snprintf(Buffer, sizeof(Buffer), "%ld.%ld", win_versions[selection].dwMajorVersion,
- win_versions[selection].dwMinorVersion);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentVersion", Buffer);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CSDVersion", win_versions[selection].szCSDVersion);
- snprintf(Buffer, sizeof(Buffer), "%ld", win_versions[selection].dwBuildNumber);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentBuildNumber", Buffer);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyProdNT, "ProductType", win_versions[selection].szProductType);
- set_reg_key_dword(HKEY_LOCAL_MACHINE, szKeyWindNT, "CSDVersion",
- MAKEWORD( win_versions[selection].wServicePackMinor,
- win_versions[selection].wServicePackMajor ));
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyEnvNT, "OS", "Windows_NT");
-
- set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "VersionNumber", NULL);
- set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "SubVersionNumber", NULL);
- break;
-
- case VER_PLATFORM_WIN32s:
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CSDVersion", NULL);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentVersion", NULL);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentBuildNumber", NULL);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyProdNT, "ProductType", NULL);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyWindNT, "CSDVersion", NULL);
- set_reg_key(HKEY_LOCAL_MACHINE, szKeyEnvNT, "OS", NULL);
- set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "VersionNumber", NULL);
- set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "SubVersionNumber", NULL);
- break;
- }
- }
+ set_window_version(selection);
/* enable the apply button */
SendMessage(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
Index: programs/winecfg/main.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/main.c,v
retrieving revision 1.26
diff -u -p -r1.26 main.c
--- programs/winecfg/main.c 25 Aug 2005 19:19:33 -0000 1.26
+++ programs/winecfg/main.c 1 Nov 2005 06:26:11 -0000
@@ -218,28 +218,45 @@ doPropertySheet (HINSTANCE hInstance, HW
/******************************************************************************
* Name : ProcessCmdLine
- * Description: Checks command line parameters for 'autodetect drives' option
+ * Description: Checks command line parameters.
* Parameters : lpCmdLine - the command line
- * Returns : TRUE - if '/D' was found. Drive autodetection was carried out.
- * FALSE - no '/D' option found in command line
- * Notes : This is a very simple implementation, which only works
- * correctly if the one and only cmd line option is '/D' or
- * no option at all. Has to be reworked, if more options are to
- * be supported.
+ * Returns : TRUE - Exit the winecfg
+ * FALSE - Continue with the GUI part
+ * Options: : -D Autodetect drives, save and exit
+ * -C Save default configuration into registry
*/
static BOOL
ProcessCmdLine(LPSTR lpCmdLine)
{
- if ((lpCmdLine[0] == '/' || lpCmdLine[0] == '-') &&
- (lpCmdLine[1] == 'D' || lpCmdLine[1] == 'd'))
+ LPSTR s = lpCmdLine; /* command line pointer */
+ CHAR ch = *s; /* current character */
+
+ while (ch && ((ch == '-') || (ch == '/')))
{
- gui_mode = FALSE;
- if (autodetect_drives()) {
- apply_drive_changes();
+ char ch2;
+
+ ch = *(++s);
+ ch2 = *(s+1);
+ if (!ch2 || isspace(ch2))
+ {
+ switch (toupper(ch))
+ {
+ case 'D':
+ gui_mode = FALSE;
+ if (autodetect_drives())
+ apply_drive_changes();
+ return TRUE;
+ case 'C':
+ gui_mode = FALSE;
+ set_window_version(get_configured_win_version(NULL));
+ apply();
+ return TRUE;
+ }
+ s++;
}
- return TRUE;
+ /* skip spaces to the next parameter */
+ while ((ch = *(s++)) && isspace(ch));
}
-
return FALSE;
}
@@ -255,15 +272,15 @@ ProcessCmdLine(LPSTR lpCmdLine)
int WINAPI
WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
{
- if (ProcessCmdLine(szCmdLine)) {
- return 0;
- }
-
if (initialize() != 0) {
WINE_ERR("initialization failed, aborting\n");
ExitProcess(1);
}
-
+
+ if (ProcessCmdLine(szCmdLine)) {
+ return 0;
+ }
+
/*
* The next 9 lines should be all that is needed
* for the Wine Configuration property sheet
Index: programs/winecfg/winecfg.h
===================================================================
RCS file: /home/wine/wine/programs/winecfg/winecfg.h,v
retrieving revision 1.28
diff -u -p -r1.28 winecfg.h
--- programs/winecfg/winecfg.h 24 Aug 2005 10:59:40 -0000 1.28
+++ programs/winecfg/winecfg.h 1 Nov 2005 06:26:12 -0000
@@ -80,6 +80,10 @@ INT_PTR CALLBACK LibrariesDlgProc (HWND
INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+/* Windows version */
+void set_window_version(int version_id);
+int get_configured_win_version(char *app);
+
/* Drive management */
void load_drives(void);
int autodetect_drives(void);
More information about the wine-patches
mailing list