Signed-off-by Roman Shchekin <mrqtros@gmail.com> (github: QtRoS)
This commit is contained in:
		
							parent
							
								
									db05e10f5f
								
							
						
					
					
						commit
						1b14a65c6d
					
				
					 2 changed files with 10 additions and 10 deletions
				
			
		|  | @ -27,8 +27,8 @@ bool equal(const wstring &a, const wstring &b) { | ||||||
| 
 | 
 | ||||||
| void updateError(const WCHAR *msg, DWORD errorCode) { | void updateError(const WCHAR *msg, DWORD errorCode) { | ||||||
| 	WCHAR errMsg[2048]; | 	WCHAR errMsg[2048]; | ||||||
| 	LPTSTR errorText = NULL, errorTextDefault = L"(Unknown error)"; | 	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), (LPTSTR)&errorText, 0, 0); | 	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) { | 	if (!errorText) { | ||||||
| 		errorText = errorTextDefault; | 		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); | 	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 (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; | 			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; | 			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; | 			versionNum = 0; | ||||||
| 		} | 		} | ||||||
| 		CloseHandle(versionFile); | 		CloseHandle(versionFile); | ||||||
|  | @ -242,14 +242,14 @@ bool update() { | ||||||
| 			int copyTries = 0; | 			int copyTries = 0; | ||||||
| 			do { | 			do { | ||||||
| 				copyResult = CopyFile(fname.c_str(), tofname.c_str(), FALSE); | 				copyResult = CopyFile(fname.c_str(), tofname.c_str(), FALSE); | ||||||
| 				if (copyResult == FALSE) { | 				if (!copyResult) { | ||||||
| 					++copyTries; | 					++copyTries; | ||||||
| 					Sleep(100); | 					Sleep(100); | ||||||
| 				} else { | 				} else { | ||||||
| 					break; | 					break; | ||||||
| 				} | 				} | ||||||
| 			} while (copyTries < 30); | 			} while (copyTries < 30); | ||||||
| 			if (copyResult == FALSE) { | 			if (!copyResult) { | ||||||
| 				writeLog(L"Error: failed to copy, asking to retry.."); | 				writeLog(L"Error: failed to copy, asking to retry.."); | ||||||
| 				WCHAR errMsg[2048]; | 				WCHAR errMsg[2048]; | ||||||
| 				wsprintf(errMsg, L"Failed to update Telegram :(\n%s is not accessible.", tofname); | 				wsprintf(errMsg, L"Failed to update Telegram :(\n%s is not accessible.", tofname); | ||||||
|  | @ -258,7 +258,7 @@ bool update() { | ||||||
| 					return false; | 					return false; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		} while (copyResult == FALSE); | 		} while (!copyResult); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	writeLog(L"Update succeed! Clearing folder.."); | 	writeLog(L"Update succeed! Clearing folder.."); | ||||||
|  | @ -289,7 +289,7 @@ void updateRegistry() { | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 				if (locationType == REG_EXPAND_SZ || locationType == REG_SZ) { | 				if (locationType == REG_EXPAND_SZ || locationType == REG_SZ) { | ||||||
| 					if (PathCanonicalize(exp, locationStr) == TRUE) { | 					if (PathCanonicalize(exp, locationStr)) { | ||||||
| 						memcpy(locationStr, exp, bufSize * sizeof(WCHAR)); | 						memcpy(locationStr, exp, bufSize * sizeof(WCHAR)); | ||||||
| 						if (GetFullPathName(L".", bufSize, exp, 0) < bufSize) { | 						if (GetFullPathName(L".", bufSize, exp, 0) < bufSize) { | ||||||
| 							wstring installpath = locationStr, mypath = exp; | 							wstring installpath = locationStr, mypath = exp; | ||||||
|  | @ -323,7 +323,7 @@ void updateRegistry() { | ||||||
| 
 | 
 | ||||||
| #include <ShlObj.h> | #include <ShlObj.h> | ||||||
| 
 | 
 | ||||||
| int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParamarg, int cmdShow) { | int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR cmdParamarg, int cmdShow) { | ||||||
| 	openLog(); | 	openLog(); | ||||||
| 
 | 
 | ||||||
| #ifdef _NEED_WIN_GENERATE_DUMP | #ifdef _NEED_WIN_GENERATE_DUMP | ||||||
|  |  | ||||||
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Roman Shchekin
						Roman Shchekin