From 2bdd151424c835908851394f99f8a57e325dfd06 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Mon, 2 Jul 2012 18:54:39 +0000 Subject: Restarting miranda now really restart it git-svn-id: http://svn.miranda-ng.org/main/trunk@724 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/utils/utils.cpp | 50 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/modules/utils/utils.cpp b/src/modules/utils/utils.cpp index bb0a60c67f..4af0230071 100644 --- a/src/modules/utils/utils.cpp +++ b/src/modules/utils/utils.cpp @@ -375,7 +375,6 @@ static INT_PTR AssertInsideScreen(WPARAM wParam, LPARAM lParam) return 1; } - static INT_PTR RestoreWindowPosition(WPARAM wParam, LPARAM lParam) { SAVEWINDOWPOS *swp=(SAVEWINDOWPOS*)lParam; @@ -415,7 +414,6 @@ static INT_PTR RestoreWindowPosition(WPARAM wParam, LPARAM lParam) } ///////////////////////////////////////////////////////////////////////////////////////// - static INT_PTR RestartMiranda(WPARAM, LPARAM) { TCHAR mirandaPath[ MAX_PATH ], cmdLine[ 100 ]; @@ -424,6 +422,7 @@ static INT_PTR RestartMiranda(WPARAM, LPARAM) si.cb = sizeof(si); GetModuleFileName(NULL, mirandaPath, SIZEOF(mirandaPath)); mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T("/restart:%d"), GetCurrentProcessId()); + CallService("CloseAction", 0, 0); CreateProcess(mirandaPath, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); return 0; } @@ -434,33 +433,32 @@ typedef BOOL (APIENTRY *PGENRANDOM)(PVOID, ULONG); static INT_PTR GenerateRandom(WPARAM wParam, LPARAM lParam) { - if (wParam == 0 || lParam == 0) return 0; - - PGENRANDOM pfnRtlGenRandom = NULL; - HMODULE hModule = GetModuleHandleA("advapi32"); - if (hModule) - { - pfnRtlGenRandom = (PGENRANDOM)GetProcAddress(hModule, "SystemFunction036"); - if (pfnRtlGenRandom) - { - if ( !pfnRtlGenRandom((PVOID)lParam, wParam)) - pfnRtlGenRandom = NULL; - } - } - if (pfnRtlGenRandom == NULL) - { - srand(GetTickCount()); - unsigned short* buf = (unsigned short*)lParam; - for (; (long)(wParam-=2) >= 0;) - *(buf++) = (unsigned short)rand(); - if (lParam < 0) - *(char*)buf = (char)(rand() & 0xFF); - } - return 0; + if (wParam == 0 || lParam == 0) return 0; + + PGENRANDOM pfnRtlGenRandom = NULL; + HMODULE hModule = GetModuleHandleA("advapi32"); + if (hModule) + { + pfnRtlGenRandom = (PGENRANDOM)GetProcAddress(hModule, "SystemFunction036"); + if (pfnRtlGenRandom) + { + if ( !pfnRtlGenRandom((PVOID)lParam, wParam)) + pfnRtlGenRandom = NULL; + } + } + if (pfnRtlGenRandom == NULL) + { + srand(GetTickCount()); + unsigned short* buf = (unsigned short*)lParam; + for (; (long)(wParam-=2) >= 0;) + *(buf++) = (unsigned short)rand(); + if (lParam < 0) + *(char*)buf = (char)(rand() & 0xFF); + } + return 0; } ///////////////////////////////////////////////////////////////////////////////////////// - int LoadUtilsModule(void) { bModuleInitialized = TRUE; -- cgit v1.2.3