mirror of
https://github.com/LegacyUpdate/LegacyUpdate.git
synced 2025-01-22 22:22:20 -05:00
Check if the ActiveX control is registered on launch
This commit is contained in:
parent
9a934c765d
commit
41d6d7ec57
3 changed files with 40 additions and 9 deletions
|
@ -7,15 +7,19 @@
|
|||
#include <wchar.h>
|
||||
#include "Exec.h"
|
||||
#include "HResult.h"
|
||||
#include "MsgBox.h"
|
||||
#include "Registry.h"
|
||||
#include "RegisterServer.h"
|
||||
#include "User.h"
|
||||
#include "VersionInfo.h"
|
||||
#include "MsgBox.h"
|
||||
|
||||
const LPTSTR UpdateSiteURLHttp = L"http://legacyupdate.net/windowsupdate/v6/";
|
||||
const LPTSTR UpdateSiteURLHttps = L"https://legacyupdate.net/windowsupdate/v6/";
|
||||
const LPTSTR UpdateSiteFirstRunFlag = L"?firstrun=true";
|
||||
|
||||
DEFINE_GUID(IID_ILegacyUpdateCtrl, 0xC33085BB, 0xC3E1, 0x4D27, 0xA2, 0x14, 0xAF, 0x01, 0x95, 0x3D, 0xF5, 0xE5);
|
||||
DEFINE_GUID(CLSID_LegacyUpdateCtrl, 0xAD28E0DF, 0x5F5A, 0x40B5, 0x94, 0x32, 0x85, 0xEF, 0xD9, 0x7D, 0x1F, 0x9F);
|
||||
|
||||
static BOOL CanUseSSLConnection() {
|
||||
// Get the Windows Update website URL set by Legacy Update setup
|
||||
LPWSTR data;
|
||||
|
@ -54,15 +58,33 @@ void LaunchUpdateSite(int argc, LPWSTR *argv, int nCmdShow) {
|
|||
// If running on 2k/XP, make sure we're elevated. If not, show Run As prompt.
|
||||
if (!IsOSVersionOrLater(6, 0) && !IsUserAdmin()) {
|
||||
LPWSTR filename;
|
||||
DWORD filenameSize;
|
||||
GetOwnFileName(&filename, &filenameSize);
|
||||
|
||||
INT_PTR execResult = (INT_PTR)ShellExecute(NULL, L"runas", filename, GetCommandLineW(), NULL, nCmdShow);
|
||||
GetOwnFileName(&filename);
|
||||
hr = Exec(L"runas", filename, GetCommandLineW(), NULL, nCmdShow, FALSE, NULL);
|
||||
LocalFree(filename);
|
||||
|
||||
// Access denied happens when the user clicks No/Cancel.
|
||||
if (execResult <= 32 && execResult != SE_ERR_ACCESSDENIED) {
|
||||
hr = HRESULT_FROM_WIN32(GetLastError());
|
||||
if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED)) {
|
||||
hr = S_OK;
|
||||
}
|
||||
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Can we instantiate our own ActiveX control? If not, try to register it.
|
||||
hr = CoCreateInstance(&CLSID_LegacyUpdateCtrl, NULL, CLSCTX_LOCAL_SERVER, &IID_ILegacyUpdateCtrl, (void **)&browser);
|
||||
if (hr == REGDB_E_CLASSNOTREG) {
|
||||
hr = RegisterServer(TRUE, TRUE);
|
||||
if (!SUCCEEDED(hr)) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
hr = CoCreateInstance(&CLSID_LegacyUpdateCtrl, NULL, CLSCTX_LOCAL_SERVER, &IID_ILegacyUpdateCtrl, (void **)&browser);
|
||||
if (!SUCCEEDED(hr)) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
IUnknown_Release(browser);
|
||||
} else if (!SUCCEEDED(hr)) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ HRESULT RegisterDll(LPWSTR path, BOOL state) {
|
|||
return status == 0 ? S_OK : E_FAIL;
|
||||
}
|
||||
|
||||
void RegisterServer(BOOL state) {
|
||||
HRESULT RegisterServer(BOOL state, BOOL forLaunch) {
|
||||
// Ensure elevation
|
||||
HRESULT hr = S_OK;
|
||||
LPWSTR installPath;
|
||||
|
@ -96,5 +96,9 @@ end:
|
|||
MsgBox(NULL, title, /*GetMessageForHresult(hr)*/ text, MB_OK | MB_ICONERROR);
|
||||
}
|
||||
|
||||
PostQuitMessage(hr);
|
||||
if (!forLaunch) {
|
||||
PostQuitMessage(hr);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
|
5
launcher/RegisterServer.h
Normal file
5
launcher/RegisterServer.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
HRESULT RegisterServer(BOOL state, BOOL forLaunch);
|
Loading…
Reference in a new issue