Module: wine Branch: master Commit: b9265bc3a9e9a19515fda20d111730f8acfb348c URL: http://source.winehq.org/git/wine.git/?a=commit;h=b9265bc3a9e9a19515fda20d11...
Author: Jason Edmeades us@edmeades.me.uk Date: Thu Mar 8 00:40:54 2007 +0000
cmd.exe: Support default colours for wineconsole.
---
programs/cmd/wcmdmain.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 59 insertions(+), 1 deletions(-)
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 327cfba..c8a7943 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -262,10 +262,68 @@ int main (int argc, char *argv[]) /* Note: cmd.exe /c dir does not get a new color, /k dir does */ if (opt_t) { if (!(((opt_t & 0xF0) >> 4) == (opt_t & 0x0F))) { - defaultColor = opt_t; + defaultColor = opt_t & 0xFF; param1[0] = 0x00; WCMD_color(); } + } else { + /* Check HKCU\Software\Microsoft\Command Processor + Then HKLM\Software\Microsoft\Command Processor + for defaultcolour value + Note Can be supplied as DWORD or REG_SZ + Note2 When supplied as REG_SZ it's in decimal!!! */ + HKEY key; + DWORD type; + DWORD value=0, size=4; + + if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software\Microsoft\Command Processor", + 0, KEY_READ, &key) == ERROR_SUCCESS) { + char strvalue[4]; + + /* See if DWORD or REG_SZ */ + if (RegQueryValueEx(key, "DefaultColor", NULL, &type, + NULL, NULL) == ERROR_SUCCESS) { + if (type == REG_DWORD) { + size = sizeof(DWORD); + RegQueryValueEx(key, "DefaultColor", NULL, NULL, + (LPBYTE)&value, &size); + } else if (type == REG_SZ) { + size = sizeof(strvalue); + RegQueryValueEx(key, "DefaultColor", NULL, NULL, + (LPBYTE)strvalue, &size); + value = strtoul(strvalue, NULL, 10); + } + } + } + + if (value == 0 && RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "Software\Microsoft\Command Processor", + 0, KEY_READ, &key) == ERROR_SUCCESS) { + char strvalue[4]; + + /* See if DWORD or REG_SZ */ + if (RegQueryValueEx(key, "DefaultColor", NULL, &type, + NULL, NULL) == ERROR_SUCCESS) { + if (type == REG_DWORD) { + size = sizeof(DWORD); + RegQueryValueEx(key, "DefaultColor", NULL, NULL, + (LPBYTE)&value, &size); + } else if (type == REG_SZ) { + size = sizeof(strvalue); + RegQueryValueEx(key, "DefaultColor", NULL, NULL, + (LPBYTE)strvalue, &size); + value = strtoul(strvalue, NULL, 10); + } + } + } + + /* If one found, set the screen to that colour */ + if (!(((value & 0xF0) >> 4) == (value & 0x0F))) { + defaultColor = value & 0xFF; + param1[0] = 0x00; + WCMD_color(); + } + }
if (opt_k) {