make correct use of tchar.h in taskmgr and build it as unicode by default Modified: trunk/reactos/include/tchar.h Modified: trunk/reactos/subsys/system/taskmgr/dbgchnl.c Modified: trunk/reactos/subsys/system/taskmgr/makefile Modified: trunk/reactos/subsys/system/taskmgr/perfpage.c Modified: trunk/reactos/subsys/system/taskmgr/run.c Modified: trunk/reactos/subsys/system/taskmgr/run.h _____
Modified: trunk/reactos/include/tchar.h --- trunk/reactos/include/tchar.h 2005-05-04 18:53:47 UTC (rev 14975) +++ trunk/reactos/include/tchar.h 2005-05-04 19:29:28 UTC (rev 14976) @@ -6,7 +6,7 @@
#ifdef _UNICODE
- #define __TEXT(q) L##q + #define __T(q) L##q
#ifndef _TCHAR_DEFINED #ifndef RC_INVOKED @@ -203,7 +203,7 @@
#else
- #define __TEXT(q) q + #define __T(q) q
#ifndef _TCHAR_DEFINED #ifndef RC_INVOKED @@ -403,8 +403,8 @@
-#define _TEXT(x) __TEXT(x) -#define _T(x) __TEXT(x) +#define _TEXT(x) __T(x) +#define _T(x) __T(x)
#endif /* _TCHAR_H_ */
_____
Modified: trunk/reactos/subsys/system/taskmgr/dbgchnl.c --- trunk/reactos/subsys/system/taskmgr/dbgchnl.c 2005-05-04 18:53:47 UTC (rev 14975) +++ trunk/reactos/subsys/system/taskmgr/dbgchnl.c 2005-05-04 19:29:28 UTC (rev 14976) @@ -69,11 +69,11 @@
return dwProcessId; }
-static int list_channel_CB(HANDLE hProcess, void* addr, char* buffer, void* user) +static int list_channel_CB(HANDLE hProcess, void* addr, TCHAR* buffer, void* user) { int j; - char val[2]; - LVITEMA lvi; + TCHAR val[2]; + LVITEM lvi; int index; HWND hChannelLV = (HWND)user;
@@ -85,10 +85,10 @@ index = ListView_InsertItem(hChannelLV, &lvi); if (index == -1) return 0;
- val[1] = '\0'; + val[1] = TEXT('\0'); for (j = 0; j < 4; j++) { - val[0] = (buffer[0] & (1 << j)) ? 'x' : ' '; + val[0] = (buffer[0] & (1 << j)) ? TEXT('x') : TEXT(' '); ListView_SetItemText(hChannelLV, index, j + 1, val); } return 1; @@ -96,7 +96,7 @@
struct cce_user { - const char* name; /* channel to look for */ + LPCTSTR name; /* channel to look for */ unsigned value, mask; /* how to change channel */ unsigned done; /* number of successful changes */ unsigned notdone; /* number of unsuccessful changes */ @@ -107,11 +107,11 @@ * * Callback used for changing a given channel attributes */ -static int change_channel_CB(HANDLE hProcess, void* addr, char* buffer, void* pmt) +static int change_channel_CB(HANDLE hProcess, void* addr, TCHAR* buffer, void* pmt) { struct cce_user* user = (struct cce_user*)pmt;
- if (!user->name || !strcmp(buffer + 1, user->name)) + if (!user->name || !_tcscmp(buffer + 1, user->name)) { buffer[0] = (buffer[0] & ~user->mask) | (user->value & user->mask); if (WriteProcessMemory(hProcess, addr, buffer, 1, NULL)) @@ -222,7 +222,7 @@ int nb_channels; };
-typedef int (*EnumChannelCB)(HANDLE, void*, char*, void*); +typedef int (*EnumChannelCB)(HANDLE, void*, TCHAR*, void*);
/****************************************************************** * enum_channel @@ -235,15 +235,15 @@ struct dll_option_layout dol; int i, j, ret = 1; void* buf_addr; - char buffer[32]; + TCHAR buffer[32]; void* addr; - const char** cache = NULL; + const TCHAR** cache = NULL; unsigned num_cache, used_cache;
addr = get_symbol(hProcess, "first_dll", "libwine.so"); if (!addr) return -1; if (unique) - cache = HeapAlloc(GetProcessHeap(), 0, (num_cache = 32) * sizeof(char*)); + cache = HeapAlloc(GetProcessHeap(), 0, (num_cache = 32) * sizeof(TCHAR*)); else num_cache = 0; used_cache = 0; @@ -265,12 +265,12 @@ * them again */ for (j = 0; j < used_cache; j++) - if (!strcmp(cache[j], buffer + 1)) break; + if (!_tcscmp(cache[j], buffer + 1)) break; if (j != used_cache) continue; if (used_cache == num_cache) - cache = HeapReAlloc(GetProcessHeap(), 0, cache, (num_cache *= 2) * sizeof(char*)); - cache[used_cache++] = strcpy(HeapAlloc(GetProcessHeap(), 0, strlen(buffer + 1) + 1), - buffer + 1); + cache = HeapReAlloc(GetProcessHeap(), 0, cache, (num_cache *= 2) * sizeof(TCHAR*)); + cache[used_cache++] = _tcscpy(HeapAlloc(GetProcessHeap(), 0, (_tcslen(buffer + 1) + 1) * sizeof(TCHAR)), + buffer + 1); } ret = ce(hProcess, buf_addr, buffer, user); } @@ -278,7 +278,7 @@ } if (unique) { - for (j = 0; j < used_cache; j++) HeapFree(GetProcessHeap(), 0, (char*)cache[j]); + for (j = 0; j < used_cache; j++) HeapFree(GetProcessHeap(), 0, (TCHAR*)cache[j]); HeapFree(GetProcessHeap(), 0, cache); } return 0; @@ -365,13 +365,13 @@ ListView_GetItemText(hChannelLV, lhti.iItem, 0, name, sizeof(name) / sizeof(name[0])); ListView_GetItemText(hChannelLV, lhti.iItem, lhti.iSubItem, val, sizeof(val) / sizeof(val[0])); user.name = name; - user.value = (val[0] == 'x') ? 0 : bitmask; + user.value = (val[0] == TEXT('x')) ? 0 : bitmask; user.mask = bitmask; user.done = user.notdone = 0; enum_channel(hProcess, change_channel_CB, &user, FALSE); if (user.done) { - val[0] ^= ('x' ^ ' '); + val[0] ^= (TEXT('x') ^ TEXT(' ')); ListView_SetItemText(hChannelLV, lhti.iItem, lhti.iSubItem, val); } if (user.notdone) _____
Modified: trunk/reactos/subsys/system/taskmgr/makefile --- trunk/reactos/subsys/system/taskmgr/makefile 2005-05-04 18:53:47 UTC (rev 14975) +++ trunk/reactos/subsys/system/taskmgr/makefile 2005-05-04 19:29:28 UTC (rev 14976) @@ -16,7 +16,7 @@
TARGET_PCH = precomp.h
-TARGET_CFLAGS = -Werror -Wall -DDBG -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__USE_W32API +TARGET_CFLAGS = -Werror -Wall -DDBG -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__USE_W32API -DUNICODE -D_UNICODE TARGET_SDKLIBS = ntdll.a kernel32.a user32.a gdi32.a comctl32.a
_____
Modified: trunk/reactos/subsys/system/taskmgr/perfpage.c --- trunk/reactos/subsys/system/taskmgr/perfpage.c 2005-05-04 18:53:47 UTC (rev 14975) +++ trunk/reactos/subsys/system/taskmgr/perfpage.c 2005-05-04 19:29:28 UTC (rev 14976) @@ -355,11 +355,11 @@
CommitChargeTotal = PerfDataGetCommitChargeTotalK(); CommitChargeLimit = PerfDataGetCommitChargeLimitK(); CommitChargePeak = PerfDataGetCommitChargePeakK(); - _ultoa(CommitChargeTotal, Text, 10); + _ultot(CommitChargeTotal, Text, 10);
SetWindowText(hPerformancePageCommitChargeTotalEdit, Text); - _ultoa(CommitChargeLimit, Text, 10); + _ultot(CommitChargeLimit, Text, 10);
SetWindowText(hPerformancePageCommitChargeLimitEdit, Text); - _ultoa(CommitChargePeak, Text, 10); + _ultot(CommitChargePeak, Text, 10);
SetWindowText(hPerformancePageCommitChargePeakEdit, Text); wsprintf(Text, szMemUsage, CommitChargeTotal, CommitChargeLimit); SendMessage(hStatusWnd, SB_SETTEXT, 2, (LPARAM)Text); @@ -370,11 +370,11 @@ KernelMemoryTotal = PerfDataGetKernelMemoryTotalK(); KernelMemoryPaged = PerfDataGetKernelMemoryPagedK(); KernelMemoryNonPaged = PerfDataGetKernelMemoryNonPagedK(); - _ultoa(KernelMemoryTotal, Text, 10); + _ultot(KernelMemoryTotal, Text, 10);
SetWindowText(hPerformancePageKernelMemoryTotalEdit, Text); - _ultoa(KernelMemoryPaged, Text, 10); + _ultot(KernelMemoryPaged, Text, 10);
SetWindowText(hPerformancePageKernelMemoryPagedEdit, Text); - _ultoa(KernelMemoryNonPaged, Text, 10); + _ultot(KernelMemoryNonPaged, Text, 10);
SetWindowText(hPerformancePageKernelMemoryNonPagedEdit, Text);
/* @@ -383,11 +383,11 @@ PhysicalMemoryTotal = PerfDataGetPhysicalMemoryTotalK(); PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK(); PhysicalMemorySystemCache = PerfDataGetPhysicalMemorySystemCacheK(); - _ultoa(PhysicalMemoryTotal, Text, 10); + _ultot(PhysicalMemoryTotal, Text, 10);
SetWindowText(hPerformancePagePhysicalMemoryTotalEdit, Text); - _ultoa(PhysicalMemoryAvailable, Text, 10); + _ultot(PhysicalMemoryAvailable, Text, 10);
SetWindowText(hPerformancePagePhysicalMemoryAvailableEdit, Text); - _ultoa(PhysicalMemorySystemCache, Text, 10); + _ultot(PhysicalMemorySystemCache, Text, 10);
SetWindowText(hPerformancePagePhysicalMemorySystemCacheEdit, Text);
/* @@ -396,11 +396,11 @@ TotalHandles = PerfDataGetSystemHandleCount(); TotalThreads = PerfDataGetTotalThreadCount(); TotalProcesses = PerfDataGetProcessCount(); - _ultoa(TotalHandles, Text, 10); + _ultot(TotalHandles, Text, 10);
SetWindowText(hPerformancePageTotalsHandleCountEdit, Text); - _ultoa(TotalThreads, Text, 10); + _ultot(TotalThreads, Text, 10);
SetWindowText(hPerformancePageTotalsThreadCountEdit, Text); - _ultoa(TotalProcesses, Text, 10); + _ultot(TotalProcesses, Text, 10);
SetWindowText(hPerformancePageTotalsProcessCountEdit, Text);
/* _____
Modified: trunk/reactos/subsys/system/taskmgr/run.c --- trunk/reactos/subsys/system/taskmgr/run.c 2005-05-04 18:53:47 UTC (rev 14975) +++ trunk/reactos/subsys/system/taskmgr/run.c 2005-05-04 19:29:28 UTC (rev 14976) @@ -27,38 +27,43 @@
{ HMODULE hShell32; RUNFILEDLG RunFileDlg; - OSVERSIONINFO versionInfo; - WCHAR wTitle[40]; - WCHAR wText[256]; - TCHAR szTemp[256]; - char szTitle[40]; - char szText[256]; + TCHAR szTitle[40]; + TCHAR szText[256];
- /* Load language string from resource file */ - LoadString(hInst, IDS_CREATENEWTASK, szTemp, 40); - strcpy(szTitle,szTemp); + /* Load language strings from resource file */ + LoadString(hInst, IDS_CREATENEWTASK, szTitle, sizeof(szTitle) / sizeof(szTitle[0])); + LoadString(hInst, IDS_CREATENEWTASK_DESC, szText, sizeof(szText) / sizeof(szText[0]));
- LoadString(hInst, IDS_CREATENEWTASK_DESC, szTemp, 256); - strcpy(szText,szTemp);
- hShell32 = LoadLibrary(_T("SHELL32.DLL")); - RunFileDlg = (RUNFILEDLG)(FARPROC)GetProcAddress(hShell32, (char*)((long)0x3D)); + RunFileDlg = (RUNFILEDLG)(FARPROC)GetProcAddress(hShell32, (LPCSTR)0x3D);
/* Show "Run..." dialog */ if (RunFileDlg) { - versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&versionInfo); - - if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) +#ifndef UNICODE + if (GetVersion() < 0x80000000) { - MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szTitle, -1, wTitle, 40); - MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szText, -1, wText, 256); - RunFileDlg(hMainWnd, 0, NULL, (LPCSTR)wTitle, (LPCSTR)wText, RFF_CALCDIRECTORY); + WCHAR wTitle[40]; + WCHAR wText[256]; + + /* RunFileDlg is always unicode on NT systems, convert the ansi + strings to unicode */ + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szTitle, -1, wTitle, sizeof(szTitle) / sizeof(szTitle[0])); + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szText, -1, wText, sizeof(szText) / sizeof(szText[0])); + + RunFileDlg(hMainWnd, 0, NULL, wTitle, wText, RFF_CALCDIRECTORY); } else - RunFileDlg(hMainWnd, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY); + { + /* RunFileDlg is ansi on win 9x systems */ + RunFileDlg(hMainWnd, 0, NULL, (LPCWSTR)szTitle, (LPCWSTR)szText, RFF_CALCDIRECTORY); + } +#else + /* NOTE - don't check whether running on win 9x or NT, let's just + assume that a unicode build only runs on NT */ + RunFileDlg(hMainWnd, 0, NULL, szTitle, szText, RFF_CALCDIRECTORY); +#endif }
FreeLibrary(hShell32); _____
Modified: trunk/reactos/subsys/system/taskmgr/run.h --- trunk/reactos/subsys/system/taskmgr/run.h 2005-05-04 18:53:47 UTC (rev 14975) +++ trunk/reactos/subsys/system/taskmgr/run.h 2005-05-04 19:29:28 UTC (rev 14976) @@ -36,9 +36,9 @@
typedef void (WINAPI *RUNFILEDLG)( HWND hwndOwner, HICON hIcon, -LPCSTR lpstrDirectory, -LPCSTR lpstrTitle, -LPCSTR lpstrDescription, +LPCWSTR lpstrDirectory, +LPCWSTR lpstrTitle, +LPCWSTR lpstrDescription, UINT uFlags);
/*