From 831067a0bad76972d1f4739c14e858bb053a8042 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 25 Oct 2012 19:14:12 +0000 Subject: more correct way of copying skypekit git-svn-id: http://svn.miranda-ng.org/main/trunk@2078 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype.cpp | 64 ++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/protocols/Skype/src/skype.cpp b/protocols/Skype/src/skype.cpp index cc93390ec5..80ba931a6b 100644 --- a/protocols/Skype/src/skype.cpp +++ b/protocols/Skype/src/skype.cpp @@ -174,43 +174,45 @@ int StartSkypeRuntime() mir_sntprintf(szFilename, SIZEOF(szFilename), _T("%s\\%s"), szFilename, _T("SkypeKit.exe")); if (!PathFileExists(szFilename)) { - // Check the current process's "run as administrator" status. - // Elevate the process if it is not run as administrator. - if (!IsRunAsAdmin()) - { - wchar_t szPath[MAX_PATH], cmdLine[100]; - GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath)); - TCHAR *profilename = Utils_ReplaceVarsT(_T("%miranda_profilename%")); - mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T(" /restart:%d /profile=%s"), GetCurrentProcessId(), profilename); - // Launch itself as administrator. - SHELLEXECUTEINFO sei = { sizeof(sei) }; - sei.lpVerb = L"runas"; - sei.lpFile = szPath; - sei.lpParameters = cmdLine; - //sei.hwnd = hDlg; - sei.nShow = SW_NORMAL; - - if (!ShellExecuteEx(&sei)) - { - DWORD dwError = GetLastError(); - if (dwError == ERROR_CANCELLED) - { - // The user refused to allow privileges elevation. - // Do nothing ... - } - } - else - { - //DestroyWindow(hDlg); // Quit itself - CallService("CloseAction", 0, 0); - } - } if ((hFile = CreateFile(szFilename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)) != INVALID_HANDLE_VALUE) { WriteFile(hFile, (void *)pData, dwSize, &written, NULL); CloseHandle(hFile); } else + { + // Check the current process's "run as administrator" status. + // Elevate the process if it is not run as administrator. + if (!IsRunAsAdmin()) + { + wchar_t szPath[MAX_PATH], cmdLine[100]; + GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath)); + TCHAR *profilename = Utils_ReplaceVarsT(_T("%miranda_profilename%")); + mir_sntprintf(cmdLine, SIZEOF(cmdLine), _T(" /restart:%d /profile=%s"), GetCurrentProcessId(), profilename); + // Launch itself as administrator. + SHELLEXECUTEINFO sei = { sizeof(sei) }; + sei.lpVerb = L"runas"; + sei.lpFile = szPath; + sei.lpParameters = cmdLine; + //sei.hwnd = hDlg; + sei.nShow = SW_NORMAL; + + if (!ShellExecuteEx(&sei)) + { + DWORD dwError = GetLastError(); + if (dwError == ERROR_CANCELLED) + { + // The user refused to allow privileges elevation. + // Do nothing ... + } + } + else + { + //DestroyWindow(hDlg); // Quit itself + CallService("CloseAction", 0, 0); + } + } return 0; + } } } } -- cgit v1.2.3