winecfg: Try2: Add windows version registry entries
Vitaliy Margolen
wine-patch at kievinfo.com
Tue Aug 16 12:40:33 CDT 2005
This time more generic for all emulated versions.
Vitaliy Margolen
changelog:
programs/winecfg
Add windows version registry entries
-------------- next part --------------
Index: programs/winecfg/appdefaults.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/appdefaults.c,v
retrieving revision 1.18
diff -u -p -r1.18 appdefaults.c
--- programs/winecfg/appdefaults.c 27 Jun 2005 09:48:06 -0000 1.18
+++ programs/winecfg/appdefaults.c 16 Aug 2005 17:20:58 -0000
@@ -303,6 +303,46 @@ static void on_winver_change(HWND dialog
WINE_TRACE("setting Version key to value '%s'\n", ver[selection - 1].szVersion);
set_reg_key(config_key, keypath(""), "Version", ver[selection - 1].szVersion);
}
+ /* 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";
+ char Buffer[10];
+
+ switch (selection)
+ {
+ case 4: case 5: case 6:
+ snprintf(Buffer, sizeof(Buffer), "%ld.%ld.%ld", ver[selection-1].dwMajorVersion,
+ ver[selection-1].dwMinorVersion, ver[selection-1].dwBuildNumber);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "VersionNumber", Buffer);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "SubVersionNumber", ver[selection-1].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_dword(HKEY_LOCAL_MACHINE, szKeyWindNT, "CSDVersion", 0);
+ break;
+
+ case 1: case 2: case 3: case 7: case 8:
+ snprintf(Buffer, sizeof(Buffer), "%ld.%ld", ver[selection-1].dwMajorVersion,
+ ver[selection-1].dwMinorVersion);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentVersion", Buffer);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CSDVersion", ver[selection-1].szCSDVersion);
+ snprintf(Buffer, sizeof(Buffer), "%ld", ver[selection-1].dwBuildNumber);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, "CurrentBuildNumber", Buffer);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKeyProdNT, "ProductType", ver[selection-1].szProductType);
+ set_reg_key_dword(HKEY_LOCAL_MACHINE, szKeyWindNT, "CSDVersion",
+ (ver[selection-1].wServicePackMajor << 8) + ver[selection-1].wServicePackMinor);
+
+ set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "VersionNumber", NULL);
+ set_reg_key(HKEY_LOCAL_MACHINE, szKey9x, "SubVersionNumber", NULL);
+ break;
+ }
+ }
/* enable the apply button */
SendMessage(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
Index: programs/winecfg/properties.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/properties.c,v
retrieving revision 1.13
diff -u -p -r1.13 properties.c
--- programs/winecfg/properties.c 3 Aug 2005 15:53:26 -0000 1.13
+++ programs/winecfg/properties.c 16 Aug 2005 17:20:58 -0000
@@ -25,18 +25,18 @@
#include "properties.h"
static const VERSION_DESC sWinVersions[] = {
- {"win2003", "Windows 2003"},
- {"winxp", "Windows XP"},
- {"win2k", "Windows 2000"},
- {"winme", "Windows ME"},
- {"win98", "Windows 98"},
- {"win95", "Windows 95"},
- {"nt40", "Windows NT 4.0"},
- {"nt351", "Windows NT 3.5"},
- {"win31", "Windows 3.1"},
- {"win30", "Windows 3.0"},
- {"win20", "Windows 2.0"},
- {"", ""}
+ {5, 2, 0xECE, "win2003", "Windows 2003", "Service Pack 1", 1, 0, "ServerNT"},
+ {5, 1, 0xA28, "winxp", "Windows XP", "Service Pack 2", 2, 0, "WinNT"},
+ {5, 0, 0x893, "win2k", "Windows 2000", "Service Pack 4", 4, 0, "WinNT"},
+ {4, 90, 0xBB8, "winme", "Windows ME", " ", 0, 0, ""},
+ {4, 10, 0x8AE, "win98", "Windows 98", " A ", 0, 0, ""},
+ {4, 0, 0x3B6, "win95", "Windows 95", "", 0, 0, ""},
+ {4, 0, 0x565, "nt40", "Windows NT 4.0", "Service Pack 6a", 6, 0, "WinNT"},
+ {3, 51, 0x421, "nt351", "Windows NT 3.5", "Service Pack 2", 0, 0, "WinNT"},
+ {2, 10, 0, "win31", "Windows 3.1", "Win32s 1.3", 0, 0, ""},
+ {3, 0, 0, "win30", "Windows 3.0", "Win32s 1.3", 0, 0, ""},
+ {2, 0, 0, "win20", "Windows 2.0", "Win32s 1.3", 0, 0, ""},
+ {0, 0, 0, "", "", "", 0, 0, ""}
};
static const DLL_DESC sDLLType[] = {
Index: programs/winecfg/properties.h
===================================================================
RCS file: /home/wine/wine/programs/winecfg/properties.h,v
retrieving revision 1.13
diff -u -p -r1.13 properties.h
--- programs/winecfg/properties.h 27 Jun 2005 09:48:06 -0000 1.13
+++ programs/winecfg/properties.h 16 Aug 2005 17:20:58 -0000
@@ -39,8 +39,15 @@
typedef struct
{
+ DWORD dwMajorVersion;
+ DWORD dwMinorVersion;
+ DWORD dwBuildNumber;
char szVersion[MAX_VERSION_LENGTH];
char szDescription[MAX_DESCRIPTION_LENGTH];
+ char szCSDVersion[128];
+ WORD wServicePackMajor;
+ WORD wServicePackMinor;
+ char szProductType[64];
} VERSION_DESC;
#define DLL_NATIVE 0x0000
Index: programs/winecfg/winecfg.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/winecfg.c,v
retrieving revision 1.37
diff -u -p -r1.37 winecfg.c
--- programs/winecfg/winecfg.c 23 Jun 2005 11:42:54 -0000 1.37
+++ programs/winecfg/winecfg.c 16 Aug 2005 17:20:59 -0000
@@ -139,11 +139,11 @@ end:
*
* If valueName or value is NULL, an empty section will be created
*/
-static int set_config_key(HKEY root, const char *subkey, const char *name, const char *value) {
+static int set_config_key(HKEY root, const char *subkey, const char *name, const BYTE *value, DWORD type) {
DWORD res = 1;
HKEY key = NULL;
- WINE_TRACE("subkey=%s: name=%s, value=%s\n", subkey, name, value);
+ WINE_TRACE("subkey=%s: name=%s, value=%s, type=%ld\n", subkey, name, value, type);
assert( subkey != NULL );
@@ -155,7 +155,11 @@ static int set_config_key(HKEY root, con
else key = root;
if (name == NULL || value == NULL) goto end;
- res = RegSetValueEx(key, name, 0, REG_SZ, value, strlen(value) + 1);
+ switch (type)
+ {
+ case REG_SZ: res = RegSetValueEx(key, name, 0, REG_SZ, value, strlen(value) + 1); break;
+ case REG_DWORD: res = RegSetValueEx(key, name, 0, REG_DWORD, value, sizeof(DWORD)); break;
+ }
if (res != ERROR_SUCCESS) goto end;
res = 0;
@@ -213,6 +217,7 @@ struct setting
char *path; /* path in the registry rooted at root */
char *name; /* name of the registry value. if null, this means delete the key */
char *value; /* contents of the registry value. if null, this means delete the value */
+ DWORD type; /* type of registry value. REG_SZ or REG_DWORD for now */
};
struct list *settings;
@@ -281,9 +286,11 @@ char *get_reg_key(HKEY root, const char
*
* value is what to set the value to, or NULL to delete it.
*
+ * type is REG_SZ or REG_DWORD.
+ *
* These values will be copied when necessary.
*/
-void set_reg_key(HKEY root, const char *path, const char *name, const char *value)
+void set_reg_key_ex(HKEY root, const char *path, const char *name, const char *value, DWORD type)
{
struct list *cursor;
struct setting *s;
@@ -309,7 +316,21 @@ void set_reg_key(HKEY root, const char *
/* yes, we have already set it, so just replace the content and return */
HeapFree(GetProcessHeap(), 0, s->value);
- s->value = value ? strdupA(value) : NULL;
+ switch (type)
+ {
+ case REG_SZ:
+ s->value = value ? strdupA(value) : NULL;
+ break;
+ case REG_DWORD:
+ if (value)
+ {
+ s->value = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD));
+ *(PDWORD)(s->value) = (DWORD)value;
+ }
+ else
+ s->value = NULL;
+ break;
+ }
/* are we deleting this key? this won't remove any of the
* children from the overlay so if the user adds it again in
@@ -329,11 +350,36 @@ void set_reg_key(HKEY root, const char *
s->root = root;
s->path = strdupA(path);
s->name = name ? strdupA(name) : NULL;
- s->value = value ? strdupA(value) : NULL;
+ s->type = type;
+ switch (type)
+ {
+ case REG_SZ:
+ s->value = value ? strdupA(value) : NULL;
+ break;
+ case REG_DWORD:
+ if (value)
+ {
+ s->value = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD));
+ *(PDWORD)(s->value) = (DWORD)value;
+ }
+ else
+ s->value = NULL;
+ break;
+ }
list_add_tail(settings, &s->entry);
}
+void set_reg_key(HKEY root, const char *path, const char *name, const char *value)
+{
+ set_reg_key_ex(root, path, name, value, REG_SZ);
+}
+
+void set_reg_key_dword(HKEY root, const char *path, const char *name, DWORD value)
+{
+ set_reg_key_ex(root, path, name, (const char*)value, REG_DWORD);
+}
+
/**
* enumerates the value names at the given path, taking into account
* the changes in the settings list.
@@ -466,7 +512,7 @@ static void process_setting(struct setti
if (s->value)
{
WINE_TRACE("Setting %s:%s to '%s'\n", s->path, s->name, s->value);
- set_config_key(s->root, s->path, s->name, s->value);
+ set_config_key(s->root, s->path, s->name, s->value, s->type);
}
else
{
Index: programs/winecfg/winecfg.h
===================================================================
RCS file: /home/wine/wine/programs/winecfg/winecfg.h,v
retrieving revision 1.26
diff -u -p -r1.26 winecfg.h
--- programs/winecfg/winecfg.h 23 Jun 2005 11:42:54 -0000 1.26
+++ programs/winecfg/winecfg.h 16 Aug 2005 17:20:59 -0000
@@ -52,6 +52,7 @@ extern char *current_app; /* NULL means
*/
void set_reg_key(HKEY root, const char *path, const char *name, const char *value);
+void set_reg_key_dword(HKEY root, const char *path, const char *name, DWORD value);
char *get_reg_key(HKEY root, const char *path, const char *name, const char *def);
BOOL reg_key_exists(HKEY root, const char *path, const char *name);
void apply(void);
More information about the wine-patches
mailing list