diff options
author | Pierre Ossman <ossman@cendio.se> | 2023-01-10 21:24:21 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2023-02-04 14:03:13 +0100 |
commit | 77f0a61ec8f1488d6042b1370444bb2612604292 (patch) | |
tree | 76a965e971e87e53abd0f7cb45c1baa7fbe52e99 /win/rfb_win32 | |
parent | 2047dae22fb862ff43309ebb4fe2b9e7d6ce6153 (diff) | |
download | tigervnc-77f0a61ec8f1488d6042b1370444bb2612604292.tar.gz tigervnc-77f0a61ec8f1488d6042b1370444bb2612604292.zip |
Get rid of TCHAR magic
We never use Windows' "UNICODE" mode anyway, so let's get rid of this
complexity.
Diffstat (limited to 'win/rfb_win32')
42 files changed, 254 insertions, 486 deletions
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 <rfb_win32/AboutDialog.h> #include <rfb_win32/Win32Util.h> -#include <rfb_win32/TCharArray.h> #include <rfb/LogWriter.h> 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 <rfb_win32/TCharArray.h> - 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 <windows.h> -#include <rfb_win32/TCharArray.h> +#include <rfb/util.h> 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 <rfb/util.h> #include <rfb_win32/Handle.h> #include <rfb_win32/Security.h> @@ -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 <windows.h> #include <rfb/PixelFormat.h> #include <rfb/Rect.h> -#include <rfb_win32/TCharArray.h> 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 <rfb_win32/Dialog.h> -#include <rfb_win32/TCharArray.h> #include <rfb/LogWriter.h> #include <rdr/Exception.h> #include <rfb_win32/Win32Util.h> @@ -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<PropSheetPage*> 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<PropSheetPage*> 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<strlen(pageTitle.buf); j++) { if (pageTitle.buf[j] == '/' || pageTitle.buf[j] == '\\' || pageTitle.buf[j] == ':') diff --git a/win/rfb_win32/Dialog.h b/win/rfb_win32/Dialog.h index 35abb990..582aa0d9 100644 --- a/win/rfb_win32/Dialog.h +++ b/win/rfb_win32/Dialog.h @@ -28,7 +28,8 @@ #include <windows.h> #include <prsht.h> #include <list> -#include <rfb_win32/TCharArray.h> + +#include <rfb/util.h> 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<PropSheetPage*> pages, HICON icon=0); + PropSheet(HINSTANCE inst, const char* title, std::list<PropSheetPage*> pages, HICON icon=0); virtual ~PropSheet(); // Display the PropertySheet @@ -130,14 +131,14 @@ namespace rfb { HICON icon; std::list<PropSheetPage*> 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 <config.h> #endif +#include <windows.h> + #include <rfb_win32/EventManager.h> #include <rdr/Exception.h> #include <rfb/LogWriter.h> 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 <windows.h> -#include <rfb_win32/TCharArray.h> + +#include <rfb/util.h> 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 <config.h> #endif -#include <tchar.h> #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 <windows.h> -#include <rfb_win32/TCharArray.h> + +#include <rfb/util.h> 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 <config.h> #endif -#include <tchar.h> #include <rfb_win32/MonitorInfo.h> #include <rfb_win32/Win32Util.h> #include <rdr/Exception.h> 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 <windows.h> -#include <rfb_win32/TCharArray.h> + +#include <rfb/util.h> 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 <rfb/LogWriter.h> #include <rdr/Exception.h> #include <malloc.h> -#include <tchar.h> 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 <windows.h> -#include <rfb_win32/TCharArray.h> + +#include <rfb/util.h> 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<uint8_t> RegKey::getBinary(const TCHAR* valname) const { - TCharArray hex(getRepresentation(valname)); - return hexToBin(CStr(hex.buf), strlen(CStr(hex.buf))); +std::vector<uint8_t> RegKey::getBinary(const char* valname) const { + CharArray hex(getRepresentation(valname)); + return hexToBin(hex.buf, strlen(hex.buf)); } -std::vector<uint8_t> RegKey::getBinary(const TCHAR* valname, const uint8_t* def, size_t deflen) const { +std::vector<uint8_t> 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<uint8_t> 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<length) throw rdr::Exception("unable to expand environment strings"); return result.takeBuf(); } else { - return tstrDup(_T("")); + return strDup(""); } } default: @@ -265,16 +265,16 @@ TCHAR* RegKey::getRepresentation(const TCHAR* valname) const { } } -bool RegKey::isValue(const TCHAR* valname) const { +bool RegKey::isValue(const char* valname) const { try { - TCharArray tmp(getRepresentation(valname)); + CharArray tmp(getRepresentation(valname)); return true; } catch(rdr::Exception&) { return false; } } -const TCHAR* RegKey::getValueName(int i) { +const char* RegKey::getValueName(int i) { DWORD maxValueNameLen; LONG result = RegQueryInfoKey(key, 0, 0, 0, 0, 0, 0, 0, &maxValueNameLen, 0, 0, 0); if (result != ERROR_SUCCESS) @@ -282,7 +282,7 @@ const TCHAR* RegKey::getValueName(int i) { if (valueNameBufLen < maxValueNameLen + 1) { valueNameBufLen = maxValueNameLen + 1; delete [] valueName.buf; - valueName.buf = new TCHAR[valueNameBufLen]; + valueName.buf = new char[valueNameBufLen]; } DWORD length = valueNameBufLen; result = RegEnumValue(key, i, valueName.buf, &length, NULL, 0, 0, 0); @@ -292,7 +292,7 @@ const TCHAR* RegKey::getValueName(int i) { return valueName.buf; } -const TCHAR* RegKey::getKeyName(int i) { +const char* RegKey::getKeyName(int i) { DWORD maxValueNameLen; LONG result = RegQueryInfoKey(key, 0, 0, 0, 0, &maxValueNameLen, 0, 0, 0, 0, 0, 0); if (result != ERROR_SUCCESS) @@ -300,7 +300,7 @@ const TCHAR* RegKey::getKeyName(int i) { if (valueNameBufLen < maxValueNameLen + 1) { valueNameBufLen = maxValueNameLen + 1; delete [] valueName.buf; - valueName.buf = new TCHAR[valueNameBufLen]; + valueName.buf = new char[valueNameBufLen]; } DWORD length = valueNameBufLen; result = RegEnumKeyEx(key, i, valueName.buf, &length, NULL, 0, 0, 0); diff --git a/win/rfb_win32/Registry.h b/win/rfb_win32/Registry.h index 3b87983b..7292372f 100644 --- a/win/rfb_win32/Registry.h +++ b/win/rfb_win32/Registry.h @@ -49,10 +49,10 @@ namespace rfb { public: // Returns true if key was created, false if already existed - bool createKey(const RegKey& root, const TCHAR* name); + bool createKey(const RegKey& root, const char* name); // Opens key if it exists, or raises an exception if not - void openKey(const RegKey& root, const TCHAR* name, bool readOnly=false); + void openKey(const RegKey& root, const char* name, bool readOnly=false); // Set the (discretionary) access control list for the key void setDACL(const PACL acl, bool inheritFromParent=true); @@ -61,47 +61,47 @@ namespace rfb { void close(); // Delete a subkey/value - void deleteKey(const TCHAR* name) const; - void deleteValue(const TCHAR* name) const; + void deleteKey(const char* name) const; + void deleteValue(const char* name) const; // Block waiting for a registry change, OR return immediately and notify the // event when there is a change, if specified void awaitChange(bool watchSubTree, DWORD filter, HANDLE event=0) const; - void setExpandString(const TCHAR* valname, const TCHAR* s) const; - void setString(const TCHAR* valname, const TCHAR* s) const; - void setBinary(const TCHAR* valname, const void* data, size_t length) const; - void setInt(const TCHAR* valname, int i) const; - void setBool(const TCHAR* valname, bool b) const; + void setExpandString(const char* valname, const char* s) const; + void setString(const char* valname, const char* s) const; + void setBinary(const char* valname, const void* data, size_t length) const; + void setInt(const char* valname, int i) const; + void setBool(const char* valname, bool b) const; - TCHAR* getString(const TCHAR* valname) const; - TCHAR* getString(const TCHAR* valname, const TCHAR* def) const; + char* getString(const char* valname) const; + char* getString(const char* valname, const char* def) const; - std::vector<uint8_t> getBinary(const TCHAR* valname) const; - std::vector<uint8_t> getBinary(const TCHAR* valname, const uint8_t* def, size_t deflength) const; + std::vector<uint8_t> getBinary(const char* valname) const; + std::vector<uint8_t> 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 <rfb/keysymdef.h> -#include <tchar.h> #include <rfb_win32/SInput.h> #include <rfb_win32/MonitorInfo.h> #include <rfb_win32/Service.h> 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 <stdint.h> #include <vector> #include <rfb_win32/LocalMem.h> -#include <rfb_win32/TCharArray.h> #include <aclapi.h> 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; i<argc; i++) { cmdline_len += strlen(argv[i]) + 3; } // - Add the supplied extra parameters to the command line - TCharArray cmdline(cmdline_len+_tcslen(defaultcmdline)); - _stprintf(cmdline.buf, _T("\"%s\" %s"), buffer.buf, defaultcmdline); + CharArray cmdline(cmdline_len+strlen(defaultcmdline)); + sprintf(cmdline.buf, "\"%s\" %s", buffer.buf, defaultcmdline); for (i=0; i<argc; i++) { - _tcscat(cmdline.buf, _T(" \"")); - _tcscat(cmdline.buf, TStr(argv[i])); - _tcscat(cmdline.buf, _T("\"")); + strcat(cmdline.buf, " \""); + strcat(cmdline.buf, argv[i]); + strcat(cmdline.buf, "\""); } // - Register the service @@ -353,30 +352,30 @@ bool rfb::win32::registerService(const TCHAR* name, // - Register the event log source RegKey hk, hk2; - hk2.createKey(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application")); + hk2.createKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application"); hk.createKey(hk2, name); - for (i=_tcslen(buffer.buf); i>0; 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 <config.h> -#endif - -#include <rfb_win32/TCharArray.h> - -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<l; i++) - if (src[i] == c) return true; - return false; - } - -}; diff --git a/win/rfb_win32/TCharArray.h b/win/rfb_win32/TCharArray.h deleted file mode 100644 index dde63b78..00000000 --- a/win/rfb_win32/TCharArray.h +++ /dev/null @@ -1,135 +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. - */ - -// -=- TCharArray.h - -// This library contains the wide-character equivalent of CharArray, named -// WCharArray. In addition to providing wide-character equivalents of -// the char* string manipulation functions (strDup, strFree, etc), special -// versions of those functions are provided which attempt to convert from -// one format to the other. -// e.g. char* t = "hello world"; WCHAR* w = wstrDup(t); -// Results in w containing the wide-character text "hello world". -// For convenience, the WStr and CStr classes are also provided. These -// accept an existing (const) WCHAR* or char* null-terminated string and -// create a read-only copy of that in the desired format. The new copy -// will actually be the original copy if the format has not changed, otherwise -// it will be a new buffer owned by the WStr/CStr. - -// In addition to providing wide character functions, this header defines -// TCHAR* handling classes & functions. TCHAR is defined at compile time to -// either char or WCHAR. Programs can treat this as a third data type and -// call TStr() whenever a TCHAR* is required but a char* or WCHAR* is supplied, -// and TStr will do the right thing. - -#ifndef __RFB_WIN32_TCHARARRAY_H__ -#define __RFB_WIN32_TCHARARRAY_H__ - -#include <windows.h> -#include <tchar.h> -#include <rfb/util.h> -#include <rfb/Password.h> - -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 <rfb_win32/TsSessions.h> #include <rfb/LogWriter.h> #include <rdr/Exception.h> -#include <tchar.h> #include <wtsapi32.h> 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 <rfb/LogWriter.h> #include <rfb/Configuration.h> -#include <tchar.h> - 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 <rfb_win32/TCharArray.h> +#include <rfb/util.h> 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 |