From 1b14a65c6d46b10a7305762c6bcb96c6ee19a0e7 Mon Sep 17 00:00:00 2001 From: Roman Shchekin Date: Sun, 4 Oct 2015 11:16:16 +0300 Subject: [PATCH] Signed-off-by Roman Shchekin (github: QtRoS) --- Telegram/SourceFiles/_other/updater.cpp | 20 ++++++++++---------- Telegram/Updater.rc | Bin 4370 -> 4372 bytes 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/_other/updater.cpp b/Telegram/SourceFiles/_other/updater.cpp index 81afbde5c7..9eef2d97c2 100644 --- a/Telegram/SourceFiles/_other/updater.cpp +++ b/Telegram/SourceFiles/_other/updater.cpp @@ -27,8 +27,8 @@ bool equal(const wstring &a, const wstring &b) { void updateError(const WCHAR *msg, DWORD errorCode) { WCHAR errMsg[2048]; - LPTSTR errorText = NULL, errorTextDefault = L"(Unknown error)"; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&errorText, 0, 0); + LPWSTR errorText = NULL, errorTextDefault = L"(Unknown error)"; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&errorText, 0, 0); if (!errorText) { errorText = errorTextDefault; } @@ -143,11 +143,11 @@ bool update() { HANDLE versionFile = CreateFile((tdataDir + L"\\version").c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if (versionFile != INVALID_HANDLE_VALUE) { - if (ReadFile(versionFile, &versionNum, sizeof(DWORD), &readLen, NULL) != TRUE || readLen != sizeof(DWORD)) { + if (!ReadFile(versionFile, &versionNum, sizeof(DWORD), &readLen, NULL) || readLen != sizeof(DWORD)) { versionNum = 0; - } else if (ReadFile(versionFile, &versionLen, sizeof(DWORD), &readLen, NULL) != TRUE || readLen != sizeof(DWORD) || versionLen > 63) { + } else if (!ReadFile(versionFile, &versionLen, sizeof(DWORD), &readLen, NULL) || readLen != sizeof(DWORD) || versionLen > 63) { versionNum = 0; - } else if (ReadFile(versionFile, versionStr, versionLen, &readLen, NULL) != TRUE || readLen != versionLen) { + } else if (!ReadFile(versionFile, versionStr, versionLen, &readLen, NULL) || readLen != versionLen) { versionNum = 0; } CloseHandle(versionFile); @@ -242,14 +242,14 @@ bool update() { int copyTries = 0; do { copyResult = CopyFile(fname.c_str(), tofname.c_str(), FALSE); - if (copyResult == FALSE) { + if (!copyResult) { ++copyTries; Sleep(100); } else { break; } } while (copyTries < 30); - if (copyResult == FALSE) { + if (!copyResult) { writeLog(L"Error: failed to copy, asking to retry.."); WCHAR errMsg[2048]; wsprintf(errMsg, L"Failed to update Telegram :(\n%s is not accessible.", tofname); @@ -258,7 +258,7 @@ bool update() { return false; } } - } while (copyResult == FALSE); + } while (!copyResult); } writeLog(L"Update succeed! Clearing folder.."); @@ -289,7 +289,7 @@ void updateRegistry() { } } if (locationType == REG_EXPAND_SZ || locationType == REG_SZ) { - if (PathCanonicalize(exp, locationStr) == TRUE) { + if (PathCanonicalize(exp, locationStr)) { memcpy(locationStr, exp, bufSize * sizeof(WCHAR)); if (GetFullPathName(L".", bufSize, exp, 0) < bufSize) { wstring installpath = locationStr, mypath = exp; @@ -323,7 +323,7 @@ void updateRegistry() { #include -int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParamarg, int cmdShow) { +int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdParamarg, int cmdShow) { openLog(); #ifdef _NEED_WIN_GENERATE_DUMP diff --git a/Telegram/Updater.rc b/Telegram/Updater.rc index 0a3c12aa216c3f7028d33374d2de2f9c997cb3d2..5df23e7561c5da258f8c175806fc5606aedea17e 100644 GIT binary patch delta 36 scmbQFG(~9x50h{?LncEWLkdGaLpeh+gC0W$gVJP0ft8z&G5PQT0H~Jz>% delta 22 dcmbQDG)ZX#4-;o1LmEQ`LlHyjW^ty!d;mrE1|I+b