From 9520538df4328f38ab55d6032e9679e6627da850 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 5 Mar 2013 19:07:01 +0000 Subject: fix for running PU under Miranda IM git-svn-id: http://svn.miranda-ng.org/main/trunk@3900 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/PluginUpdater/src/Utils.cpp | 42 +++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'plugins/PluginUpdater/src') diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 89d817a06f..4d169825f2 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -175,19 +175,6 @@ int Get_CRC(unsigned char* buffer, ULONG bufsize) return crc^0xffffffff; } -long FileSize(FILE *input) -{ - - long fileSizeBytes; - fseek(input, 0, SEEK_END); - fileSizeBytes = ftell(input); - fseek(input, 0, SEEK_SET); - - return fileSizeBytes; - - -} - BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal, int CRCsum) { DWORD dwBytes; @@ -259,11 +246,6 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal, int CRCsum) return ret; } -void __stdcall RestartMe(void*) -{ - CallService(MS_SYSTEM_RESTART, db_get_b(NULL,MODNAME,"RestartCurrentProfile",1) ? 1 : 0, 0); -} - ///////////////////////////////////////////////////////////////////////////////////////// BOOL AllowUpdateOnStartup() @@ -355,6 +337,30 @@ void CreatePathToFileT(TCHAR* tszFilePath) CreateDirectoryTreeT(tszFilePath); *pszLastBackslash = '\\'; } + +void __stdcall RestartMe(void*) +{ + TCHAR mirandaPath[MAX_PATH], cmdLine[MAX_PATH]; + GetModuleFileName(NULL, mirandaPath, SIZEOF(mirandaPath)); + + TCHAR *profilename = Utils_ReplaceVarsT(_T("%miranda_profilename%")); + mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("\"%s\" /restart:%d /profile=%s"), mirandaPath, GetCurrentProcessId(), profilename); + mir_free(profilename); + + CallService("CloseAction", 0, 0); + + PROCESS_INFORMATION pi; + STARTUPINFO si = { sizeof(si) }; + CreateProcess(mirandaPath, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); +} + +#else + +void __stdcall RestartMe(void*) +{ + CallService(MS_SYSTEM_RESTART, db_get_b(NULL,MODNAME,"RestartCurrentProfile",1) ? 1 : 0, 0); +} + #endif // FUNCTION: IsRunAsAdmin() -- cgit v1.2.3