forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
90 lines (78 loc) · 3.2 KB
/
Copy pathmain.cpp
File metadata and controls
90 lines (78 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include <wil/result_macros.h>
#pragma warning( push )
#pragma warning ( disable : 4324 )
#include <wrl/module.h>
#pragma warning( pop )
#include <winrt/Microsoft.Management.Deployment.h>
#include "WindowsPackageManager.h"
#include <AppInstallerCLICore.h>
#include <ComClsids.h>
using namespace winrt::Microsoft::Management::Deployment;
// CreatorMap for out-of-proc com registration and direct in-proc com class construction
CoCreatableClassWrlCreatorMapInclude(PackageManager);
CoCreatableClassWrlCreatorMapInclude(FindPackagesOptions);
CoCreatableClassWrlCreatorMapInclude(CreateCompositePackageCatalogOptions);
CoCreatableClassWrlCreatorMapInclude(InstallOptions);
CoCreatableClassWrlCreatorMapInclude(UninstallOptions);
CoCreatableClassWrlCreatorMapInclude(PackageMatchFilter);
CoCreatableClassWrlCreatorMapInclude(PackageManagerSettings);
extern "C"
{
int WINDOWS_PACKAGE_MANAGER_API_CALLING_CONVENTION WindowsPackageManagerCLIMain(int argc, wchar_t const** argv) try
{
::Microsoft::WRL::Module<::Microsoft::WRL::ModuleType::InProc>::Create();
return AppInstaller::CLI::CoreMain(argc, argv);
}
CATCH_RETURN();
WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerServerInitialize() try
{
AppInstaller::CLI::ServerInitialize();
return S_OK;
}
CATCH_RETURN();
WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerServerModuleCreate(WindowsPackageManagerServerModuleTerminationCallback callback) try
{
::Microsoft::WRL::Module<::Microsoft::WRL::ModuleType::OutOfProc>::Create(callback);
return S_OK;
}
CATCH_RETURN();
WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerServerModuleRegister() try
{
RETURN_HR(::Microsoft::WRL::Module<::Microsoft::WRL::ModuleType::OutOfProc>::GetModule().RegisterObjects());
}
CATCH_RETURN();
WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerServerModuleUnregister() try
{
RETURN_HR(::Microsoft::WRL::Module<::Microsoft::WRL::ModuleType::OutOfProc>::GetModule().UnregisterObjects());
}
CATCH_RETURN();
WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerInProcModuleInitialize() try
{
::Microsoft::WRL::Module<::Microsoft::WRL::ModuleType::InProc>::Create();
return S_OK;
}
CATCH_RETURN();
bool WINDOWS_PACKAGE_MANAGER_API_CALLING_CONVENTION WindowsPackageManagerInProcModuleTerminate()
{
try
{
return ::Microsoft::WRL::Module<::Microsoft::WRL::ModuleType::InProc>::GetModule().Terminate();
}
catch (...)
{
return false;
}
}
WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerInProcModuleGetClassObject(
REFCLSID rclsid,
REFIID riid,
LPVOID* ppv) try
{
CLSID redirectedClsid = GetRedirectedClsidFromInProcClsid(rclsid);
RETURN_HR_IF(CLASS_E_CLASSNOTAVAILABLE, IsEqualCLSID(redirectedClsid, CLSID_NULL));
RETURN_HR(::Microsoft::WRL::Module<::Microsoft::WRL::ModuleType::InProc>::GetModule().GetClassObject(redirectedClsid, riid, ppv));
}
CATCH_RETURN();
}