mirror of
https://github.com/LegacyUpdate/LegacyUpdate.git
synced 2025-01-22 06:01:50 -05:00
35 lines
1,008 B
C
35 lines
1,008 B
C
#include <windows.h>
|
|
#include <nsis/pluginapi.h>
|
|
#include <wuapi.h>
|
|
#include "main.h"
|
|
|
|
static const LPWSTR MicrosoftUpdateServiceID = L"7971f918-a847-4430-9279-4a52d1efe18d";
|
|
|
|
PLUGIN_METHOD(EnableMicrosoftUpdate) {
|
|
PLUGIN_INIT();
|
|
|
|
IUpdateServiceManager2 *serviceManager;
|
|
IUpdateServiceRegistration *registration;
|
|
|
|
HRESULT hr = CoCreateInstance(&CLSID_UpdateServiceManager, NULL, CLSCTX_INPROC_SERVER, &IID_IUpdateServiceManager2, (void **)&serviceManager);
|
|
if (!SUCCEEDED(hr)) {
|
|
goto end;
|
|
}
|
|
|
|
BSTR serviceID = SysAllocString(MicrosoftUpdateServiceID);
|
|
BSTR serviceCab = SysAllocString(L"");
|
|
hr = IUpdateServiceManager2_AddService2(serviceManager, serviceID, asfAllowPendingRegistration | asfAllowOnlineRegistration | asfRegisterServiceWithAU, serviceCab, ®istration);
|
|
SysFreeString(serviceID);
|
|
SysFreeString(serviceCab);
|
|
|
|
end:
|
|
if (registration) {
|
|
IUpdateServiceManager2_Release(registration);
|
|
}
|
|
|
|
if (serviceManager) {
|
|
IUpdateServiceManager2_Release(serviceManager);
|
|
}
|
|
|
|
pushint(hr);
|
|
}
|