Commit b28a6c18 authored by Vladimir Pankratov's avatar Vladimir Pankratov Committed by Alexandre Julliard

taskmgr: Converted some functions and variables to Unicode.

parent 098dc7b3
......@@ -4,6 +4,7 @@
* debug.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
* Copyright (C) 2008 Vladimir Pankratov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -26,26 +27,43 @@
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <winnt.h>
#include "wine/unicode.h"
#include "taskmgr.h"
#include "perfdata.h"
void ProcessPage_OnDebug(void)
{
LVITEM lvitem;
LVITEMW lvitem;
ULONG Index;
DWORD dwProcessId;
TCHAR strErrorText[260];
HKEY hKey;
TCHAR strDebugPath[260];
TCHAR strDebugger[260];
WCHAR wstrErrorText[256];
HKEY hKey;
WCHAR wstrDebugPath[256];
WCHAR wstrDebugger[256];
DWORD dwDebuggerSize;
PROCESS_INFORMATION pi;
STARTUPINFO si;
HANDLE hDebugEvent;
PROCESS_INFORMATION pi;
STARTUPINFOW si;
HANDLE hDebugEvent;
static const WCHAR wszWarnTitle[] = {'T','a','s','k',' ','M','a','n','a','g','e','r',' ',
'W','a','r','n','i','n','g',0};
static const WCHAR wszUnable2Debug[] = {'U','n','a','b','l','e',' ','t','o',' ','D','e','b','u','g',' ',
'P','r','o','c','e','s','s',0};
static const WCHAR wszSubKey[] = {'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s',' ','N','T','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'A','e','D','e','b','u','g',0};
static const WCHAR wszDebugger[] = {'D','e','b','u','g','g','e','r',0};
static const WCHAR wszWarnMsg[] = {'W','A','R','N','I','N','G',':',' ','D','e','b','u','g','g','i','n','g',' ',
't','h','i','s',' ','p','r','o','c','e','s','s',' ','m','a','y',' ',
'r','e','s','u','l','t',' ','i','n',' ','l','o','s','s',' ','o','f',' ',
'd','a','t','a','.','\n','A','r','e',' ','y','o','u',' ','s','u','r','e',' ',
'y','o','u',' ','w','i','s','h',' ','t','o',' ','a','t','t','a','c','h',' ',
't','h','e',' ','d','e','b','u','g','g','e','r','?',0};
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{
......@@ -54,7 +72,7 @@ void ProcessPage_OnDebug(void)
lvitem.iItem = Index;
lvitem.iSubItem = 0;
SendMessage(hProcessPageListCtrl, LVM_GETITEM, 0, (LPARAM) &lvitem);
SendMessageW(hProcessPageListCtrl, LVM_GETITEMW, 0, (LPARAM) &lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
......@@ -65,25 +83,25 @@ void ProcessPage_OnDebug(void)
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return;
if (MessageBox(hMainWnd, _T("WARNING: Debugging this process may result in loss of data.\nAre you sure you wish to attach the debugger?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
if (MessageBoxW(hMainWnd, wszWarnMsg, wszWarnTitle, MB_YESNO|MB_ICONWARNING) != IDYES)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
MessageBoxW(hMainWnd, wstrErrorText, wszUnable2Debug, MB_OK|MB_ICONSTOP);
return;
}
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"), 0, KEY_READ, &hKey) != ERROR_SUCCESS)
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszSubKey, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
MessageBoxW(hMainWnd, wstrErrorText, wszUnable2Debug, MB_OK|MB_ICONSTOP);
return;
}
dwDebuggerSize = 260;
if (RegQueryValueEx(hKey, _T("Debugger"), NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) != ERROR_SUCCESS)
if (RegQueryValueExW(hKey, wszDebugger, NULL, NULL, (LPBYTE)wstrDebugger, &dwDebuggerSize) != ERROR_SUCCESS)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
MessageBoxW(hMainWnd, wstrErrorText, wszUnable2Debug, MB_OK|MB_ICONSTOP);
RegCloseKey(hKey);
return;
}
......@@ -93,20 +111,20 @@ void ProcessPage_OnDebug(void)
hDebugEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!hDebugEvent)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
MessageBoxW(hMainWnd, wstrErrorText, wszUnable2Debug, MB_OK|MB_ICONSTOP);
return;
}
wsprintf(strDebugPath, strDebugger, dwProcessId, hDebugEvent);
wsprintfW(wstrDebugPath, wstrDebugger, dwProcessId, hDebugEvent);
memset(&pi, 0, sizeof(PROCESS_INFORMATION));
memset(&si, 0, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
if (!CreateProcess(NULL, strDebugPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
memset(&si, 0, sizeof(STARTUPINFOW));
si.cb = sizeof(STARTUPINFOW);
if (!CreateProcessW(NULL, wstrDebugPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Debug Process"), MB_OK|MB_ICONSTOP);
GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
MessageBoxW(hMainWnd, wstrErrorText, wszUnable2Debug, MB_OK|MB_ICONSTOP);
}
CloseHandle(hDebugEvent);
......
......@@ -4,6 +4,7 @@
* endproc.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
* Copyright (C) 2008 Vladimir Pankratov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -26,20 +27,24 @@
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <winnt.h>
#include "wine/unicode.h"
#include "taskmgr.h"
#include "perfdata.h"
static const WCHAR wszWarnMsg[] = {'W','A','R','N','I','N','G',':',' ','T','e','r','m','i','n','a','t','i','n','g',' ','a',' ','p','r','o','c','e','s','s',' ','c','a','n',' ','c','a','u','s','e',' ','u','n','d','e','s','i','r','e','d','\n','r','e','s','u','l','t','s',' ','i','n','c','l','u','d','i','n','g',' ','l','o','s','s',' ','o','f',' ','d','a','t','a',' ','a','n','d',' ','s','y','s','t','e','m',' ','i','n','s','t','a','b','i','l','i','t','y','.',' ','T','h','e','\n','p','r','o','c','e','s','s',' ','w','i','l','l',' ','n','o','t',' ','b','e',' ','g','i','v','e','n',' ','t','h','e',' ','c','h','a','n','c','e',' ','t','o',' ','s','a','v','e',' ','i','t','s',' ','s','t','a','t','e',' ','o','r','\n','d','a','t','a',' ','b','e','f','o','r','e',' ','i','t',' ','i','s',' ','t','e','r','m','i','n','a','t','e','d','.',' ','A','r','e',' ','y','o','u',' ','s','u','r','e',' ','y','o','u',' ','w','a','n','t',' ','t','o','\n','t','e','r','m','i','n','a','t','e',' ','t','h','e',' ','p','r','o','c','e','s','s','?',0};
static const WCHAR wszWarnTitle[] = {'T','a','s','k',' ','M','a','n','a','g','e','r',' ','W','a','r','n','i','n','g',0};
static const WCHAR wszUnable2Terminate[] = {'U','n','a','b','l','e',' ','t','o',' ','T','e','r','m','i','n','a','t','e',' ','P','r','o','c','e','s','s',0};
void ProcessPage_OnEndProcess(void)
{
LVITEM lvitem;
LVITEMW lvitem;
ULONG Index;
DWORD dwProcessId;
HANDLE hProcess;
TCHAR strErrorText[260];
HANDLE hProcess;
WCHAR wstrErrorText[256];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{
......@@ -48,7 +53,7 @@ void ProcessPage_OnEndProcess(void)
lvitem.iItem = Index;
lvitem.iSubItem = 0;
SendMessage(hProcessPageListCtrl, LVM_GETITEM, 0, (LPARAM) &lvitem);
SendMessageW(hProcessPageListCtrl, LVM_GETITEMW, 0, (LPARAM) &lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
......@@ -59,22 +64,22 @@ void ProcessPage_OnEndProcess(void)
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return;
if (MessageBox(hMainWnd, _T("WARNING: Terminating a process can cause undesired\nresults including loss of data and system instability. The\nprocess will not be given the chance to save its state or\ndata before it is terminated. Are you sure you want to\nterminate the process?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
if (MessageBoxW(hMainWnd, wszWarnMsg, wszWarnTitle, MB_YESNO|MB_ICONWARNING) != IDYES)
return;
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
if (!hProcess)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);
return;
}
if (!TerminateProcess(hProcess, 0))
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);
}
CloseHandle(hProcess);
......@@ -82,11 +87,11 @@ void ProcessPage_OnEndProcess(void)
void ProcessPage_OnEndProcessTree(void)
{
LVITEM lvitem;
LVITEMW lvitem;
ULONG Index;
DWORD dwProcessId;
HANDLE hProcess;
TCHAR strErrorText[260];
HANDLE hProcess;
WCHAR wstrErrorText[256];
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{
......@@ -95,7 +100,7 @@ void ProcessPage_OnEndProcessTree(void)
lvitem.iItem = Index;
lvitem.iSubItem = 0;
SendMessage(hProcessPageListCtrl, LVM_GETITEM, 0, (LPARAM) &lvitem);
SendMessageW(hProcessPageListCtrl, LVM_GETITEMW, 0, (LPARAM) &lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
......@@ -106,22 +111,22 @@ void ProcessPage_OnEndProcessTree(void)
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return;
if (MessageBox(hMainWnd, _T("WARNING: Terminating a process can cause undesired\nresults including loss of data and system instability. The\nprocess will not be given the chance to save its state or\ndata before it is terminated. Are you sure you want to\nterminate the process?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
if (MessageBoxW(hMainWnd, wszWarnMsg, wszWarnTitle, MB_YESNO|MB_ICONWARNING) != IDYES)
return;
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId);
if (!hProcess)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);
return;
}
if (!TerminateProcess(hProcess, 0))
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Terminate Process"), MB_OK|MB_ICONSTOP);
GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
MessageBoxW(hMainWnd, wstrErrorText,wszUnable2Terminate, MB_OK|MB_ICONSTOP);
}
CloseHandle(hProcess);
......
......@@ -4,6 +4,7 @@
* graph.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
* Copyright (C) 2008 Vladimir Pankratov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -26,10 +27,10 @@
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <winnt.h>
#include "wine/unicode.h"
#include "taskmgr.h"
#include "perfdata.h"
......@@ -45,7 +46,7 @@ static void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
RECT rcClient;
RECT rcBarLeft;
RECT rcBarRight;
TCHAR Text[260];
WCHAR Text[256];
ULONG CpuUsage;
ULONG CpuKernelUsage;
int nBars;
......@@ -56,6 +57,10 @@ static void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
int nBarsFree;
/* Top bars that are "unused", i.e. are dark green, representing free cpu time */
int i;
static const WCHAR wszFormatI[] = {'%','d','%','%',0};
static const WCHAR wszFormatII[] = {' ',' ','%','d','%','%',0};
static const WCHAR wszFormatIII[] = {' ','%','d','%','%',0};
/*
* Get the client area rectangle
......@@ -79,15 +84,15 @@ static void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
*/
if (CpuUsage == 100)
{
_stprintf(Text, _T("%d%%"), (int)CpuUsage);
sprintfW(Text, wszFormatI, (int)CpuUsage);
}
else if (CpuUsage < 10)
{
_stprintf(Text, _T(" %d%%"), (int)CpuUsage);
sprintfW(Text, wszFormatII, (int)CpuUsage);
}
else
{
_stprintf(Text, _T(" %d%%"), (int)CpuUsage);
sprintfW(Text, wszFormatIII, (int)CpuUsage);
}
/*
......@@ -221,7 +226,7 @@ static void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
RECT rcClient;
RECT rcBarLeft;
RECT rcBarRight;
TCHAR Text[260];
WCHAR Text[256];
ULONGLONG CommitChargeTotal;
ULONGLONG CommitChargeLimit;
int nBars;
......@@ -230,6 +235,8 @@ static void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
int nBarsFree;
/* Top bars that are "unused", i.e. are dark green, representing free memory */
int i;
static const WCHAR wszFormat[] = {'%','d','K',0};
/*
* Get the client area rectangle
......@@ -247,13 +254,13 @@ static void Graph_DrawMemUsageGraph(HDC hDC, HWND hWnd)
CommitChargeTotal = (ULONGLONG)PerfDataGetCommitChargeTotalK();
CommitChargeLimit = (ULONGLONG)PerfDataGetCommitChargeLimitK();
_stprintf(Text, _T("%dK"), (int)CommitChargeTotal);
sprintfW(Text, wszFormat, (int)CommitChargeTotal);
/*
* Draw the font text onto the graph
* The bottom 20 pixels are reserved for the text
*/
Font_DrawText(hDC, Text, ((rcClient.right - rcClient.left) - (_tcslen(Text) * 8)) / 2, rcClient.bottom - 11 - 5);
Font_DrawText(hDC, Text, ((rcClient.right - rcClient.left) - (strlenW(Text) * 8)) / 2, rcClient.bottom - 11 - 5);
/*
* Now we have to draw the graph
......
......@@ -4,6 +4,7 @@
* priority.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
* Copyright (C) 2008 Vladimir Pankratov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -26,20 +27,25 @@
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <stdio.h>
#include <winnt.h>
#include "wine/unicode.h"
#include "taskmgr.h"
#include "perfdata.h"
static void DoSetPriority(DWORD priority)
{
LVITEM lvitem;
LVITEMW lvitem;
ULONG Index;
DWORD dwProcessId;
HANDLE hProcess;
TCHAR strErrorText[260];
HANDLE hProcess;
WCHAR wstrErrorText[256];
static const WCHAR wszWarnMsg[] = {'W','A','R','N','I','N','G',':',' ','C','h','a','n','g','i','n','g',
' ','t','h','e',' ','p','r','i','o','r','i','t','y',' ','c','l','a','s','s',' ','o','f',' ','t','h','i','s',' ','p','r','o','c','e','s','s',' ','m','a','y','\n','c','a','u','s','e',' ','u','n','d','e','s','i','r','e','d',' ','r','e','s','u','l','t','s',' ','i','n','c','l','u','d','i','n','g',' ','s','y','s','t','e','m',' ','i','n','s','t','a','b','i','l','i','t','y','.',' ','A','r','e',' ','y','o','u','\n','s','u','r','e',' ','y','o','u',' ','w','a','n','t',' ','t','o',' ','c','h','a','n','g','e',' ','t','h','e',' ','p','r','i','o','r','i','t','y',' ','c','l','a','s','s','?',0};
static const WCHAR wszWarnTitle[] = {'T','a','s','k',' ','M','a','n','a','g','e','r',' ','W','a','r','n','i','n','g',0};
static const WCHAR wszUnable2Change[] = {'U','n','a','b','l','e',' ','t','o',' ','C','h','a','n','g','e',' ','P','r','i','o','r','i','t','y',0};
for (Index=0; Index<(ULONG)ListView_GetItemCount(hProcessPageListCtrl); Index++)
{
......@@ -48,7 +54,7 @@ static void DoSetPriority(DWORD priority)
lvitem.iItem = Index;
lvitem.iSubItem = 0;
SendMessage(hProcessPageListCtrl, LVM_GETITEM, 0, (LPARAM)&lvitem);
SendMessageW(hProcessPageListCtrl, LVM_GETITEMW, 0, (LPARAM)&lvitem);
if (lvitem.state & LVIS_SELECTED)
break;
......@@ -59,22 +65,22 @@ static void DoSetPriority(DWORD priority)
if ((ListView_GetSelectedCount(hProcessPageListCtrl) != 1) || (dwProcessId == 0))
return;
if (MessageBox(hMainWnd, _T("WARNING: Changing the priority class of this process may\ncause undesired results including system instability. Are you\nsure you want to change the priority class?"), _T("Task Manager Warning"), MB_YESNO|MB_ICONWARNING) != IDYES)
if (MessageBoxW(hMainWnd, wszWarnMsg, wszWarnTitle, MB_YESNO|MB_ICONWARNING) != IDYES)
return;
hProcess = OpenProcess(PROCESS_SET_INFORMATION, FALSE, dwProcessId);
if (!hProcess)
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
MessageBoxW(hMainWnd, wstrErrorText, wszUnable2Change, MB_OK|MB_ICONSTOP);
return;
}
if (!SetPriorityClass(hProcess, priority))
{
GetLastErrorText(strErrorText, 260);
MessageBox(hMainWnd, strErrorText, _T("Unable to Change Priority"), MB_OK|MB_ICONSTOP);
GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
MessageBoxW(hMainWnd, wstrErrorText, wszUnable2Change, MB_OK|MB_ICONSTOP);
}
CloseHandle(hProcess);
......
......@@ -146,7 +146,7 @@ void FillSolidRect(HDC hDC, LPCRECT lpRect, COLORREF clr);
void FillSolidRect2(HDC hDC, int x, int y, int cx, int cy, COLORREF clr);
void Draw3dRect(HDC hDC, int x, int y, int cx, int cy, COLORREF clrTopLeft, COLORREF clrBottomRight);
void Draw3dRect2(HDC hDC, LPRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottomRight);
void Font_DrawText(HDC hDC, LPCTSTR lpszText, int x, int y);
void Font_DrawText(HDC hDC, LPWSTR lpwszText, int x, int y);
#define OPTIONS_MENU_INDEX 1
......@@ -156,7 +156,7 @@ void TaskManager_OnOptionsHideWhenMinimized(void);
void TaskManager_OnOptionsShow16BitTasks(void);
void TaskManager_OnFileNew(void);
LPTSTR GetLastErrorText( LPTSTR lpszBuf, DWORD dwSize );
LPWSTR GetLastErrorText( LPWSTR lpwszBuf, DWORD dwSize );
void OnAbout(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment