From 77f0a61ec8f1488d6042b1370444bb2612604292 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 10 Jan 2023 21:24:21 +0100 Subject: [PATCH] Get rid of TCHAR magic We never use Windows' "UNICODE" mode anyway, so let's get rid of this complexity. --- common/os/os.cxx | 6 +- common/os/os.h | 6 -- common/rdr/Exception.cxx | 1 - common/rfb/WinPasswdValidator.cxx | 7 +- vncviewer/parameters.cxx | 1 - win/rfb_win32/AboutDialog.cxx | 9 +- win/rfb_win32/CMakeLists.txt | 1 - win/rfb_win32/CleanDesktop.cxx | 5 +- win/rfb_win32/CleanDesktop.h | 2 - win/rfb_win32/Clipboard.cxx | 2 +- win/rfb_win32/ComputerName.h | 8 +- win/rfb_win32/CurrentUser.cxx | 12 +-- win/rfb_win32/CurrentUser.h | 3 +- win/rfb_win32/DeviceContext.cxx | 4 +- win/rfb_win32/DeviceContext.h | 3 +- win/rfb_win32/Dialog.cxx | 21 ++-- win/rfb_win32/Dialog.h | 15 +-- win/rfb_win32/EventManager.cxx | 2 + win/rfb_win32/LaunchProcess.cxx | 20 ++-- win/rfb_win32/LaunchProcess.h | 9 +- win/rfb_win32/ListViewControl.cxx | 13 ++- win/rfb_win32/ListViewControl.h | 8 +- win/rfb_win32/ModuleFileName.h | 7 +- win/rfb_win32/MonitorInfo.cxx | 1 - win/rfb_win32/MsgBox.h | 29 +++--- win/rfb_win32/MsgWindow.cxx | 15 ++- win/rfb_win32/MsgWindow.h | 9 +- win/rfb_win32/RegConfig.cxx | 10 +- win/rfb_win32/RegConfig.h | 4 +- win/rfb_win32/Registry.cxx | 86 ++++++++-------- win/rfb_win32/Registry.h | 44 ++++----- win/rfb_win32/SDisplay.cxx | 6 +- win/rfb_win32/SDisplayCorePolling.cxx | 2 +- win/rfb_win32/SInput.cxx | 1 - win/rfb_win32/Security.cxx | 16 +-- win/rfb_win32/Security.h | 9 +- win/rfb_win32/Service.cxx | 61 ++++++------ win/rfb_win32/Service.h | 24 ++--- win/rfb_win32/TCharArray.cxx | 89 ----------------- win/rfb_win32/TCharArray.h | 135 -------------------------- win/rfb_win32/TrayIcon.h | 8 +- win/rfb_win32/TsSessions.cxx | 3 +- win/rfb_win32/WMHooks.cxx | 2 +- win/rfb_win32/WMNotifier.cxx | 2 +- win/rfb_win32/WMPoller.cxx | 8 +- win/rfb_win32/Win32Util.cxx | 22 ++--- win/rfb_win32/Win32Util.h | 10 +- win/vncconfig/Authentication.h | 26 ++--- win/vncconfig/Connections.h | 60 ++++++------ win/vncconfig/Desktop.h | 12 +-- win/vncconfig/Hooking.h | 10 +- win/vncconfig/Inputs.h | 12 +-- win/vncconfig/Legacy.cxx | 108 ++++++++++----------- win/vncconfig/Legacy.h | 8 +- win/vncconfig/PasswordDialog.cxx | 14 +-- win/vncconfig/Sharing.h | 6 +- win/vncconfig/vncconfig.cxx | 18 ++-- win/winvnc/AddNewClientDialog.h | 5 +- win/winvnc/ControlPanel.cxx | 10 +- win/winvnc/QueryConnectDialog.cxx | 9 +- win/winvnc/STrayIcon.cxx | 14 +-- win/winvnc/STrayIcon.h | 5 +- win/winvnc/VNCServerService.cxx | 6 +- win/winvnc/VNCServerService.h | 4 +- win/winvnc/VNCServerWin32.cxx | 20 ++-- win/winvnc/VNCServerWin32.h | 3 +- win/winvnc/winvnc.cxx | 24 ++--- win/wm_hooks/wm_hooks.cxx | 18 ++-- 68 files changed, 453 insertions(+), 700 deletions(-) delete mode 100644 win/rfb_win32/TCharArray.cxx delete mode 100644 win/rfb_win32/TCharArray.h diff --git a/common/os/os.cxx b/common/os/os.cxx index aa9e2bae..31dbe5f3 100644 --- a/common/os/os.cxx +++ b/common/os/os.cxx @@ -44,7 +44,7 @@ static int gethomedir(char **dirp, bool userDir) uid_t uid; struct passwd *passwd; #else - TCHAR *dir; + char *dir; BOOL ret; #endif @@ -73,7 +73,7 @@ static int gethomedir(char **dirp, bool userDir) else memcpy(dir + len, "/.vnc/\0", 7); #else - dir = new TCHAR[MAX_PATH]; + dir = new char[MAX_PATH]; if (dir == NULL) return -1; @@ -89,7 +89,7 @@ static int gethomedir(char **dirp, bool userDir) if (userDir) dir[strlen(dir)+1] = '\0'; else - memcpy(dir+strlen(dir), (TCHAR *)"\\vnc\\\0", 6); + memcpy(dir+strlen(dir), "\\vnc\\\0", 6); #endif *dirp = dir; return 0; diff --git a/common/os/os.h b/common/os/os.h index d0717fd0..62acf829 100644 --- a/common/os/os.h +++ b/common/os/os.h @@ -24,9 +24,6 @@ * If HOME environment variable is set then it is used. * Otherwise home directory is obtained via getpwuid function. * - * Note for Windows: - * This functions returns array of TCHARs, not array of chars. - * * Returns: * 0 - Success * -1 - Failure @@ -38,9 +35,6 @@ int getvnchomedir(char **dirp); * If HOME environment variable is set then it is used. * Otherwise home directory is obtained via getpwuid function. * - * Note for Windows: - * This functions returns array of TCHARs, not array of chars. - * * Returns: * 0 - Success * -1 - Failure diff --git a/common/rdr/Exception.cxx b/common/rdr/Exception.cxx index 382fea3d..b1e0a841 100644 --- a/common/rdr/Exception.cxx +++ b/common/rdr/Exception.cxx @@ -28,7 +28,6 @@ #include #include #ifdef _WIN32 -#include #include #include #include diff --git a/common/rfb/WinPasswdValidator.cxx b/common/rfb/WinPasswdValidator.cxx index f07c27e8..18f113cd 100644 --- a/common/rfb/WinPasswdValidator.cxx +++ b/common/rfb/WinPasswdValidator.cxx @@ -24,7 +24,6 @@ #include #include -#include using namespace rfb; @@ -33,9 +32,9 @@ bool WinPasswdValidator::validateInternal(rfb::SConnection* /*sc*/, const char* username, const char* password) { - TCHAR* user = (TCHAR*) strDup(username); - TCHAR* pass = (TCHAR*) strDup(password); - TCHAR* domain = (TCHAR*) strDup("."); + char* user = strDup(username); + char* pass = strDup(password); + char* domain = strDup("."); HANDLE handle; BOOL ret = LogonUser(user, domain, pass, LOGON32_LOGON_NETWORK, diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx index 173406d5..d3b11532 100644 --- a/vncviewer/parameters.cxx +++ b/vncviewer/parameters.cxx @@ -28,7 +28,6 @@ #ifdef _WIN32 #include -#include #endif #include "parameters.h" diff --git a/win/rfb_win32/AboutDialog.cxx b/win/rfb_win32/AboutDialog.cxx index 992f0707..a48a1ea7 100644 --- a/win/rfb_win32/AboutDialog.cxx +++ b/win/rfb_win32/AboutDialog.cxx @@ -22,7 +22,6 @@ #include #include -#include #include using namespace rfb; @@ -42,12 +41,12 @@ bool AboutDialog::showDialog() { void AboutDialog::initDialog() { // Set the build time field - SetWindowText(GetDlgItem(handle, BuildTime), TStr(buildTime)); + SetWindowText(GetDlgItem(handle, BuildTime), buildTime); // Get our executable's version info FileVersionInfo verInfo; - SetWindowText(GetDlgItem(handle, Version), verInfo.getVerString(_T("ProductVersion"))); - SetWindowText(GetDlgItem(handle, Copyright), verInfo.getVerString(_T("LegalCopyright"))); - SetWindowText(GetDlgItem(handle, Description), verInfo.getVerString(_T("ProductName"))); + SetWindowText(GetDlgItem(handle, Version), verInfo.getVerString("ProductVersion")); + SetWindowText(GetDlgItem(handle, Copyright), verInfo.getVerString("LegalCopyright")); + SetWindowText(GetDlgItem(handle, Description), verInfo.getVerString("ProductName")); } diff --git a/win/rfb_win32/CMakeLists.txt b/win/rfb_win32/CMakeLists.txt index 682873e7..5a7d90c6 100644 --- a/win/rfb_win32/CMakeLists.txt +++ b/win/rfb_win32/CMakeLists.txt @@ -21,7 +21,6 @@ add_library(rfb_win32 STATIC Service.cxx SInput.cxx SocketManager.cxx - TCharArray.cxx TsSessions.cxx Win32Util.cxx WMCursor.cxx diff --git a/win/rfb_win32/CleanDesktop.cxx b/win/rfb_win32/CleanDesktop.cxx index f1545452..e69acd7f 100644 --- a/win/rfb_win32/CleanDesktop.cxx +++ b/win/rfb_win32/CleanDesktop.cxx @@ -65,7 +65,6 @@ struct ActiveDesktop { return false; } item.fChecked = enable_; - vlog.debug("%sbling %d: \"%s\"", enable_ ? "ena" : "disa", i, (const char*)CStr(item.wszFriendlyName)); hr = handle->ModifyDesktopItem(&item, COMP_ELEM_CHECKED); return hr == S_OK; @@ -257,8 +256,8 @@ void CleanDesktop::enableEffects() { vlog.debug("restore desktop effects"); RegKey desktopCfg; - desktopCfg.openKey(HKEY_CURRENT_USER, _T("Control Panel\\Desktop")); - SysParamsInfo(SPI_SETFONTSMOOTHING, desktopCfg.getInt(_T("FontSmoothing"), 0) != 0, 0, SPIF_SENDCHANGE); + desktopCfg.openKey(HKEY_CURRENT_USER, "Control Panel\\Desktop"); + SysParamsInfo(SPI_SETFONTSMOOTHING, desktopCfg.getInt("FontSmoothing", 0) != 0, 0, SPIF_SENDCHANGE); if (SysParamsInfo(SPI_SETUIEFFECTS, 0, (void*)(intptr_t)uiEffects, SPIF_SENDCHANGE) == ERROR_CALL_NOT_IMPLEMENTED) { SysParamsInfo(SPI_SETCOMBOBOXANIMATION, 0, (void*)(intptr_t)comboBoxAnim, SPIF_SENDCHANGE); SysParamsInfo(SPI_SETGRADIENTCAPTIONS, 0, (void*)(intptr_t)gradientCaptions, SPIF_SENDCHANGE); diff --git a/win/rfb_win32/CleanDesktop.h b/win/rfb_win32/CleanDesktop.h index 22e246fa..08268017 100644 --- a/win/rfb_win32/CleanDesktop.h +++ b/win/rfb_win32/CleanDesktop.h @@ -21,8 +21,6 @@ #ifndef __RFB_WIN32_CLEANDESKTOP_H__ #define __RFB_WIN32_CLEANDESKTOP_H__ -#include - namespace rfb { namespace win32 { diff --git a/win/rfb_win32/Clipboard.cxx b/win/rfb_win32/Clipboard.cxx index 68e7c505..9a9dfb6a 100644 --- a/win/rfb_win32/Clipboard.cxx +++ b/win/rfb_win32/Clipboard.cxx @@ -39,7 +39,7 @@ static LogWriter vlog("Clipboard"); // Clipboard::Clipboard() - : MsgWindow(_T("Clipboard")), notifier(0), next_window(0) { + : MsgWindow("Clipboard"), notifier(0), next_window(0) { next_window = SetClipboardViewer(getHandle()); vlog.debug("registered clipboard handler"); } diff --git a/win/rfb_win32/ComputerName.h b/win/rfb_win32/ComputerName.h index 110caa59..345ff0d7 100644 --- a/win/rfb_win32/ComputerName.h +++ b/win/rfb_win32/ComputerName.h @@ -20,17 +20,17 @@ #define __RFB_WIN32_COMPUTERNAME_H__ #include -#include +#include namespace rfb { namespace win32 { // Get the computer name - struct ComputerName : TCharArray { - ComputerName() : TCharArray(MAX_COMPUTERNAME_LENGTH+1) { + struct ComputerName : CharArray { + ComputerName() : CharArray(MAX_COMPUTERNAME_LENGTH+1) { ULONG namelength = MAX_COMPUTERNAME_LENGTH+1; if (!GetComputerName(buf, &namelength)) - _tcscpy(buf, _T("")); + strcpy(buf, ""); } }; diff --git a/win/rfb_win32/CurrentUser.cxx b/win/rfb_win32/CurrentUser.cxx index 7d420d99..153e415d 100644 --- a/win/rfb_win32/CurrentUser.cxx +++ b/win/rfb_win32/CurrentUser.cxx @@ -35,13 +35,13 @@ using namespace win32; static LogWriter vlog("CurrentUser"); -const TCHAR* shellIconClass = _T("Shell_TrayWnd"); +const char* shellIconClass = "Shell_TrayWnd"; BOOL CALLBACK enumWindows(HWND hwnd, LPARAM lParam) { - TCHAR className[16]; + char className[16]; if (GetClassName(hwnd, className, sizeof(className)) && - (_tcscmp(className, shellIconClass) == 0)) { - vlog.debug("located tray icon window (%s)", (const char*)CStr(className)); + (strcmp(className, shellIconClass) == 0)) { + vlog.debug("located tray icon window (%s)", className); DWORD processId = 0; GetWindowThreadProcessId(hwnd, &processId); if (!processId) @@ -61,7 +61,7 @@ BOOL CALLBACK enumDesktops(LPTSTR lpszDesktop, LPARAM lParam) { HDESK desktop = OpenDesktop(lpszDesktop, 0, FALSE, DESKTOP_ENUMERATE); vlog.debug("opening \"%s\"", lpszDesktop); if (!desktop) { - vlog.info("desktop \"%s\" inaccessible", (const char*)CStr(lpszDesktop)); + vlog.info("desktop \"%s\" inaccessible", lpszDesktop); return TRUE; } BOOL result = EnumDesktopWindows(desktop, enumWindows, lParam); @@ -110,7 +110,7 @@ ImpersonateCurrentUser::~ImpersonateCurrentUser() { } -UserName::UserName() : TCharArray(UNLEN+1) { +UserName::UserName() : CharArray(UNLEN+1) { DWORD len = UNLEN+1; if (!GetUserName(buf, &len)) throw rdr::SystemException("GetUserName failed", GetLastError()); diff --git a/win/rfb_win32/CurrentUser.h b/win/rfb_win32/CurrentUser.h index 9c020887..37fa65b2 100644 --- a/win/rfb_win32/CurrentUser.h +++ b/win/rfb_win32/CurrentUser.h @@ -26,6 +26,7 @@ #ifndef __RFB_WIN32_CURRENT_USER_H__ #define __RFB_WIN32_CURRENT_USER_H__ +#include #include #include @@ -66,7 +67,7 @@ namespace rfb { // Returns the name of the user the thread is currently running as. // Raises a SystemException in case of error. - struct UserName : public TCharArray { + struct UserName : public CharArray { UserName(); }; diff --git a/win/rfb_win32/DeviceContext.cxx b/win/rfb_win32/DeviceContext.cxx index 0a7d00a2..e59672f5 100644 --- a/win/rfb_win32/DeviceContext.cxx +++ b/win/rfb_win32/DeviceContext.cxx @@ -156,8 +156,8 @@ Rect DeviceContext::getClipBox(HDC dc) { } -DeviceDC::DeviceDC(const TCHAR* deviceName) { - dc = ::CreateDC(_T("DISPLAY"), deviceName, NULL, NULL); +DeviceDC::DeviceDC(const char* deviceName) { + dc = ::CreateDC("DISPLAY", deviceName, NULL, NULL); if (!dc) throw rdr::SystemException("failed to create DeviceDC", GetLastError()); } diff --git a/win/rfb_win32/DeviceContext.h b/win/rfb_win32/DeviceContext.h index 9d91cec2..0664684b 100644 --- a/win/rfb_win32/DeviceContext.h +++ b/win/rfb_win32/DeviceContext.h @@ -26,7 +26,6 @@ #include #include #include -#include namespace rfb { @@ -50,7 +49,7 @@ namespace rfb { // -=- DeviceContext that opens a specific display device class DeviceDC : public DeviceContext { public: - DeviceDC(const TCHAR* deviceName); + DeviceDC(const char* deviceName); ~DeviceDC(); }; diff --git a/win/rfb_win32/Dialog.cxx b/win/rfb_win32/Dialog.cxx index 369bea30..cb480506 100644 --- a/win/rfb_win32/Dialog.cxx +++ b/win/rfb_win32/Dialog.cxx @@ -26,7 +26,6 @@ #endif #include -#include #include #include #include @@ -58,7 +57,7 @@ Dialog::~Dialog() } -bool Dialog::showDialog(const TCHAR* resource, HWND owner) +bool Dialog::showDialog(const char* resource, HWND owner) { if (alreadyShowing) return false; handle = 0; @@ -82,8 +81,8 @@ int Dialog::getItemInt(int id) { throw rdr::Exception("unable to read dialog Int"); return result; } -TCHAR* Dialog::getItemString(int id) { - TCharArray tmp(256); +char* Dialog::getItemString(int id) { + CharArray tmp(256); if (!GetDlgItemText(handle, id, tmp.buf, 256)) tmp.buf[0] = 0; return tmp.takeBuf(); @@ -95,7 +94,7 @@ void Dialog::setItemChecked(int id, bool state) { void Dialog::setItemInt(int id, int value) { SetDlgItemInt(handle, id, value, TRUE); } -void Dialog::setItemString(int id, const TCHAR* s) { +void Dialog::setItemString(int id, const char* s) { SetDlgItemText(handle, id, s); } @@ -152,7 +151,7 @@ BOOL Dialog::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } -PropSheetPage::PropSheetPage(HINSTANCE inst, const TCHAR* id) : Dialog(inst), propSheet(0) { +PropSheetPage::PropSheetPage(HINSTANCE inst, const char* id) : Dialog(inst), propSheet(0) { page.dwSize = sizeof(page); page.dwFlags = 0; // PSP_USECALLBACK; page.hInstance = inst; @@ -207,8 +206,8 @@ BOOL PropSheetPage::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam } -PropSheet::PropSheet(HINSTANCE inst_, const TCHAR* title_, std::list pages_, HICON icon_) -: icon(icon_), pages(pages_), inst(inst_), title(tstrDup(title_)), handle(0), alreadyShowing(0) { +PropSheet::PropSheet(HINSTANCE inst_, const char* title_, std::list pages_, HICON icon_) +: icon(icon_), pages(pages_), inst(inst_), title(strDup(title_)), handle(0), alreadyShowing(0) { } PropSheet::~PropSheet() { @@ -283,7 +282,7 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo (void)capture; #ifdef _DIALOG_CAPTURE if (capture) { - plog.info("capturing \"%s\"", (const char*)CStr(title.buf)); + plog.info("capturing \"%s\"", title.buf); char* tmpdir = getenv("TEMP"); HDC dc = GetWindowDC(handle); DeviceFrameBuffer fb(dc); @@ -298,9 +297,9 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo DispatchMessage(&msg); } fb.grabRect(fb.getRect()); - TCHAR title[128]; + char title[128]; if (!GetWindowText(PropSheet_GetCurrentPageHwnd(handle), title, sizeof(title))) - _stprintf(title, _T("capture%d"), i); + sprintf(title, "capture%d", i); CharArray pageTitle(strDup(title)); for (int j=0; j #include #include -#include + +#include namespace rfb { @@ -51,7 +52,7 @@ namespace rfb { // expansion), and owner is an optional window handle - the corresponding // window is disabled while the dialog box is displayed. - bool showDialog(const TCHAR* resource, HWND owner=0); + bool showDialog(const char* resource, HWND owner=0); // initDialog() is called upon receipt of the WM_INITDIALOG message. @@ -76,12 +77,12 @@ namespace rfb { // Read the states of items bool isItemChecked(int id); int getItemInt(int id); - TCHAR* getItemString(int id); // Recipient owns string storage + char* getItemString(int id); // Recipient owns string storage // Set the states of items void setItemChecked(int id, bool state); void setItemInt(int id, int value); - void setItemString(int id, const TCHAR* s); + void setItemString(int id, const char* s); // enableItem is used to grey out an item, making it inaccessible, or to // re-enable it. @@ -105,7 +106,7 @@ namespace rfb { class PropSheet { public: - PropSheet(HINSTANCE inst, const TCHAR* title, std::list pages, HICON icon=0); + PropSheet(HINSTANCE inst, const char* title, std::list pages, HICON icon=0); virtual ~PropSheet(); // Display the PropertySheet @@ -130,14 +131,14 @@ namespace rfb { HICON icon; std::list pages; HINSTANCE inst; - TCharArray title; + CharArray title; HWND handle; bool alreadyShowing; }; class PropSheetPage : public Dialog { public: - PropSheetPage(HINSTANCE inst, const TCHAR* id); + PropSheetPage(HINSTANCE inst, const char* id); virtual ~PropSheetPage(); void setChanged(bool changed); diff --git a/win/rfb_win32/EventManager.cxx b/win/rfb_win32/EventManager.cxx index 401a8ee2..0f33f5ac 100644 --- a/win/rfb_win32/EventManager.cxx +++ b/win/rfb_win32/EventManager.cxx @@ -20,6 +20,8 @@ #include #endif +#include + #include #include #include diff --git a/win/rfb_win32/LaunchProcess.cxx b/win/rfb_win32/LaunchProcess.cxx index b19471e7..13d7e950 100644 --- a/win/rfb_win32/LaunchProcess.cxx +++ b/win/rfb_win32/LaunchProcess.cxx @@ -32,8 +32,8 @@ using namespace rfb; using namespace win32; -LaunchProcess::LaunchProcess(const TCHAR* exeName_, const TCHAR* params_) -: exeName(tstrDup(exeName_)), params(tstrDup(params_)) { +LaunchProcess::LaunchProcess(const char* exeName_, const char* params_) +: exeName(strDup(exeName_)), params(strDup(params_)) { memset(&procInfo, 0, sizeof(procInfo)); } @@ -64,22 +64,22 @@ void LaunchProcess::start(HANDLE userToken, bool createConsole) { sinfo.lpDesktop = desktopName; // - Concoct a suitable command-line - TCharArray exePath; - if (!tstrContains(exeName.buf, _T('\\'))) { + CharArray exePath; + if (!strContains(exeName.buf, '\\')) { ModuleFileName filename; - TCharArray path; splitPath(filename.buf, &path.buf, 0); - exePath.buf = new TCHAR[_tcslen(path.buf) + _tcslen(exeName.buf) + 2]; - _stprintf(exePath.buf, _T("%s\\%s"), path.buf, exeName.buf); + CharArray path; splitPath(filename.buf, &path.buf, 0); + exePath.buf = new char[strlen(path.buf) + strlen(exeName.buf) + 2]; + sprintf(exePath.buf, "%s\\%s", path.buf, exeName.buf); } else { - exePath.buf = tstrDup(exeName.buf); + exePath.buf = strDup(exeName.buf); } // - Start the process // Note: We specify the exe's precise path in the ApplicationName parameter, // AND include the name as the first part of the CommandLine parameter, // because CreateProcess doesn't make ApplicationName argv[0] in C programs. - TCharArray cmdLine(_tcslen(exeName.buf) + 3 + _tcslen(params.buf) + 1); - _stprintf(cmdLine.buf, _T("\"%s\" %s"), exeName.buf, params.buf); + CharArray cmdLine(strlen(exeName.buf) + 3 + strlen(params.buf) + 1); + sprintf(cmdLine.buf, "\"%s\" %s", exeName.buf, params.buf); DWORD flags = createConsole ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW; BOOL success; if (userToken != INVALID_HANDLE_VALUE) diff --git a/win/rfb_win32/LaunchProcess.h b/win/rfb_win32/LaunchProcess.h index 73213786..dc74682a 100644 --- a/win/rfb_win32/LaunchProcess.h +++ b/win/rfb_win32/LaunchProcess.h @@ -25,7 +25,8 @@ #define __RFB_WIN32_LAUNCHPROCESS_H__ #include -#include + +#include namespace rfb { @@ -33,7 +34,7 @@ namespace rfb { class LaunchProcess { public: - LaunchProcess(const TCHAR* exeName_, const TCHAR* params); + LaunchProcess(const char* exeName_, const char* params); ~LaunchProcess(); // start() starts the specified process with the supplied @@ -59,8 +60,8 @@ namespace rfb { PROCESS_INFORMATION procInfo; DWORD returnCode; protected: - TCharArray exeName; - TCharArray params; + CharArray exeName; + CharArray params; }; diff --git a/win/rfb_win32/ListViewControl.cxx b/win/rfb_win32/ListViewControl.cxx index 7c376582..8426e9c9 100644 --- a/win/rfb_win32/ListViewControl.cxx +++ b/win/rfb_win32/ListViewControl.cxx @@ -4,7 +4,6 @@ #ifdef HAVE_CONFIG_H #include #endif -#include #include "ListViewControl.h" #include "commctrl.h" ////////////////////////////////////////////////////////////////////// @@ -31,10 +30,10 @@ void ListViewControl::SelectLVItem(DWORD idListView, HWND hDlg, int numberItem) } BOOL ListViewControl::InitLVColumns(DWORD idListView, HWND hDlg, int width, int columns, - TCHAR *title[], DWORD mask, DWORD LVStyle, DWORD format) + char *title[], DWORD mask, DWORD LVStyle, DWORD format) { (void)ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, idListView), LVStyle); - TCHAR szText[256]; + char szText[256]; LVCOLUMN lvc; int iCol; @@ -46,14 +45,14 @@ BOOL ListViewControl::InitLVColumns(DWORD idListView, HWND hDlg, int width, int lvc.cx = width; lvc.fmt = format; - _tcscpy(szText, title[iCol]); + strcpy(szText, title[iCol]); if (ListView_InsertColumn(GetDlgItem(hDlg, idListView), iCol, &lvc) == -1) return FALSE; } return TRUE; } -BOOL ListViewControl::InsertLVItem(DWORD idListView, HWND hDlg, int number, TCHAR * texts[], +BOOL ListViewControl::InsertLVItem(DWORD idListView, HWND hDlg, int number, char * texts[], int columns) { int i; @@ -77,7 +76,7 @@ BOOL ListViewControl::InsertLVItem(DWORD idListView, HWND hDlg, int number, TCH } void ListViewControl::SetLVItemText(DWORD idListView, HWND hDlg, int numberItem, - int namberColumn, TCHAR * text) + int namberColumn, char * text) { ListView_SetItemText( GetDlgItem(hDlg, idListView), @@ -85,7 +84,7 @@ void ListViewControl::SetLVItemText(DWORD idListView, HWND hDlg, int numberItem, } void ListViewControl::GetLVItemText(DWORD idListView, HWND hDlg, int numberItem, - int namberColumn, TCHAR * text) + int namberColumn, char * text) { ListView_GetItemText(GetDlgItem(hDlg, idListView), numberItem, namberColumn, text, 256); diff --git a/win/rfb_win32/ListViewControl.h b/win/rfb_win32/ListViewControl.h index ac8bf3d3..4debd57e 100644 --- a/win/rfb_win32/ListViewControl.h +++ b/win/rfb_win32/ListViewControl.h @@ -18,13 +18,13 @@ namespace rfb { bool IsSelectedLVItem(DWORD idListView, HWND hDlg, int numberItem); void SelectLVItem(DWORD idListView, HWND hDlg, int numberItem); BOOL InitLVColumns(DWORD idListView, HWND hDlg, int width, int columns, - TCHAR * title[], DWORD mask, DWORD style, DWORD format); - BOOL InsertLVItem(DWORD idListView, HWND hDlg, int number, TCHAR * texts[], + char * title[], DWORD mask, DWORD style, DWORD format); + BOOL InsertLVItem(DWORD idListView, HWND hDlg, int number, char * texts[], int columns); void SetLVItemText(DWORD idListView, HWND hDlg, int numberItem, - int namberColumn, TCHAR * text); + int namberColumn, char * text); void GetLVItemText(DWORD idListView, HWND hDlg, int numberItem, - int namberColumn, TCHAR * text); + int namberColumn, char * text); void DeleteLVItem(DWORD idListView, HWND hDlg, int number); void DeleteAllLVItem(DWORD idListView, HWND hDlg); virtual ~ListViewControl(); diff --git a/win/rfb_win32/ModuleFileName.h b/win/rfb_win32/ModuleFileName.h index 2264e89d..02a34f1a 100644 --- a/win/rfb_win32/ModuleFileName.h +++ b/win/rfb_win32/ModuleFileName.h @@ -20,13 +20,14 @@ #define __RFB_WIN32_MODULE_FILENAME_H__ #include -#include + +#include namespace rfb { namespace win32 { - struct ModuleFileName : public TCharArray { - ModuleFileName(HMODULE module=0) : TCharArray(MAX_PATH) { + struct ModuleFileName : public CharArray { + ModuleFileName(HMODULE module=0) : CharArray(MAX_PATH) { if (!module) module = GetModuleHandle(0); if (!GetModuleFileName(module, buf, MAX_PATH)) diff --git a/win/rfb_win32/MonitorInfo.cxx b/win/rfb_win32/MonitorInfo.cxx index 2f216e19..c7217c19 100644 --- a/win/rfb_win32/MonitorInfo.cxx +++ b/win/rfb_win32/MonitorInfo.cxx @@ -20,7 +20,6 @@ #include #endif -#include #include #include #include diff --git a/win/rfb_win32/MsgBox.h b/win/rfb_win32/MsgBox.h index 918a909f..30492974 100644 --- a/win/rfb_win32/MsgBox.h +++ b/win/rfb_win32/MsgBox.h @@ -20,7 +20,8 @@ #define __RFB_WIN32_MSGBOX_H__ #include -#include + +#include namespace rfb { namespace win32 { @@ -31,28 +32,28 @@ namespace rfb { // Message box titles are based on the (standard Win32) flags // passed to the MsgBox helper function. - extern TStr AppName; + extern const char* AppName; // Wrapper around Win32 MessageBox() - static int MsgBox(HWND parent, const TCHAR* msg, UINT flags) { - const TCHAR* msgType = 0; + static int MsgBox(HWND parent, const char* msg, UINT flags) { + const char* msgType = 0; UINT tflags = flags & 0x70; if (tflags == MB_ICONHAND) - msgType = _T("Error"); + msgType = "Error"; else if (tflags == MB_ICONQUESTION) - msgType = _T("Question"); + msgType = "Question"; else if (tflags == MB_ICONEXCLAMATION) - msgType = _T("Warning"); + msgType = "Warning"; else if (tflags == MB_ICONASTERISK) - msgType = _T("Information"); + msgType = "Information"; flags |= MB_TOPMOST | MB_SETFOREGROUND; - int len = _tcslen(AppName.buf) + 1; - if (msgType) len += _tcslen(msgType) + 3; - TCharArray title(new TCHAR[len]); - _tcscpy(title.buf, AppName.buf); + int len = strlen(AppName) + 1; + if (msgType) len += strlen(msgType) + 3; + CharArray title(new char[len]); + strcpy(title.buf, AppName); if (msgType) { - _tcscat(title.buf, _T(" : ")); - _tcscat(title.buf, msgType); + strcat(title.buf, " : "); + strcat(title.buf, msgType); } return MessageBox(parent, msg, title.buf, flags); } diff --git a/win/rfb_win32/MsgWindow.cxx b/win/rfb_win32/MsgWindow.cxx index 5aadb434..1a987475 100644 --- a/win/rfb_win32/MsgWindow.cxx +++ b/win/rfb_win32/MsgWindow.cxx @@ -28,7 +28,6 @@ #include #include #include -#include using namespace rfb; using namespace rfb::win32; @@ -80,7 +79,7 @@ MsgWindowClass::MsgWindowClass() : classAtom(0) { wndClass.hCursor = 0; wndClass.hbrBackground = 0; wndClass.lpszMenuName = 0; - wndClass.lpszClassName = _T("rfb::win32::MsgWindowClass"); + wndClass.lpszClassName = "rfb::win32::MsgWindowClass"; classAtom = RegisterClass(&wndClass); if (!classAtom) { throw rdr::SystemException("unable to register MsgWindow window class", GetLastError()); @@ -89,7 +88,7 @@ MsgWindowClass::MsgWindowClass() : classAtom(0) { MsgWindowClass::~MsgWindowClass() { if (classAtom) { - UnregisterClass((const TCHAR*)(intptr_t)classAtom, instance); + UnregisterClass((const char*)(intptr_t)classAtom, instance); } } @@ -99,21 +98,21 @@ static MsgWindowClass baseClass; // -=- MsgWindow // -MsgWindow::MsgWindow(const TCHAR* name_) : name(tstrDup(name_)), handle(0) { - vlog.debug("creating window \"%s\"", (const char*)CStr(name.buf)); - handle = CreateWindow((const TCHAR*)(intptr_t)baseClass.classAtom, +MsgWindow::MsgWindow(const char* name_) : name(strDup(name_)), handle(0) { + vlog.debug("creating window \"%s\"", name.buf); + handle = CreateWindow((const char*)(intptr_t)baseClass.classAtom, name.buf, WS_OVERLAPPED, 0, 0, 10, 10, 0, 0, baseClass.instance, this); if (!handle) { throw rdr::SystemException("unable to create WMNotifier window instance", GetLastError()); } - vlog.debug("created window \"%s\" (%p)", (const char*)CStr(name.buf), handle); + vlog.debug("created window \"%s\" (%p)", name.buf, handle); } MsgWindow::~MsgWindow() { if (handle) DestroyWindow(handle); - vlog.debug("destroyed window \"%s\" (%p)", (const char*)CStr(name.buf), handle); + vlog.debug("destroyed window \"%s\" (%p)", name.buf, handle); } LRESULT diff --git a/win/rfb_win32/MsgWindow.h b/win/rfb_win32/MsgWindow.h index 92b6cf20..22ff1b85 100644 --- a/win/rfb_win32/MsgWindow.h +++ b/win/rfb_win32/MsgWindow.h @@ -25,7 +25,8 @@ #define __RFB_WIN32_MSG_WINDOW_H__ #include -#include + +#include namespace rfb { @@ -33,16 +34,16 @@ namespace rfb { class MsgWindow { public: - MsgWindow(const TCHAR* _name); + MsgWindow(const char* _name); virtual ~MsgWindow(); - const TCHAR* getName() {return name.buf;} + const char* getName() {return name.buf;} HWND getHandle() const {return handle;} virtual LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam); protected: - TCharArray name; + CharArray name; HWND handle; }; diff --git a/win/rfb_win32/RegConfig.cxx b/win/rfb_win32/RegConfig.cxx index e697e66b..3d5af9e3 100644 --- a/win/rfb_win32/RegConfig.cxx +++ b/win/rfb_win32/RegConfig.cxx @@ -46,7 +46,7 @@ RegConfig::~RegConfig() { eventMgr->removeEvent(event); } -bool RegConfig::setKey(const HKEY rootkey, const TCHAR* keyname) { +bool RegConfig::setKey(const HKEY rootkey, const char* keyname) { try { key.createKey(rootkey, keyname); processEvent(event); @@ -61,10 +61,10 @@ void RegConfig::loadRegistryConfig(RegKey& key) { DWORD i = 0; try { while (1) { - TCharArray name(tstrDup(key.getValueName(i++))); + CharArray name(strDup(key.getValueName(i++))); if (!name.buf) break; - TCharArray value(key.getRepresentation(name.buf)); - if (!value.buf || !Configuration::setParam(CStr(name.buf), CStr(value.buf))) + CharArray value(key.getRepresentation(name.buf)); + if (!value.buf || !Configuration::setParam(name.buf, value.buf)) vlog.info("unable to process %s", name.buf); } } catch (rdr::SystemException& e) { @@ -97,7 +97,7 @@ RegConfigThread::~RegConfigThread() { wait(); } -bool RegConfigThread::start(const HKEY rootKey, const TCHAR* keyname) { +bool RegConfigThread::start(const HKEY rootKey, const char* keyname) { if (config.setKey(rootKey, keyname)) { Thread::start(); while (thread_id == (DWORD)-1) diff --git a/win/rfb_win32/RegConfig.h b/win/rfb_win32/RegConfig.h index c092090d..ef8e45bd 100644 --- a/win/rfb_win32/RegConfig.h +++ b/win/rfb_win32/RegConfig.h @@ -41,7 +41,7 @@ namespace rfb { ~RegConfig(); // Specify the registry key to read Configuration items from - bool setKey(const HKEY rootkey, const TCHAR* keyname); + bool setKey(const HKEY rootkey, const char* keyname); // Support for a callback, run in the RegConfig host thread whenever // the registry configuration changes @@ -70,7 +70,7 @@ namespace rfb { ~RegConfigThread(); // Start the thread, reading from the specified key - bool start(const HKEY rootkey, const TCHAR* keyname); + bool start(const HKEY rootkey, const char* keyname); protected: virtual void worker(); EventManager eventMgr; diff --git a/win/rfb_win32/Registry.cxx b/win/rfb_win32/Registry.cxx index 78879c3b..a994fe6f 100644 --- a/win/rfb_win32/Registry.cxx +++ b/win/rfb_win32/Registry.cxx @@ -79,24 +79,24 @@ void RegKey::setHKEY(HKEY k, bool fK) { } -bool RegKey::createKey(const RegKey& root, const TCHAR* name) { +bool RegKey::createKey(const RegKey& root, const char* name) { close(); LONG result = RegCreateKey(root.key, name, &key); if (result != ERROR_SUCCESS) { vlog.error("RegCreateKey(%p, %s): %lx", root.key, name, result); throw rdr::SystemException("RegCreateKeyEx", result); } - vlog.debug("createKey(%p,%s) = %p", root.key, (const char*)CStr(name), key); + vlog.debug("createKey(%p,%s) = %p", root.key, name, key); freeKey = true; return true; } -void RegKey::openKey(const RegKey& root, const TCHAR* name, bool readOnly) { +void RegKey::openKey(const RegKey& root, const char* name, bool readOnly) { close(); LONG result = RegOpenKeyEx(root.key, name, 0, readOnly ? KEY_READ : KEY_ALL_ACCESS, &key); if (result != ERROR_SUCCESS) throw rdr::SystemException("RegOpenKeyEx (open)", result); - vlog.debug("openKey(%p,%s,%s) = %p", root.key, (const char*)CStr(name), + vlog.debug("openKey(%p,%s,%s) = %p", root.key, name, readOnly ? "ro" : "rw", key); freeKey = true; } @@ -118,13 +118,13 @@ void RegKey::close() { } } -void RegKey::deleteKey(const TCHAR* name) const { +void RegKey::deleteKey(const char* name) const { LONG result = RegDeleteKey(key, name); if (result != ERROR_SUCCESS) throw rdr::SystemException("RegDeleteKey", result); } -void RegKey::deleteValue(const TCHAR* name) const { +void RegKey::deleteValue(const char* name) const { LONG result = RegDeleteValue(key, name); if (result != ERROR_SUCCESS) throw rdr::SystemException("RegDeleteValue", result); @@ -140,44 +140,44 @@ void RegKey::awaitChange(bool watchSubTree, DWORD filter, HANDLE event) const { RegKey::operator HKEY() const {return key;} -void RegKey::setExpandString(const TCHAR* valname, const TCHAR* value) const { - LONG result = RegSetValueEx(key, valname, 0, REG_EXPAND_SZ, (const BYTE*)value, (_tcslen(value)+1)*sizeof(TCHAR)); +void RegKey::setExpandString(const char* valname, const char* value) const { + LONG result = RegSetValueEx(key, valname, 0, REG_EXPAND_SZ, (const BYTE*)value, (strlen(value)+1)*sizeof(char)); if (result != ERROR_SUCCESS) throw rdr::SystemException("setExpandString", result); } -void RegKey::setString(const TCHAR* valname, const TCHAR* value) const { - LONG result = RegSetValueEx(key, valname, 0, REG_SZ, (const BYTE*)value, (_tcslen(value)+1)*sizeof(TCHAR)); +void RegKey::setString(const char* valname, const char* value) const { + LONG result = RegSetValueEx(key, valname, 0, REG_SZ, (const BYTE*)value, (strlen(value)+1)*sizeof(char)); if (result != ERROR_SUCCESS) throw rdr::SystemException("setString", result); } -void RegKey::setBinary(const TCHAR* valname, const void* value, size_t length) const { +void RegKey::setBinary(const char* valname, const void* value, size_t length) const { LONG result = RegSetValueEx(key, valname, 0, REG_BINARY, (const BYTE*)value, length); if (result != ERROR_SUCCESS) throw rdr::SystemException("setBinary", result); } -void RegKey::setInt(const TCHAR* valname, int value) const { +void RegKey::setInt(const char* valname, int value) const { LONG result = RegSetValueEx(key, valname, 0, REG_DWORD, (const BYTE*)&value, sizeof(value)); if (result != ERROR_SUCCESS) throw rdr::SystemException("setInt", result); } -void RegKey::setBool(const TCHAR* valname, bool value) const { +void RegKey::setBool(const char* valname, bool value) const { setInt(valname, value ? 1 : 0); } -TCHAR* RegKey::getString(const TCHAR* valname) const {return getRepresentation(valname);} -TCHAR* RegKey::getString(const TCHAR* valname, const TCHAR* def) const { +char* RegKey::getString(const char* valname) const {return getRepresentation(valname);} +char* RegKey::getString(const char* valname, const char* def) const { try { return getString(valname); } catch(rdr::Exception&) { - return tstrDup(def); + return strDup(def); } } -std::vector RegKey::getBinary(const TCHAR* valname) const { - TCharArray hex(getRepresentation(valname)); - return hexToBin(CStr(hex.buf), strlen(CStr(hex.buf))); +std::vector RegKey::getBinary(const char* valname) const { + CharArray hex(getRepresentation(valname)); + return hexToBin(hex.buf, strlen(hex.buf)); } -std::vector RegKey::getBinary(const TCHAR* valname, const uint8_t* def, size_t deflen) const { +std::vector RegKey::getBinary(const char* valname, const uint8_t* def, size_t deflen) const { try { return getBinary(valname); } catch(rdr::Exception&) { @@ -187,11 +187,11 @@ std::vector RegKey::getBinary(const TCHAR* valname, const uint8_t* def, } } -int RegKey::getInt(const TCHAR* valname) const { - TCharArray tmp(getRepresentation(valname)); - return _ttoi(tmp.buf); +int RegKey::getInt(const char* valname) const { + CharArray tmp(getRepresentation(valname)); + return atoi(tmp.buf); } -int RegKey::getInt(const TCHAR* valname, int def) const { +int RegKey::getInt(const char* valname, int def) const { try { return getInt(valname); } catch(rdr::Exception&) { @@ -199,24 +199,24 @@ int RegKey::getInt(const TCHAR* valname, int def) const { } } -bool RegKey::getBool(const TCHAR* valname) const { +bool RegKey::getBool(const char* valname) const { return getInt(valname) > 0; } -bool RegKey::getBool(const TCHAR* valname, bool def) const { +bool RegKey::getBool(const char* valname, bool def) const { return getInt(valname, def ? 1 : 0) > 0; } -static inline TCHAR* terminateData(char* data, int length) +static inline char* terminateData(char* data, int length) { // We must terminate the string, just to be sure. Stupid Win32... - int len = length/sizeof(TCHAR); - TCharArray str(len+1); + int len = length/sizeof(char); + CharArray str(len+1); memcpy(str.buf, data, length); str.buf[len] = 0; return str.takeBuf(); } -TCHAR* RegKey::getRepresentation(const TCHAR* valname) const { +char* RegKey::getRepresentation(const char* valname) const { DWORD type, length; LONG result = RegQueryValueEx(key, valname, 0, &type, 0, &length); if (result != ERROR_SUCCESS) @@ -229,35 +229,35 @@ TCHAR* RegKey::getRepresentation(const TCHAR* valname) const { switch (type) { case REG_BINARY: { - TCharArray hex(binToHex((const uint8_t*)data.buf, length)); + CharArray hex(binToHex((const uint8_t*)data.buf, length)); return hex.takeBuf(); } case REG_SZ: if (length) { return terminateData(data.buf, length); } else { - return tstrDup(_T("")); + return strDup(""); } case REG_DWORD: { - TCharArray tmp(16); - _stprintf(tmp.buf, _T("%lu"), *((DWORD*)data.buf)); + CharArray tmp(16); + sprintf(tmp.buf, "%lu", *((DWORD*)data.buf)); return tmp.takeBuf(); } case REG_EXPAND_SZ: { if (length) { - TCharArray str(terminateData(data.buf, length)); + CharArray str(terminateData(data.buf, length)); DWORD required = ExpandEnvironmentStrings(str.buf, 0, 0); if (required==0) throw rdr::SystemException("ExpandEnvironmentStrings", GetLastError()); - TCharArray result(required); + CharArray result(required); length = ExpandEnvironmentStrings(str.buf, result.buf, required); if (required getBinary(const TCHAR* valname) const; - std::vector getBinary(const TCHAR* valname, const uint8_t* def, size_t deflength) const; + std::vector getBinary(const char* valname) const; + std::vector getBinary(const char* valname, const uint8_t* def, size_t deflength) const; - int getInt(const TCHAR* valname) const; - int getInt(const TCHAR* valname, int def) const; + int getInt(const char* valname) const; + int getInt(const char* valname, int def) const; - bool getBool(const TCHAR* valname) const; - bool getBool(const TCHAR* valname, bool def) const; + bool getBool(const char* valname) const; + bool getBool(const char* valname, bool def) const; - TCHAR* getRepresentation(const TCHAR* valname) const; + char* getRepresentation(const char* valname) const; - bool isValue(const TCHAR* valname) const; + bool isValue(const char* valname) const; // Get the name of value/key number "i" // If there are fewer than "i" values then return 0 // NAME IS OWNED BY RegKey OBJECT! - const TCHAR* getValueName(int i); - const TCHAR* getKeyName(int i); + const char* getValueName(int i); + const char* getKeyName(int i); operator HKEY() const; protected: HKEY key; bool freeKey; - TCharArray valueName; + CharArray valueName; DWORD valueNameBufLen; }; diff --git a/win/rfb_win32/SDisplay.cxx b/win/rfb_win32/SDisplay.cxx index c381c412..02ef548d 100644 --- a/win/rfb_win32/SDisplay.cxx +++ b/win/rfb_win32/SDisplay.cxx @@ -448,9 +448,9 @@ SDisplay::recreatePixelBuffer(bool force) { // Opening the whole display with CreateDC doesn't work on multi-monitor // systems for some reason. DeviceContext* new_device = 0; - TCharArray deviceName(displayDevice.getData()); + CharArray deviceName(displayDevice.getData()); if (deviceName.buf[0]) { - vlog.info("Attaching to device %s", (const char*)CStr(deviceName.buf)); + vlog.info("Attaching to device %s", deviceName.buf); new_device = new DeviceDC(deviceName.buf); } if (!new_device) { @@ -461,7 +461,7 @@ SDisplay::recreatePixelBuffer(bool force) { // Get the coordinates of the specified dispay device Rect newScreenRect; if (deviceName.buf[0]) { - MonitorInfo info(CStr(deviceName.buf)); + MonitorInfo info(deviceName.buf); newScreenRect = Rect(info.rcMonitor.left, info.rcMonitor.top, info.rcMonitor.right, info.rcMonitor.bottom); } else { diff --git a/win/rfb_win32/SDisplayCorePolling.cxx b/win/rfb_win32/SDisplayCorePolling.cxx index f47560b4..ae033511 100644 --- a/win/rfb_win32/SDisplayCorePolling.cxx +++ b/win/rfb_win32/SDisplayCorePolling.cxx @@ -36,7 +36,7 @@ const int POLLING_SEGMENTS = 16; const unsigned int SDisplayCorePolling::pollTimerId = 1; SDisplayCorePolling::SDisplayCorePolling(SDisplay* d, UpdateTracker* ut, int pollInterval_) - : MsgWindow(_T("rfb::win32::SDisplayCorePolling")), + : MsgWindow("rfb::win32::SDisplayCorePolling"), pollTimer(getHandle(), pollTimerId), pollNextStrip(false), display(d), updateTracker(ut) { pollInterval = __rfbmax(10, (pollInterval_ / POLLING_SEGMENTS)); copyrect.setUpdateTracker(ut); diff --git a/win/rfb_win32/SInput.cxx b/win/rfb_win32/SInput.cxx index efc17fdb..b76060a8 100644 --- a/win/rfb_win32/SInput.cxx +++ b/win/rfb_win32/SInput.cxx @@ -30,7 +30,6 @@ #define XK_CURRENCY #include -#include #include #include #include diff --git a/win/rfb_win32/Security.cxx b/win/rfb_win32/Security.cxx index 7280d6d1..8dfc5b8d 100644 --- a/win/rfb_win32/Security.cxx +++ b/win/rfb_win32/Security.cxx @@ -35,18 +35,18 @@ using namespace rfb::win32; static LogWriter vlog("SecurityWin32"); -Trustee::Trustee(const TCHAR* name, +Trustee::Trustee(const char* name, TRUSTEE_FORM form, TRUSTEE_TYPE type) { pMultipleTrustee = 0; MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE; TrusteeForm = form; TrusteeType = type; - ptstrName = (TCHAR*)name; + ptstrName = (char*)name; } -ExplicitAccess::ExplicitAccess(const TCHAR* name, +ExplicitAccess::ExplicitAccess(const char* name, TRUSTEE_FORM type, DWORD perms, ACCESS_MODE mode, @@ -75,7 +75,7 @@ void AccessEntries::allocMinEntries(int count) { } } -void AccessEntries::addEntry(const TCHAR* trusteeName, +void AccessEntries::addEntry(const char* trusteeName, DWORD permissions, ACCESS_MODE mode) { allocMinEntries(entry_count+1); @@ -89,7 +89,7 @@ void AccessEntries::addEntry(const PSID sid, ACCESS_MODE mode) { allocMinEntries(entry_count+1); ZeroMemory(&entries[entry_count], sizeof(EXPLICIT_ACCESS)); - entries[entry_count] = ExplicitAccess((TCHAR*)sid, TRUSTEE_IS_SID, permissions, mode); + entries[entry_count] = ExplicitAccess((char*)sid, TRUSTEE_IS_SID, permissions, mode); entry_count++; } @@ -111,7 +111,7 @@ void Sid::setSID(const PSID sid) { throw rdr::SystemException("CopySid failed", GetLastError()); } -void Sid::getUserNameAndDomain(TCHAR** name, TCHAR** domain) { +void Sid::getUserNameAndDomain(char** name, char** domain) { DWORD nameLen = 0; DWORD domainLen = 0; SID_NAME_USE use; @@ -119,8 +119,8 @@ void Sid::getUserNameAndDomain(TCHAR** name, TCHAR** domain) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) throw rdr::SystemException("Unable to determine SID name lengths", GetLastError()); vlog.info("nameLen=%lu, domainLen=%lu, use=%d", nameLen, domainLen, use); - *name = new TCHAR[nameLen]; - *domain = new TCHAR[domainLen]; + *name = new char[nameLen]; + *domain = new char[domainLen]; if (!LookupAccountSid(0, (PSID)*this, *name, &nameLen, *domain, &domainLen, &use)) throw rdr::SystemException("Unable to lookup account SID", GetLastError()); } diff --git a/win/rfb_win32/Security.h b/win/rfb_win32/Security.h index 85317fae..a24c359f 100644 --- a/win/rfb_win32/Security.h +++ b/win/rfb_win32/Security.h @@ -27,7 +27,6 @@ #include #include #include -#include #include namespace rfb { @@ -35,13 +34,13 @@ namespace rfb { namespace win32 { struct Trustee : public TRUSTEE { - Trustee(const TCHAR* name, + Trustee(const char* name, TRUSTEE_FORM form=TRUSTEE_IS_NAME, TRUSTEE_TYPE type=TRUSTEE_IS_UNKNOWN); }; struct ExplicitAccess : public EXPLICIT_ACCESS { - ExplicitAccess(const TCHAR* name, + ExplicitAccess(const char* name, TRUSTEE_FORM type, DWORD perms, ACCESS_MODE mode, @@ -53,7 +52,7 @@ namespace rfb { AccessEntries(); ~AccessEntries(); void allocMinEntries(int count); - void addEntry(const TCHAR* trusteeName, + void addEntry(const char* trusteeName, DWORD permissions, ACCESS_MODE mode); void addEntry(const PSID sid, @@ -73,7 +72,7 @@ namespace rfb { void setSID(const PSID sid); - void getUserNameAndDomain(TCHAR** name, TCHAR** domain); + void getUserNameAndDomain(char** name, char** domain); struct Administrators; struct SYSTEM; diff --git a/win/rfb_win32/Service.cxx b/win/rfb_win32/Service.cxx index 353ff92b..40d4ae87 100644 --- a/win/rfb_win32/Service.cxx +++ b/win/rfb_win32/Service.cxx @@ -90,7 +90,7 @@ VOID WINAPI serviceProc(DWORD dwArgc, LPTSTR* lpszArgv) { // -=- Service -Service::Service(const TCHAR* name_) : name(name_) { +Service::Service(const char* name_) : name(name_) { vlog.debug("Service"); status_handle = 0; status.dwControlsAccepted = SERVICE_CONTROL_INTERROGATE | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_STOP; @@ -105,7 +105,7 @@ Service::Service(const TCHAR* name_) : name(name_) { void Service::start() { SERVICE_TABLE_ENTRY entry[2]; - entry[0].lpServiceName = (TCHAR*)name; + entry[0].lpServiceName = (char*)name; entry[0].lpServiceProc = serviceProc; entry[1].lpServiceName = NULL; entry[1].lpServiceProc = NULL; @@ -263,7 +263,7 @@ rfb::win32::emulateCtrlAltDel() { class Logger_EventLog : public Logger { public: - Logger_EventLog(const TCHAR* srcname) : Logger("EventLog") { + Logger_EventLog(const char* srcname) : Logger("EventLog") { eventlog = RegisterEventSource(NULL, srcname); if (!eventlog) printf("Unable to open event log:%ld\n", GetLastError()); @@ -275,8 +275,7 @@ public: virtual void write(int level, const char *logname, const char *message) { if (!eventlog) return; - TStr log(logname), msg(message); - const TCHAR* strings[] = {log, msg}; + const char* strings[] = {logname, message}; WORD type = EVENTLOG_INFORMATION_TYPE; if (level == 0) type = EVENTLOG_ERROR_TYPE; if (!ReportEvent(eventlog, type, 0, VNC4LogMessage, NULL, 2, 0, strings, NULL)) { @@ -291,7 +290,7 @@ protected: static Logger_EventLog* logger = 0; -bool rfb::win32::initEventLogLogger(const TCHAR* srcname) { +bool rfb::win32::initEventLogLogger(const char* srcname) { if (logger) return false; logger = new Logger_EventLog(srcname); @@ -302,32 +301,32 @@ bool rfb::win32::initEventLogLogger(const TCHAR* srcname) { // -=- Registering and unregistering the service -bool rfb::win32::registerService(const TCHAR* name, - const TCHAR* display, - const TCHAR* desc, +bool rfb::win32::registerService(const char* name, + const char* display, + const char* desc, int argc, char** argv) { // - Initialise the default service parameters - const TCHAR* defaultcmdline; - defaultcmdline = _T("-service"); + const char* defaultcmdline; + defaultcmdline = "-service"; // - Get the full pathname of our executable ModuleFileName buffer; // - Calculate the command-line length - int cmdline_len = _tcslen(buffer.buf) + 4; + int cmdline_len = strlen(buffer.buf) + 4; int i; for (i=0; i0; i--) { - if (buffer.buf[i] == _T('\\')) { + for (i=strlen(buffer.buf); i>0; i--) { + if (buffer.buf[i] == '\\') { buffer.buf[i+1] = 0; break; } } - const TCHAR* dllFilename = _T("logmessages.dll"); - TCharArray dllPath(_tcslen(buffer.buf) + _tcslen(dllFilename) + 1); - _tcscpy(dllPath.buf, buffer.buf); - _tcscat(dllPath.buf, dllFilename); + const char* dllFilename = "logmessages.dll"; + CharArray dllPath(strlen(buffer.buf) + strlen(dllFilename) + 1); + strcpy(dllPath.buf, buffer.buf); + strcat(dllPath.buf, dllFilename); - hk.setExpandString(_T("EventMessageFile"), dllPath.buf); - hk.setInt(_T("TypesSupported"), EVENTLOG_ERROR_TYPE | EVENTLOG_INFORMATION_TYPE); + hk.setExpandString("EventMessageFile", dllPath.buf); + hk.setInt("TypesSupported", EVENTLOG_ERROR_TYPE | EVENTLOG_INFORMATION_TYPE); Sleep(500); return true; } -bool rfb::win32::unregisterService(const TCHAR* name) { +bool rfb::win32::unregisterService(const char* name) { // - Open the SCM ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE); if (!scm) @@ -391,7 +390,7 @@ bool rfb::win32::unregisterService(const TCHAR* name) { // - Register the event log source RegKey hk; - hk.openKey(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application")); + hk.openKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application"); hk.deleteKey(name); Sleep(500); @@ -402,7 +401,7 @@ bool rfb::win32::unregisterService(const TCHAR* name) { // -=- Starting and stopping the service -bool rfb::win32::startService(const TCHAR* name) { +bool rfb::win32::startService(const char* name) { // - Open the SCM ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); @@ -423,7 +422,7 @@ bool rfb::win32::startService(const TCHAR* name) { return true; } -bool rfb::win32::stopService(const TCHAR* name) { +bool rfb::win32::stopService(const char* name) { // - Open the SCM ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); if (!scm) @@ -444,7 +443,7 @@ bool rfb::win32::stopService(const TCHAR* name) { return true; } -DWORD rfb::win32::getServiceState(const TCHAR* name) { +DWORD rfb::win32::getServiceState(const char* name) { // - Open the SCM ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); if (!scm) diff --git a/win/rfb_win32/Service.h b/win/rfb_win32/Service.h index 691ad95d..6fcd6f25 100644 --- a/win/rfb_win32/Service.h +++ b/win/rfb_win32/Service.h @@ -40,10 +40,10 @@ namespace rfb { class Service { public: - Service(const TCHAR* name_); + Service(const char* name_); virtual ~Service(); - const TCHAR* getName() {return name;} + const char* getName() {return name;} SERVICE_STATUS& getStatus() {return status;} void setStatus(DWORD status); @@ -53,7 +53,7 @@ namespace rfb { void start(); // - Service main procedure - override to implement a service - virtual DWORD serviceMain(int argc, TCHAR* argv[]) = 0; + virtual DWORD serviceMain(int argc, char* argv[]) = 0; // - Service control notifications @@ -70,7 +70,7 @@ namespace rfb { SERVICE_STATUS_HANDLE status_handle; SERVICE_STATUS status; protected: - const TCHAR* name; + const char* name; }; class ServiceHandle { @@ -92,22 +92,22 @@ namespace rfb { bool emulateCtrlAltDel(); // -=- Routines to initialise the Event Log target Logger - bool initEventLogLogger(const TCHAR* srcname); + bool initEventLogLogger(const char* srcname); // -=- Routines to register/unregister the service // These routines also take care of registering the required // event source information, etc. - // *** should really accept TCHAR argv + // *** should really accept char argv - bool registerService(const TCHAR* name, const TCHAR* display, - const TCHAR* desc, int argc, char** argv); - bool unregisterService(const TCHAR* name); + bool registerService(const char* name, const char* display, + const char* desc, int argc, char** argv); + bool unregisterService(const char* name); - bool startService(const TCHAR* name); - bool stopService(const TCHAR* name); + bool startService(const char* name); + bool stopService(const char* name); // -=- Get the state of the named service (one of the NT service state values) - DWORD getServiceState(const TCHAR* name); + DWORD getServiceState(const char* name); // -=- Convert a supplied service state value to a printable string e.g. Running, Stopped... // The caller must delete the returned string buffer diff --git a/win/rfb_win32/TCharArray.cxx b/win/rfb_win32/TCharArray.cxx deleted file mode 100644 index a36f23b1..00000000 --- a/win/rfb_win32/TCharArray.cxx +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * - * This is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -namespace rfb { - - WCHAR* wstrDup(const WCHAR* s) { - if (!s) return 0; - WCHAR* t = new WCHAR[wcslen(s)+1]; - memcpy(t, s, sizeof(WCHAR)*(wcslen(s)+1)); - return t; - } - void wstrFree(WCHAR* s) {delete [] s;} - - char* strDup(const WCHAR* s) { - if (!s) return 0; - int len = wcslen(s); - char* t = new char[len+1]; - t[WideCharToMultiByte(CP_ACP, 0, s, len, t, len, 0, 0)] = 0; - return t; - } - - WCHAR* wstrDup(const char* s) { - if (!s) return 0; - int len = strlen(s); - WCHAR* t = new WCHAR[len+1]; - t[MultiByteToWideChar(CP_ACP, 0, s, len, t, len)] = 0; - return t; - } - - - bool wstrSplit(const WCHAR* src, const WCHAR limiter, WCHAR** out1, WCHAR** out2, bool fromEnd) { - WCharArray out1old, out2old; - if (out1) out1old.buf = *out1; - if (out2) out2old.buf = *out2; - int len = wcslen(src); - int i=0, increment=1, limit=len; - if (fromEnd) { - i=len-1; increment = -1; limit = -1; - } - while (i!=limit) { - if (src[i] == limiter) { - if (out1) { - *out1 = new WCHAR[i+1]; - if (i) memcpy(*out1, src, sizeof(WCHAR)*i); - (*out1)[i] = 0; - } - if (out2) { - *out2 = new WCHAR[len-i]; - if (len-i-1) memcpy(*out2, &src[i+1], sizeof(WCHAR)*(len-i-1)); - (*out2)[len-i-1] = 0; - } - return true; - } - i+=increment; - } - if (out1) *out1 = wstrDup(src); - if (out2) *out2 = 0; - return false; - } - - bool wstrContains(const WCHAR* src, WCHAR c) { - int l=wcslen(src); - for (int i=0; i -#include -#include -#include - -namespace rfb { - - // -=- String duplication and cleanup functions. - // These routines also handle conversion between WCHAR* and char* - - char* strDup(const WCHAR* s); - WCHAR* wstrDup(const WCHAR* s); - WCHAR* wstrDup(const char* s); - void wstrFree(WCHAR* s); - - bool wstrSplit(const WCHAR* src, const WCHAR limiter, WCHAR** out1, WCHAR** out2, bool fromEnd=false); - bool wstrContains(const WCHAR* src, WCHAR c); - - // -=- Temporary format conversion classes - // CStr accepts WCHAR* or char* and behaves like a char* - // WStr accepts WCHAR* or char* and behaves like a WCHAR* - - struct WStr { - WStr(const char* s) : buf(wstrDup(s)), free_(true) {} - WStr(const WCHAR* s) : buf(s), free_(false) {} - ~WStr() {if (free_) wstrFree((WCHAR*)buf);} - operator const WCHAR*() {return buf;} - const WCHAR* buf; - bool free_; - }; - - struct CStr { - CStr(const char* s) : buf(s), free_(false) {} - CStr(const WCHAR* s) : buf(strDup(s)), free_(true) {} - ~CStr() {if (free_) strFree((char*)buf);} - operator const char*() {return buf;} - const char* buf; - bool free_; - }; - - // -=- Class to handle cleanup of arrays of native Win32 characters - class WCharArray { - public: - WCharArray() : buf(0) {} - WCharArray(char* str) : buf(wstrDup(str)) {strFree(str);} // note: assumes ownership - WCharArray(WCHAR* str) : buf(str) {} // note: assumes ownership - WCharArray(int len) { - buf = new WCHAR[len]; - } - ~WCharArray() { - delete [] buf; - } - // Get the buffer pointer & clear it (i.e. caller takes ownership) - WCHAR* takeBuf() {WCHAR* tmp = buf; buf = 0; return tmp;} - void replaceBuf(WCHAR* str) {delete [] buf; buf = str;} - WCHAR* buf; - }; - - // -=- Wide-character-based password-buffer handler. Zeroes the password - // buffer when deleted or replaced. - class WPlainPasswd : public WCharArray { - public: - WPlainPasswd() {} - WPlainPasswd(WCHAR* str) : WCharArray(str) {} - ~WPlainPasswd() {replaceBuf(0);} - void replaceBuf(WCHAR* str) { - if (buf) - memset(buf, 0, sizeof(WCHAR)*wcslen(buf)); - WCharArray::replaceBuf(str); - } - }; - -#ifdef _UNICODE -#define tstrDup wstrDup -#define tstrFree wstrFree -#define tstrSplit wstrSplit -#define tstrContains wstrContains - typedef WCharArray TCharArray; - typedef WStr TStr; - typedef WPlainPasswd TPlainPasswd; -#else -#define tstrDup strDup -#define tstrFree strFree -#define tstrSplit strSplit -#define tstrContains strContains - typedef CharArray TCharArray; - typedef CStr TStr; - typedef PlainPasswd TPlainPasswd; -#endif - -}; - -#endif diff --git a/win/rfb_win32/TrayIcon.h b/win/rfb_win32/TrayIcon.h index dc5102a9..c99203d1 100644 --- a/win/rfb_win32/TrayIcon.h +++ b/win/rfb_win32/TrayIcon.h @@ -34,7 +34,7 @@ namespace rfb { class TrayIcon : public MsgWindow { public: - TrayIcon() : MsgWindow(_T("VNCTray")) { + TrayIcon() : MsgWindow("VNCTray") { #ifdef NOTIFYICONDATA_V1_SIZE nid.cbSize = NOTIFYICONDATA_V1_SIZE; #else @@ -59,12 +59,12 @@ namespace rfb { return refresh(); } } - bool setToolTip(const TCHAR* text) { + bool setToolTip(const char* text) { if (text == 0) { nid.uFlags &= ~NIF_TIP; } else { - const int tipLen = sizeof(nid.szTip)/sizeof(TCHAR); - _tcsncpy(nid.szTip, text, tipLen); + const int tipLen = sizeof(nid.szTip)/sizeof(char); + strncpy(nid.szTip, text, tipLen); nid.szTip[tipLen-1] = 0; nid.uFlags |= NIF_TIP; } diff --git a/win/rfb_win32/TsSessions.cxx b/win/rfb_win32/TsSessions.cxx index 9b1632f5..ad30abf4 100644 --- a/win/rfb_win32/TsSessions.cxx +++ b/win/rfb_win32/TsSessions.cxx @@ -23,7 +23,6 @@ #include #include #include -#include #include static rfb::LogWriter vlog("TsSessions"); @@ -57,7 +56,7 @@ namespace win32 { // Try to reconnect our session to the console ConsoleSessionId console; vlog.info("Console session is %lu", console.id); - if (!WTSConnectSession(sessionId, console.id, (PTSTR)_T(""), 0)) + if (!WTSConnectSession(sessionId, console.id, (PTSTR)"", 0)) throw rdr::SystemException("Unable to connect session to Console", GetLastError()); // Lock the newly connected session, for security diff --git a/win/rfb_win32/WMHooks.cxx b/win/rfb_win32/WMHooks.cxx index 70844563..017972ba 100644 --- a/win/rfb_win32/WMHooks.cxx +++ b/win/rfb_win32/WMHooks.cxx @@ -211,7 +211,7 @@ WMHooksThread::worker() { // actually complete them before we notify the hook callbacks & they go off // capturing screen state. const int updateDelayMs = 40; - MsgWindow updateDelayWnd(_T("WMHooks::updateDelay")); + MsgWindow updateDelayWnd("WMHooks::updateDelay"); IntervalTimer updateDelayTimer(updateDelayWnd.getHandle(), 1); Region updates[2]; int activeRgn = 0; diff --git a/win/rfb_win32/WMNotifier.cxx b/win/rfb_win32/WMNotifier.cxx index e05661f7..81b4fa51 100644 --- a/win/rfb_win32/WMNotifier.cxx +++ b/win/rfb_win32/WMNotifier.cxx @@ -34,7 +34,7 @@ using namespace rfb::win32; static LogWriter vlog("WMMonitor"); -WMMonitor::WMMonitor() : MsgWindow(_T("WMMonitor")), notifier(0) { +WMMonitor::WMMonitor() : MsgWindow("WMMonitor"), notifier(0) { } WMMonitor::~WMMonitor() { diff --git a/win/rfb_win32/WMPoller.cxx b/win/rfb_win32/WMPoller.cxx index 38b2ad42..1e29d0c6 100644 --- a/win/rfb_win32/WMPoller.cxx +++ b/win/rfb_win32/WMPoller.cxx @@ -27,8 +27,6 @@ #include #include -#include - using namespace rfb; using namespace rfb::win32; @@ -57,11 +55,11 @@ rfb::win32::WMPoller::setUpdateTracker(UpdateTracker* ut_) { bool rfb::win32::WMPoller::checkPollWindow(HWND w) { - TCHAR buffer[128]; + char buffer[128]; if (!GetClassName(w, buffer, 128)) throw rdr::SystemException("unable to get window class:%u", GetLastError()); - if ((_tcscmp(buffer, _T("tty")) != 0) && - (_tcscmp(buffer, _T("ConsoleWindowClass")) != 0)) { + if ((strcmp(buffer, "tty") != 0) && + (strcmp(buffer, "ConsoleWindowClass") != 0)) { return false; } return true; diff --git a/win/rfb_win32/Win32Util.cxx b/win/rfb_win32/Win32Util.cxx index 2fbce0dd..53443007 100644 --- a/win/rfb_win32/Win32Util.cxx +++ b/win/rfb_win32/Win32Util.cxx @@ -34,7 +34,7 @@ namespace rfb { namespace win32 { -FileVersionInfo::FileVersionInfo(const TCHAR* filename) { +FileVersionInfo::FileVersionInfo(const char* filename) { // Get executable name ModuleFileName exeName; if (!filename) @@ -50,29 +50,29 @@ FileVersionInfo::FileVersionInfo(const TCHAR* filename) { // Get version info size DWORD handle; - int size = GetFileVersionInfoSize((TCHAR*)filename, &handle); + int size = GetFileVersionInfoSize((char*)filename, &handle); if (!size) throw rdr::SystemException("GetVersionInfoSize failed", GetLastError()); // Get version info - buf = new TCHAR[size]; - if (!GetFileVersionInfo((TCHAR*)filename, handle, size, buf)) + buf = new char[size]; + if (!GetFileVersionInfo((char*)filename, handle, size, buf)) throw rdr::SystemException("GetVersionInfo failed", GetLastError()); } -const TCHAR* FileVersionInfo::getVerString(const TCHAR* name, DWORD langId) { +const char* FileVersionInfo::getVerString(const char* name, DWORD langId) { uint8_t langIdBuf[sizeof(langId)]; for (int i=sizeof(langIdBuf)-1; i>=0; i--) { langIdBuf[i] = (langId & 0xff); langId = langId >> 8; } - TCharArray langIdStr(binToHex(langIdBuf, sizeof(langId))); - TCharArray infoName(_tcslen(_T("StringFileInfo")) + 4 + _tcslen(name) + _tcslen(langIdStr.buf)); - _stprintf(infoName.buf, _T("\\StringFileInfo\\%s\\%s"), langIdStr.buf, name); + CharArray langIdStr(binToHex(langIdBuf, sizeof(langId))); + CharArray infoName(strlen("StringFileInfo") + 4 + strlen(name) + strlen(langIdStr.buf)); + sprintf(infoName.buf, "\\StringFileInfo\\%s\\%s", langIdStr.buf, name); // Locate the required version string within the version info - TCHAR* buffer = 0; + char* buffer = 0; UINT length = 0; if (!VerQueryValue(buf, infoName.buf, (void**)&buffer, &length)) { printf("unable to find %s version string", infoName.buf); @@ -82,8 +82,8 @@ const TCHAR* FileVersionInfo::getVerString(const TCHAR* name, DWORD langId) { } -bool splitPath(const TCHAR* path, TCHAR** dir, TCHAR** file) { - return tstrSplit(path, '\\', dir, file, true); +bool splitPath(const char* path, char** dir, char** file) { + return strSplit(path, '\\', dir, file, true); } diff --git a/win/rfb_win32/Win32Util.h b/win/rfb_win32/Win32Util.h index 8cc1a2b9..beb22ec7 100644 --- a/win/rfb_win32/Win32Util.h +++ b/win/rfb_win32/Win32Util.h @@ -25,18 +25,18 @@ #ifndef __RFB_WIN32_GDIUTIL_H__ #define __RFB_WIN32_GDIUTIL_H__ -#include +#include namespace rfb { namespace win32 { - struct FileVersionInfo : public TCharArray { - FileVersionInfo(const TCHAR* filename=0); - const TCHAR* getVerString(const TCHAR* name, DWORD langId = 0x080904b0); + struct FileVersionInfo : public CharArray { + FileVersionInfo(const char* filename=0); + const char* getVerString(const char* name, DWORD langId = 0x080904b0); }; - bool splitPath(const TCHAR* path, TCHAR** dir, TCHAR** file); + bool splitPath(const char* path, char** dir, char** file); // Center the window to a rectangle, or to a parent window. // Optionally, resize the window to lay within the rect or parent window diff --git a/win/vncconfig/Authentication.h b/win/vncconfig/Authentication.h index 1e4ea4ac..6789a4f2 100644 --- a/win/vncconfig/Authentication.h +++ b/win/vncconfig/Authentication.h @@ -65,13 +65,13 @@ namespace rfb { PasswordDialog passwdDlg(regKey, registryInsecure); passwdDlg.showDialog(handle); } else if (id == IDC_LOAD_CERT) { - const TCHAR* title = _T("X509Cert"); - const TCHAR* filter = - _T("X.509 Certificates (*.crt;*.cer;*.pem)\0*.crt;*.cer;*.pem\0All\0*.*\0"); + const char* title = "X509Cert"; + const char* filter = + "X.509 Certificates (*.crt;*.cer;*.pem)\0*.crt;*.cer;*.pem\0All\0*.*\0"; showFileChooser(regKey, title, filter, handle); } else if (id == IDC_LOAD_CERTKEY) { - const TCHAR* title = _T("X509Key"); - const TCHAR* filter = _T("X.509 Keys (*.key;*.pem)\0*.key;*.pem\0All\0*.*\0"); + const char* title = "X509Key"; + const char* filter = "X.509 Keys (*.key;*.pem)\0*.key;*.pem\0All\0*.*\0"; showFileChooser(regKey, title, filter, handle); } else if (id == IDC_QUERY_LOGGED_ON) { enableItem(IDC_QUERY_LOGGED_ON, enableQueryOnlyIfLoggedOn()); @@ -85,10 +85,10 @@ namespace rfb { if (isItemChecked(IDC_AUTH_VNC)) verifyVncPassword(regKey); else if (haveVncPassword() && - MsgBox(0, _T("The VNC authentication method is disabled, but a password is still stored for it.\n") - _T("Do you want to remove the VNC authentication password from the registry?"), + MsgBox(0, "The VNC authentication method is disabled, but a password is still stored for it.\n" + "Do you want to remove the VNC authentication password from the registry?", MB_ICONWARNING | MB_YESNO) == IDYES) { - regKey.setBinary(_T("Password"), 0, 0); + regKey.setBinary("Password", 0, 0); } #ifdef HAVE_GNUTLS @@ -98,9 +98,9 @@ namespace rfb { } #endif - regKey.setString(_T("SecurityTypes"), security->ToString()); - regKey.setBool(_T("QueryConnect"), isItemChecked(IDC_QUERY_CONNECT)); - regKey.setBool(_T("QueryOnlyIfLoggedOn"), isItemChecked(IDC_QUERY_LOGGED_ON)); + regKey.setString("SecurityTypes", security->ToString()); + regKey.setBool("QueryConnect", isItemChecked(IDC_QUERY_CONNECT)); + regKey.setBool("QueryOnlyIfLoggedOn", isItemChecked(IDC_QUERY_LOGGED_ON)); return true; } @@ -120,8 +120,8 @@ namespace rfb { static void verifyVncPassword(const RegKey& regKey) { if (!haveVncPassword()) { - MsgBox(0, _T("The VNC authentication method is enabled, but no password is specified.\n") - _T("The password dialog will now be shown."), MB_ICONINFORMATION | MB_OK); + MsgBox(0, "The VNC authentication method is enabled, but no password is specified.\n" + "The password dialog will now be shown.", MB_ICONINFORMATION | MB_OK); PasswordDialog passwd(regKey, registryInsecure); passwd.showDialog(); } diff --git a/win/vncconfig/Connections.h b/win/vncconfig/Connections.h index c3d67374..ff03897a 100644 --- a/win/vncconfig/Connections.h +++ b/win/vncconfig/Connections.h @@ -41,17 +41,17 @@ namespace rfb { class ConnHostDialog : public Dialog { public: ConnHostDialog() : Dialog(GetModuleHandle(0)) {} - bool showDialog(const TCHAR* pat) { - pattern.replaceBuf(tstrDup(pat)); + bool showDialog(const char* pat) { + pattern.replaceBuf(strDup(pat)); return Dialog::showDialog(MAKEINTRESOURCE(IDD_CONN_HOST)); } void initDialog() { - if (_tcslen(pattern.buf) == 0) - pattern.replaceBuf(tstrDup("+")); + if (strlen(pattern.buf) == 0) + pattern.replaceBuf(strDup("+")); - if (pattern.buf[0] == _T('+')) + if (pattern.buf[0] == '+') setItemChecked(IDC_ALLOW, true); - else if (pattern.buf[0] == _T('?')) + else if (pattern.buf[0] == '?') setItemChecked(IDC_QUERY, true); else setItemChecked(IDC_DENY, true); @@ -60,29 +60,29 @@ namespace rfb { pattern.replaceBuf(0); } bool onOk() { - TCharArray host(getItemString(IDC_HOST_PATTERN)); - TCharArray newPat(_tcslen(host.buf)+2); + CharArray host(getItemString(IDC_HOST_PATTERN)); + CharArray newPat(strlen(host.buf)+2); if (isItemChecked(IDC_ALLOW)) - newPat.buf[0] = _T('+'); + newPat.buf[0] = '+'; else if (isItemChecked(IDC_QUERY)) - newPat.buf[0] = _T('?'); + newPat.buf[0] = '?'; else - newPat.buf[0] = _T('-'); + newPat.buf[0] = '-'; newPat.buf[1] = 0; - _tcscat(newPat.buf, host.buf); + strcat(newPat.buf, host.buf); try { - network::TcpFilter::Pattern pat(network::TcpFilter::parsePattern(CStr(newPat.buf))); - pattern.replaceBuf(TCharArray(network::TcpFilter::patternToStr(pat)).takeBuf()); + network::TcpFilter::Pattern pat(network::TcpFilter::parsePattern(newPat.buf)); + pattern.replaceBuf(CharArray(network::TcpFilter::patternToStr(pat)).takeBuf()); } catch(rdr::Exception& e) { - MsgBox(NULL, TStr(e.str()), MB_ICONEXCLAMATION | MB_OK); + MsgBox(NULL, e.str(), MB_ICONEXCLAMATION | MB_OK); return false; } return true; } - const TCHAR* getPattern() {return pattern.buf;} + const char* getPattern() {return pattern.buf;} protected: - TCharArray pattern; + CharArray pattern; }; class ConnectionsPage : public PropSheetPage { @@ -106,7 +106,7 @@ namespace rfb { CharArray first; strSplit(tmp.buf, ',', &first.buf, &tmp.buf); if (strlen(first.buf)) - SendMessage(listBox, LB_ADDSTRING, 0, (LPARAM)(const TCHAR*)TStr(first.buf)); + SendMessage(listBox, LB_ADDSTRING, 0, (LPARAM)first.buf); } onCommand(IDC_RFB_ENABLE, EN_CHANGE); @@ -157,9 +157,9 @@ namespace rfb { } case IDC_HOST_ADD: - if (hostDialog.showDialog(_T(""))) + if (hostDialog.showDialog("")) { - const TCHAR* pattern = hostDialog.getPattern(); + const char* pattern = hostDialog.getPattern(); if (pattern) SendMessage(GetDlgItem(handle, IDC_HOSTS), LB_ADDSTRING, 0, (LPARAM)pattern); } @@ -169,11 +169,11 @@ namespace rfb { { HWND listBox = GetDlgItem(handle, IDC_HOSTS); int item = SendMessage(listBox, LB_GETCURSEL, 0, 0); - TCharArray pattern(SendMessage(listBox, LB_GETTEXTLEN, item, 0)+1); + CharArray pattern(SendMessage(listBox, LB_GETTEXTLEN, item, 0)+1); SendMessage(listBox, LB_GETTEXT, item, (LPARAM)pattern.buf); if (hostDialog.showDialog(pattern.buf)) { - const TCHAR* newPat = hostDialog.getPattern(); + const char* newPat = hostDialog.getPattern(); if (newPat) { item = SendMessage(listBox, LB_FINDSTRINGEXACT, item, (LPARAM)pattern.buf); if (item != LB_ERR) { @@ -191,7 +191,7 @@ namespace rfb { { HWND listBox = GetDlgItem(handle, IDC_HOSTS); int item = SendMessage(listBox, LB_GETCURSEL, 0, 0); - TCharArray pattern(SendMessage(listBox, LB_GETTEXTLEN, item, 0)+1); + CharArray pattern(SendMessage(listBox, LB_GETTEXTLEN, item, 0)+1); SendMessage(listBox, LB_GETTEXT, item, (LPARAM)pattern.buf); SendMessage(listBox, LB_DELETESTRING, item, 0); SendMessage(listBox, LB_INSERTSTRING, item-1, (LPARAM)pattern.buf); @@ -204,7 +204,7 @@ namespace rfb { { HWND listBox = GetDlgItem(handle, IDC_HOSTS); int item = SendMessage(listBox, LB_GETCURSEL, 0, 0); - TCharArray pattern(SendMessage(listBox, LB_GETTEXTLEN, item, 0)+1); + CharArray pattern(SendMessage(listBox, LB_GETTEXTLEN, item, 0)+1); SendMessage(listBox, LB_GETTEXT, item, (LPARAM)pattern.buf); SendMessage(listBox, LB_DELETESTRING, item, 0); SendMessage(listBox, LB_INSERTSTRING, item+1, (LPARAM)pattern.buf); @@ -225,10 +225,10 @@ namespace rfb { return false; } bool onOk() { - regKey.setInt(_T("PortNumber"), isItemChecked(IDC_RFB_ENABLE) ? getItemInt(IDC_PORT) : 0); - regKey.setInt(_T("IdleTimeout"), getItemInt(IDC_IDLE_TIMEOUT)); - regKey.setInt(_T("LocalHost"), isItemChecked(IDC_LOCALHOST)); - regKey.setString(_T("Hosts"), TCharArray(getHosts()).buf); + regKey.setInt("PortNumber", isItemChecked(IDC_RFB_ENABLE) ? getItemInt(IDC_PORT) : 0); + regKey.setInt("IdleTimeout", getItemInt(IDC_IDLE_TIMEOUT)); + regKey.setInt("LocalHost", isItemChecked(IDC_LOCALHOST)); + regKey.setString("Hosts", CharArray(getHosts()).buf); return true; } bool isChanged() { @@ -248,9 +248,9 @@ namespace rfb { HWND listBox = GetDlgItem(handle, IDC_HOSTS); for (i=0; i 2); - MsgBox(0, _T("The QuerySetting option has been replaced by QueryConnect.") - _T("Please see the documentation for details of the QueryConnect option."), + if (key.getInt("QuerySetting", 2) != 2) { + regKey.setBool("QueryConnect", key.getInt("QuerySetting") > 2); + MsgBox(0, "The QuerySetting option has been replaced by QueryConnect." + "Please see the documentation for details of the QueryConnect option.", MB_ICONWARNING | MB_OK); } - regKey.setInt(_T("QueryTimeout"), key.getInt(_T("QueryTimeout"), 10)); + regKey.setInt("QueryTimeout", key.getInt("QueryTimeout", 10)); std::vector passwd; - passwd = key.getBinary(_T("Password")); - regKey.setBinary(_T("Password"), passwd.data(), passwd.size()); - - bool enableInputs = key.getBool(_T("InputsEnabled"), true); - regKey.setBool(_T("AcceptKeyEvents"), enableInputs); - regKey.setBool(_T("AcceptPointerEvents"), enableInputs); - regKey.setBool(_T("AcceptCutText"), enableInputs); - regKey.setBool(_T("SendCutText"), enableInputs); - - switch (key.getInt(_T("LockSetting"), 0)) { - case 0: regKey.setString(_T("DisconnectAction"), _T("None")); break; - case 1: regKey.setString(_T("DisconnectAction"), _T("Lock")); break; - case 2: regKey.setString(_T("DisconnectAction"), _T("Logoff")); break; + passwd = key.getBinary("Password"); + regKey.setBinary("Password", passwd.data(), passwd.size()); + + bool enableInputs = key.getBool("InputsEnabled", true); + regKey.setBool("AcceptKeyEvents", enableInputs); + regKey.setBool("AcceptPointerEvents", enableInputs); + regKey.setBool("AcceptCutText", enableInputs); + regKey.setBool("SendCutText", enableInputs); + + switch (key.getInt("LockSetting", 0)) { + case 0: regKey.setString("DisconnectAction", "None"); break; + case 1: regKey.setString("DisconnectAction", "Lock"); break; + case 2: regKey.setString("DisconnectAction", "Logoff"); break; }; - regKey.setBool(_T("DisableLocalInputs"), key.getBool(_T("LocalInputsDisabled"), false)); + regKey.setBool("DisableLocalInputs", key.getBool("LocalInputsDisabled", false)); // *** ignore polling preferences // PollUnderCursor, PollForeground, OnlyPollConsole, OnlyPollOnEvent - regKey.setBool(_T("UseHooks"), !key.getBool(_T("PollFullScreen"), false)); + regKey.setBool("UseHooks", !key.getBool("PollFullScreen", false)); - if (key.isValue(_T("AllowShutdown"))) - MsgBox(0, _T("The AllowShutdown option is not supported by this release."), MB_ICONWARNING | MB_OK); - if (key.isValue(_T("AllowEditClients"))) - MsgBox(0, _T("The AllowEditClients option is not supported by this release."), MB_ICONWARNING | MB_OK); + if (key.isValue("AllowShutdown")) + MsgBox(0, "The AllowShutdown option is not supported by this release.", MB_ICONWARNING | MB_OK); + if (key.isValue("AllowEditClients")) + MsgBox(0, "The AllowEditClients option is not supported by this release.", MB_ICONWARNING | MB_OK); - allowProperties = key.getBool(_T("AllowProperties"), allowProperties); + allowProperties = key.getBool("AllowProperties", allowProperties); } diff --git a/win/vncconfig/Legacy.h b/win/vncconfig/Legacy.h index 0fcf29fe..884a151a 100644 --- a/win/vncconfig/Legacy.h +++ b/win/vncconfig/Legacy.h @@ -44,12 +44,12 @@ namespace rfb { case IDC_LEGACY_IMPORT: { DWORD result = MsgBox(0, - _T("Importing your legacy VNC 3.3 settings will overwrite your existing settings.\n") - _T("Are you sure you wish to continue?"), + "Importing your legacy VNC 3.3 settings will overwrite your existing settings.\n" + "Are you sure you wish to continue?", MB_ICONWARNING | MB_YESNO); if (result == IDYES) { LoadPrefs(); - MsgBox(0, _T("Imported VNC 3.3 settings successfully."), + MsgBox(0, "Imported VNC 3.3 settings successfully.", MB_ICONINFORMATION | MB_OK); // Sleep to allow RegConfig thread to reload settings @@ -65,7 +65,7 @@ namespace rfb { return false; } bool onOk() { - regKey.setBool(_T("Protocol3.3"), isItemChecked(IDC_PROTOCOL_3_3)); + regKey.setBool("Protocol3.3", isItemChecked(IDC_PROTOCOL_3_3)); return true; } diff --git a/win/vncconfig/PasswordDialog.cxx b/win/vncconfig/PasswordDialog.cxx index d26d86f6..0483e496 100644 --- a/win/vncconfig/PasswordDialog.cxx +++ b/win/vncconfig/PasswordDialog.cxx @@ -33,20 +33,20 @@ bool PasswordDialog::showDialog(HWND owner) { } bool PasswordDialog::onOk() { - TPlainPasswd password1(getItemString(IDC_PASSWORD1)); - TPlainPasswd password2(getItemString(IDC_PASSWORD2)); - if (_tcscmp(password1.buf, password2.buf) != 0) { - MsgBox(0, _T("The supplied passwords do not match"), + PlainPasswd password1(getItemString(IDC_PASSWORD1)); + PlainPasswd password2(getItemString(IDC_PASSWORD2)); + if (strcmp(password1.buf, password2.buf) != 0) { + MsgBox(0, "The supplied passwords do not match", MB_ICONEXCLAMATION | MB_OK); return false; } if (registryInsecure && - (MsgBox(0, _T("Please note that your password cannot be stored securely on this system. ") - _T("Are you sure you wish to continue?"), + (MsgBox(0, "Please note that your password cannot be stored securely on this system. " + "Are you sure you wish to continue?", MB_YESNO | MB_ICONWARNING) == IDNO)) return false; PlainPasswd password(strDup(password1.buf)); ObfuscatedPasswd obfPwd(password); - regKey.setBinary(_T("Password"), obfPwd.buf, obfPwd.length); + regKey.setBinary("Password", obfPwd.buf, obfPwd.length); return true; } diff --git a/win/vncconfig/Sharing.h b/win/vncconfig/Sharing.h index 4dcb1db9..0a2bbe40 100644 --- a/win/vncconfig/Sharing.h +++ b/win/vncconfig/Sharing.h @@ -43,9 +43,9 @@ namespace rfb { return true; } bool onOk() { - regKey.setBool(_T("DisconnectClients"), isItemChecked(IDC_DISCONNECT_CLIENTS)); - regKey.setBool(_T("AlwaysShared"), isItemChecked(IDC_SHARE_ALWAYS)); - regKey.setBool(_T("NeverShared"), isItemChecked(IDC_SHARE_NEVER)); + regKey.setBool("DisconnectClients", isItemChecked(IDC_DISCONNECT_CLIENTS)); + regKey.setBool("AlwaysShared", isItemChecked(IDC_SHARE_ALWAYS)); + regKey.setBool("NeverShared", isItemChecked(IDC_SHARE_NEVER)); return true; } protected: diff --git a/win/vncconfig/vncconfig.cxx b/win/vncconfig/vncconfig.cxx index c58303d4..2b7eaa1e 100644 --- a/win/vncconfig/vncconfig.cxx +++ b/win/vncconfig/vncconfig.cxx @@ -43,7 +43,7 @@ static LogWriter vlog("main"); #include -TStr rfb::win32::AppName("TigerVNC Configuration"); +const char* rfb::win32::AppName = "TigerVNC Configuration"; #ifdef _DEBUG @@ -109,7 +109,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /* // Create the required configuration registry key RegKey rootKey; - rootKey.createKey(configKey, _T("Software\\TigerVNC\\WinVNC4")); + rootKey.createKey(configKey, "Software\\TigerVNC\\WinVNC4"); // Override whatever security it already had (NT only) bool warnOnChangePassword = false; @@ -130,8 +130,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /* // Something weird happens on NT 4.0 SP5 but I can't reproduce it on other // NT 4.0 service pack revisions. if (e.err == ERROR_INVALID_PARAMETER) { - MsgBox(0, _T("Windows reported an error trying to secure the VNC Server settings for this user. ") - _T("Your settings may not be secure!"), MB_ICONWARNING | MB_OK); + MsgBox(0, "Windows reported an error trying to secure the VNC Server settings for this user. " + "Your settings may not be secure!", MB_ICONWARNING | MB_OK); } else if (e.err != ERROR_CALL_NOT_IMPLEMENTED && e.err != ERROR_NOT_LOGGED_ON) { // If the call is not implemented, ignore the error and continue @@ -142,7 +142,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /* // Start a RegConfig thread, to load in existing settings RegConfigThread config; - config.start(configKey, _T("Software\\TigerVNC\\WinVNC4")); + config.start(configKey, "Software\\TigerVNC\\WinVNC4"); // Build the dialog std::list pages; @@ -159,9 +159,9 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /* HICON icon = (HICON)LoadImage(inst, MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 0, 0, LR_SHARED); // Create the PropertySheet handler - const TCHAR* propSheetTitle = _T("VNC Server Properties (Service-Mode)"); + const char* propSheetTitle = "VNC Server Properties (Service-Mode)"; if (configKey == HKEY_CURRENT_USER) - propSheetTitle = _T("VNC Server Properties (User-Mode)"); + propSheetTitle = "VNC Server Properties (User-Mode)"; PropSheet sheet(inst, propSheetTitle, pages, icon); #ifdef _DEBUG @@ -173,7 +173,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /* } catch (rdr::SystemException& e) { switch (e.err) { case ERROR_ACCESS_DENIED: - MsgBox(0, _T("You do not have sufficient access rights to run the VNC Configuration applet"), + MsgBox(0, "You do not have sufficient access rights to run the VNC Configuration applet", MB_ICONSTOP | MB_OK); return 1; }; @@ -181,7 +181,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /* } } catch (rdr::Exception& e) { - MsgBox(NULL, TStr(e.str()), MB_ICONEXCLAMATION | MB_OK); + MsgBox(NULL, e.str(), MB_ICONEXCLAMATION | MB_OK); return 1; } diff --git a/win/winvnc/AddNewClientDialog.h b/win/winvnc/AddNewClientDialog.h index 9bf51355..4bc489d8 100644 --- a/win/winvnc/AddNewClientDialog.h +++ b/win/winvnc/AddNewClientDialog.h @@ -23,7 +23,6 @@ #include #include -//#include namespace winvnc { @@ -41,10 +40,10 @@ namespace winvnc { // Dialog methods (protected) virtual void initDialog() { if (hostName.buf) - setItemString(IDC_HOST, rfb::TStr(hostName.buf)); + setItemString(IDC_HOST, hostName.buf); } virtual bool onOk() { - hostName.replaceBuf(rfb::strDup(rfb::CStr(getItemString(IDC_HOST)))); + hostName.replaceBuf(rfb::strDup(getItemString(IDC_HOST))); return true; } diff --git a/win/winvnc/ControlPanel.cxx b/win/winvnc/ControlPanel.cxx index d498513a..ff4a63a1 100644 --- a/win/winvnc/ControlPanel.cxx +++ b/win/winvnc/ControlPanel.cxx @@ -21,11 +21,11 @@ bool ControlPanel::showDialog() void ControlPanel::initDialog() { - TCHAR *ColumnsStrings[] = { - (TCHAR *) "IP address", - (TCHAR *) "Status" + const char *ColumnsStrings[] = { + "IP address", + "Status" }; - InitLVColumns(IDC_LIST_CONNECTIONS, handle, 120, 2, ColumnsStrings, + InitLVColumns(IDC_LIST_CONNECTIONS, handle, 120, 2, (char **)ColumnsStrings, LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM, LVS_EX_FULLROWSELECT, LVCFMT_LEFT); SendCommand(4, -1); @@ -93,7 +93,7 @@ void ControlPanel::UpdateListView(ListConnInfo* LCInfo) for (ListConn.iBegin(); !ListConn.iEnd(); ListConn.iNext()) { ListConn.iGetCharInfo(ItemString); - InsertLVItem(IDC_LIST_CONNECTIONS, handle, i, (TCHAR **) ItemString, 2); + InsertLVItem(IDC_LIST_CONNECTIONS, handle, i, (char **) ItemString, 2); for (ListSelConn.iBegin(); !ListSelConn.iEnd(); ListSelConn.iNext()) { if (ListSelConn.iGetConn() == ListConn.iGetConn()) SelectLVItem(IDC_LIST_CONNECTIONS, handle, i); diff --git a/win/winvnc/QueryConnectDialog.cxx b/win/winvnc/QueryConnectDialog.cxx index 8cea7a67..295f26c2 100644 --- a/win/winvnc/QueryConnectDialog.cxx +++ b/win/winvnc/QueryConnectDialog.cxx @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -77,16 +76,16 @@ void QueryConnectDialog::worker() { void QueryConnectDialog::initDialog() { if (!SetTimer(handle, 1, 1000, 0)) throw rdr::SystemException("SetTimer", GetLastError()); - setItemString(IDC_QUERY_HOST, TStr(peerIp.buf)); + setItemString(IDC_QUERY_HOST, peerIp.buf); if (!userName.buf) userName.buf = strDup("(anonymous)"); - setItemString(IDC_QUERY_USER, TStr(userName.buf)); + setItemString(IDC_QUERY_USER, userName.buf); setCountdownLabel(); } void QueryConnectDialog::setCountdownLabel() { - TCHAR buf[16]; - _stprintf(buf, _T("%d"), countdown); + char buf[16]; + sprintf(buf, "%d", countdown); setItemString(IDC_QUERY_COUNTDOWN, buf); } diff --git a/win/winvnc/STrayIcon.cxx b/win/winvnc/STrayIcon.cxx index 2cf24752..4ba147c2 100644 --- a/win/winvnc/STrayIcon.cxx +++ b/win/winvnc/STrayIcon.cxx @@ -73,11 +73,11 @@ namespace winvnc { class STrayIcon : public TrayIcon { public: STrayIcon(STrayIconThread& t) : - vncConfig(_T("vncconfig.exe"), isServiceProcess() ? _T("-noconsole -service") : _T("-noconsole")), - vncConnect(_T("winvnc4.exe"), _T("-noconsole -connect")), thread(t) { + vncConfig("vncconfig.exe", isServiceProcess() ? "-noconsole -service" : "-noconsole"), + vncConnect("winvnc4.exe", "-noconsole -connect"), thread(t) { // *** - SetWindowText(getHandle(), _T("winvnc::IPC_Interface")); + SetWindowText(getHandle(), "winvnc::IPC_Interface"); // *** SetTimer(getHandle(), 1, 3000, 0); @@ -154,13 +154,13 @@ public: thread.server.disconnectClients("tray menu disconnect"); break; case ID_CLOSE: - if (MsgBox(0, _T("Are you sure you want to close the server?"), + if (MsgBox(0, "Are you sure you want to close the server?", MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES) { if (isServiceProcess()) { try { rfb::win32::stopService(VNCServerService::Name); } catch (rdr::Exception& e) { - MsgBox(0, TStr(e.str()), MB_ICONERROR | MB_OK); + MsgBox(0, e.str(), MB_ICONERROR | MB_OK); } } else { thread.server.stop(); @@ -277,11 +277,11 @@ void STrayIconThread::worker() { } } -void STrayIconThread::setToolTip(const TCHAR* text) { +void STrayIconThread::setToolTip(const char* text) { if (!windowHandle) return; os::AutoMutex a(lock); delete [] toolTip.buf; - toolTip.buf = tstrDup(text); + toolTip.buf = strDup(text); PostMessage(windowHandle, WM_SET_TOOLTIP, 0, 0); } diff --git a/win/winvnc/STrayIcon.h b/win/winvnc/STrayIcon.h index 09066362..c0385852 100644 --- a/win/winvnc/STrayIcon.h +++ b/win/winvnc/STrayIcon.h @@ -20,7 +20,6 @@ #define WINVNC_TRAYICON_H #include -#include #include namespace os { @@ -36,7 +35,7 @@ namespace winvnc { UINT activeIcon, UINT dis_inactiveIcon, UINT dis_activeIcon, UINT menu); virtual ~STrayIconThread(); - void setToolTip(const TCHAR* text); + void setToolTip(const char* text); static rfb::BoolParameter disableOptions; static rfb::BoolParameter disableClose; @@ -48,7 +47,7 @@ namespace winvnc { os::Mutex* lock; DWORD thread_id; HWND windowHandle; - rfb::TCharArray toolTip; + rfb::CharArray toolTip; VNCServerWin32& server; UINT inactiveIcon; UINT activeIcon; diff --git a/win/winvnc/VNCServerService.cxx b/win/winvnc/VNCServerService.cxx index b4f81e27..0a0ed520 100644 --- a/win/winvnc/VNCServerService.cxx +++ b/win/winvnc/VNCServerService.cxx @@ -34,7 +34,7 @@ using namespace winvnc; using namespace rfb; using namespace win32; -const TCHAR* winvnc::VNCServerService::Name = _T("TigerVNC"); +const char* winvnc::VNCServerService::Name = "TigerVNC"; // SendSAS is not available until Windows 7, and missing from MinGW static HMODULE sasLibrary = NULL; @@ -108,7 +108,7 @@ HANDLE LaunchProcessWin(DWORD /*dwSessionId*/) if (GetSessionUserTokenWin(&hToken)) { ModuleFileName filename; - TCharArray cmdLine; + CharArray cmdLine; cmdLine.format("\"%s\" -noconsole -service_run", filename.buf); STARTUPINFO si; ZeroMemory(&si, sizeof si); @@ -125,7 +125,7 @@ HANDLE LaunchProcessWin(DWORD /*dwSessionId*/) return hProcess; } -DWORD VNCServerService::serviceMain(int /*argc*/, TCHAR* /*argv*/ []) +DWORD VNCServerService::serviceMain(int /*argc*/, char* /*argv*/ []) { ConsoleSessionId OlddwSessionId; diff --git a/win/winvnc/VNCServerService.h b/win/winvnc/VNCServerService.h index 8cb82c29..cae44868 100644 --- a/win/winvnc/VNCServerService.h +++ b/win/winvnc/VNCServerService.h @@ -28,10 +28,10 @@ namespace winvnc { public: VNCServerService(); - DWORD serviceMain(int argc, TCHAR* argv[]); + DWORD serviceMain(int argc, char* argv[]); void stop(); - static const TCHAR* Name; + static const char* Name; protected: rfb::win32::Handle stopServiceEvent; rfb::win32::Handle sessionEvent; diff --git a/win/winvnc/VNCServerWin32.cxx b/win/winvnc/VNCServerWin32.cxx index 79769e93..70f82ff0 100644 --- a/win/winvnc/VNCServerWin32.cxx +++ b/win/winvnc/VNCServerWin32.cxx @@ -44,7 +44,7 @@ using namespace network; static LogWriter vlog("VNCServerWin32"); -const TCHAR* winvnc::VNCServerWin32::RegConfigPath = _T("Software\\TigerVNC\\WinVNC4"); +const char* winvnc::VNCServerWin32::RegConfigPath = "Software\\TigerVNC\\WinVNC4"; static IntParameter port_number("PortNumber", @@ -64,7 +64,7 @@ VNCServerWin32::VNCServerWin32() commandEvent(CreateEvent(0, TRUE, FALSE, 0)), sessionEvent(isServiceProcess() ? CreateEvent(0, FALSE, FALSE, "Global\\SessionEventTigerVNC") : 0), - vncServer(CStr(ComputerName().buf), &desktop), + vncServer(ComputerName().buf, &desktop), thread_id(-1), runServer(false), isDesktopStarted(false), config(&sockMgr), rfbSock(&sockMgr), trayIcon(0), queryConnectDialog(0) @@ -112,9 +112,9 @@ void VNCServerWin32::processAddressChange() { return; // Tool-tip prefix depends on server mode - const TCHAR* prefix = _T("VNC Server (User):"); + const char* prefix = "VNC Server (User):"; if (isServiceProcess()) - prefix = _T("VNC Server (Service):"); + prefix = "VNC Server (Service):"; // Fetch the list of addresses std::list addrs; @@ -125,19 +125,19 @@ void VNCServerWin32::processAddressChange() { // Allocate space for the new tip std::list::iterator i, next_i; - int length = _tcslen(prefix)+1; + int length = strlen(prefix)+1; for (i=addrs.begin(); i!= addrs.end(); i++) length += strlen(*i) + 1; // Build the new tip - TCharArray toolTip(length); - _tcscpy(toolTip.buf, prefix); + CharArray toolTip(length); + strcpy(toolTip.buf, prefix); for (i=addrs.begin(); i!= addrs.end(); i=next_i) { next_i = i; next_i ++; - TCharArray addr(*i); // Assumes ownership of string - _tcscat(toolTip.buf, addr.buf); + CharArray addr(*i); // Assumes ownership of string + strcat(toolTip.buf, addr.buf); if (next_i != addrs.end()) - _tcscat(toolTip.buf, _T(",")); + strcat(toolTip.buf, ","); } // Pass the new tip to the tray icon diff --git a/win/winvnc/VNCServerWin32.h b/win/winvnc/VNCServerWin32.h index 1a737823..0a2c330c 100644 --- a/win/winvnc/VNCServerWin32.h +++ b/win/winvnc/VNCServerWin32.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -72,7 +71,7 @@ namespace winvnc { void queryConnectionComplete(); // Where to read the configuration settings from - static const TCHAR* RegConfigPath; + static const char* RegConfigPath; bool getClientsInfo(ListConnInfo* LCInfo); diff --git a/win/winvnc/winvnc.cxx b/win/winvnc/winvnc.cxx index 271538d0..ee4d94a5 100644 --- a/win/winvnc/winvnc.cxx +++ b/win/winvnc/winvnc.cxx @@ -41,7 +41,7 @@ using namespace win32; static LogWriter vlog("main"); -TStr rfb::win32::AppName("TigerVNC Server"); +const char* rfb::win32::AppName = "TigerVNC Server"; extern bool runAsService; @@ -56,12 +56,12 @@ static bool close_console = false; static void programInfo() { win32::FileVersionInfo inf; - _tprintf(_T("%s - %s, Version %s\n"), - inf.getVerString(_T("ProductName")), - inf.getVerString(_T("FileDescription")), - inf.getVerString(_T("FileVersion"))); + printf("%s - %s, Version %s\n", + inf.getVerString("ProductName"), + inf.getVerString("FileDescription"), + inf.getVerString("FileVersion")); printf("%s\n", buildTime); - _tprintf(_T("%s\n\n"), inf.getVerString(_T("LegalCopyright"))); + printf("%s\n\n", inf.getVerString("LegalCopyright")); } static void programUsage() { @@ -87,7 +87,7 @@ static void programUsage() { static void MsgBoxOrLog(const char* msg, bool isError=false) { if (close_console) { - MsgBox(0, TStr(msg), (isError ? MB_ICONERROR : MB_ICONINFORMATION) | MB_OK); + MsgBox(0, msg, (isError ? MB_ICONERROR : MB_ICONINFORMATION) | MB_OK); } else { if (isError) { try { @@ -116,7 +116,7 @@ static void processParams(int argc, char** argv) { host.buf = strDup(ancd.getHostName()); } if (host.buf) { - HWND hwnd = FindWindow(0, _T("winvnc::IPC_Interface")); + HWND hwnd = FindWindow(0, "winvnc::IPC_Interface"); if (!hwnd) throw rdr::Exception("Unable to locate existing VNC Server."); COPYDATASTRUCT copyData; @@ -129,7 +129,7 @@ static void processParams(int argc, char** argv) { } } else if (strcasecmp(argv[i], "-disconnect") == 0) { runServer = false; - HWND hwnd = FindWindow(0, _T("winvnc::IPC_Interface")); + HWND hwnd = FindWindow(0, "winvnc::IPC_Interface"); if (!hwnd) throw rdr::Exception("Unable to locate existing VNC Server."); COPYDATASTRUCT copyData; @@ -155,7 +155,7 @@ static void processParams(int argc, char** argv) { CharArray result; DWORD state = rfb::win32::getServiceState(VNCServerService::Name); result.format("The %s Service is in the %s state.", - (const char*)CStr(VNCServerService::Name), + VNCServerService::Name, rfb::win32::serviceStateName(state)); MsgBoxOrLog(result.buf); } else if (strcasecmp(argv[i], "-service") == 0) { @@ -186,8 +186,8 @@ static void processParams(int argc, char** argv) { } if (rfb::win32::registerService(VNCServerService::Name, - _T("TigerVNC Server"), - _T("Provides remote access to this machine via the VNC/RFB protocol."), + "TigerVNC Server", + "Provides remote access to this machine via the VNC/RFB protocol.", argc-(j+1), &argv[j+1])) MsgBoxOrLog("Registered service successfully"); } else if (strcasecmp(argv[i], "-unregister") == 0) { diff --git a/win/wm_hooks/wm_hooks.cxx b/win/wm_hooks/wm_hooks.cxx index be845d6a..c864171b 100644 --- a/win/wm_hooks/wm_hooks.cxx +++ b/win/wm_hooks/wm_hooks.cxx @@ -24,48 +24,46 @@ #include #endif -#include - #include #include #define SHARED __attribute__((section ("shared"), shared)) -UINT WM_HK_PingThread = RegisterWindowMessage(_T("RFB.WM_Hooks.PingThread")); +UINT WM_HK_PingThread = RegisterWindowMessage("RFB.WM_Hooks.PingThread"); -UINT WM_HK_WindowChanged = RegisterWindowMessage(_T("RFB.WM_Hooks.WindowChanged")); +UINT WM_HK_WindowChanged = RegisterWindowMessage("RFB.WM_Hooks.WindowChanged"); UINT WM_Hooks_WindowChanged() { return WM_HK_WindowChanged; } -UINT WM_HK_WindowClientAreaChanged = RegisterWindowMessage(_T("RFB.WM_Hooks.WindowClientAreaChanged")); +UINT WM_HK_WindowClientAreaChanged = RegisterWindowMessage("RFB.WM_Hooks.WindowClientAreaChanged"); UINT WM_Hooks_WindowClientAreaChanged() { return WM_HK_WindowClientAreaChanged; } -UINT WM_HK_WindowBorderChanged = RegisterWindowMessage(_T("RFB.WM_Hooks.WindowBorderChanged")); +UINT WM_HK_WindowBorderChanged = RegisterWindowMessage("RFB.WM_Hooks.WindowBorderChanged"); UINT WM_Hooks_WindowBorderChanged() { return WM_HK_WindowBorderChanged; } -UINT WM_HK_RectangleChanged = RegisterWindowMessage(_T("RFB.WM_Hooks.RectangleChanged")); +UINT WM_HK_RectangleChanged = RegisterWindowMessage("RFB.WM_Hooks.RectangleChanged"); UINT WM_Hooks_RectangleChanged() { return WM_HK_RectangleChanged; } -UINT WM_HK_CursorChanged = RegisterWindowMessage(_T("RFB.WM_Hooks.CursorChanged")); +UINT WM_HK_CursorChanged = RegisterWindowMessage("RFB.WM_Hooks.CursorChanged"); UINT WM_Hooks_CursorChanged() { return WM_HK_CursorChanged; } #ifdef _DEBUG -UINT WM_HK_Diagnostic = RegisterWindowMessage(_T("RFB.WM_Hooks.Diagnostic")); +UINT WM_HK_Diagnostic = RegisterWindowMessage("RFB.WM_Hooks.Diagnostic"); UINT WM_Hooks_Diagnostic() { return WM_HK_Diagnostic; } #endif -ATOM ATOM_Popup_Selection = GlobalAddAtom(_T("RFB.WM_Hooks.PopupSelectionAtom")); +ATOM ATOM_Popup_Selection = GlobalAddAtom("RFB.WM_Hooks.PopupSelectionAtom"); // // -=- DLL entry point -- 2.39.5