diff --git a/reactos/include/tchar.h b/reactos/include/tchar.h index 9225bf2babd..fe0c94b8770 100644 --- a/reactos/include/tchar.h +++ b/reactos/include/tchar.h @@ -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_ */ diff --git a/reactos/subsys/system/taskmgr/dbgchnl.c b/reactos/subsys/system/taskmgr/dbgchnl.c index aedc5f995c5..e49618e96b9 100644 --- a/reactos/subsys/system/taskmgr/dbgchnl.c +++ b/reactos/subsys/system/taskmgr/dbgchnl.c @@ -69,11 +69,11 @@ static DWORD get_selected_pid(void) 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 @@ static int list_channel_CB(HANDLE hProcess, void* addr, char* buffer, void* 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 @@ static int list_channel_CB(HANDLE hProcess, void* addr, char* buffer, void* 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 @@ struct cce_user * * 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 @@ struct dll_option_layout int nb_channels; }; -typedef int (*EnumChannelCB)(HANDLE, void*, char*, void*); +typedef int (*EnumChannelCB)(HANDLE, void*, TCHAR*, void*); /****************************************************************** * enum_channel @@ -235,15 +235,15 @@ static int enum_channel(HANDLE hProcess, EnumChannelCB ce, void* user, unsigned 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 @@ static int enum_channel(HANDLE hProcess, EnumChannelCB ce, void* user, unsigned * 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 @@ static int enum_channel(HANDLE hProcess, EnumChannelCB ce, void* user, unsigned } 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 @@ static void DebugChannels_OnNotify(HWND hDlg, LPARAM lParam) 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) diff --git a/reactos/subsys/system/taskmgr/makefile b/reactos/subsys/system/taskmgr/makefile index cd1ba71805a..a2e3879fe77 100644 --- a/reactos/subsys/system/taskmgr/makefile +++ b/reactos/subsys/system/taskmgr/makefile @@ -16,7 +16,7 @@ TARGET_INSTALLDIR = system32 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 diff --git a/reactos/subsys/system/taskmgr/perfpage.c b/reactos/subsys/system/taskmgr/perfpage.c index ae07c86b3f5..17d7b995583 100644 --- a/reactos/subsys/system/taskmgr/perfpage.c +++ b/reactos/subsys/system/taskmgr/perfpage.c @@ -355,11 +355,11 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter) 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 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter) 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 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter) 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 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter) 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); /* diff --git a/reactos/subsys/system/taskmgr/run.c b/reactos/subsys/system/taskmgr/run.c index 08a228bf737..a3c3b7c23df 100644 --- a/reactos/subsys/system/taskmgr/run.c +++ b/reactos/subsys/system/taskmgr/run.c @@ -27,38 +27,43 @@ void TaskManager_OnFileNew(void) { 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); - - LoadString(hInst, IDS_CREATENEWTASK_DESC, szTemp, 256); - strcpy(szText,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])); 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); diff --git a/reactos/subsys/system/taskmgr/run.h b/reactos/subsys/system/taskmgr/run.h index e98db0a5180..1cf178333e7 100644 --- a/reactos/subsys/system/taskmgr/run.h +++ b/reactos/subsys/system/taskmgr/run.h @@ -36,9 +36,9 @@ void TaskManager_OnFileNew(void); typedef void (WINAPI *RUNFILEDLG)( HWND hwndOwner, HICON hIcon, -LPCSTR lpstrDirectory, -LPCSTR lpstrTitle, -LPCSTR lpstrDescription, +LPCWSTR lpstrDirectory, +LPCWSTR lpstrTitle, +LPCWSTR lpstrDescription, UINT uFlags); /*