main
cpp 93 lines 2.58 KB
Raw
1 // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3 #include "precomp.h"
4 #include "BalBaseBAFunctions.h"
5 #include "BalBaseBAFunctionsProc.h"
6
7 const LPCWSTR STRING_VARIABLE = L"AString";
8 const LPCWSTR NUMBER_VARIABLE = L"ANumber";
9
10 class CBafRelatedBundleVariableTesting : public CBalBaseBAFunctions
11 {
12 public: // IBAFunctions
13
14
15 public: //IBootstrapperApplication
16 virtual STDMETHODIMP OnDetectRelatedBundle(
17 __in_z LPCWSTR wzBundleId,
18 __in BOOTSTRAPPER_RELATION_TYPE relationType,
19 __in_z LPCWSTR wzBundleTag,
20 __in BOOL fPerMachine,
21 __in LPCWSTR wzVersion,
22 __in BOOL fMissingFromCache,
23 __inout BOOL* pfCancel
24 )
25 {
26
27 HRESULT hr = S_OK;
28 LPWSTR wzValue = NULL;
29
30 hr = BalGetRelatedBundleVariable(wzBundleId, STRING_VARIABLE, &wzValue);
31
32 BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieved related bundle variable with BAFunctions: AString = %ws, Error: 0x%x", wzValue, hr);
33
34 hr = BalGetRelatedBundleVariable(wzBundleId, NUMBER_VARIABLE, &wzValue);
35
36 BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieved related bundle variable with BAFunctions: ANumber = %ws, Error: 0x%x", wzValue, hr);
37
38 hr = __super::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, pfCancel);
39
40 ReleaseStr(wzValue);
41 return hr;
42 }
43
44 private:
45
46
47 public:
48 //
49 // Constructor - initialize member variables.
50 //
51 CBafRelatedBundleVariableTesting(
52 __in HMODULE hModule
53 ) : CBalBaseBAFunctions(hModule)
54 {
55 }
56
57 //
58 // Destructor - release member variables.
59 //
60 ~CBafRelatedBundleVariableTesting()
61 {
62 }
63
64 private:
65 };
66
67
68 HRESULT WINAPI CreateBAFunctions(
69 __in HMODULE hModule,
70 __in const BA_FUNCTIONS_CREATE_ARGS* pArgs,
71 __inout BA_FUNCTIONS_CREATE_RESULTS* pResults
72 )
73 {
74 HRESULT hr = S_OK;
75 CBafRelatedBundleVariableTesting* pBAFunctions = NULL;
76
77 BalInitialize(pArgs->pEngine);
78
79 pBAFunctions = new CBafRelatedBundleVariableTesting(hModule);
80 ExitOnNull(pBAFunctions, hr, E_OUTOFMEMORY, "Failed to create new CBafRelatedBundleVariableTesting object.");
81
82 hr = pBAFunctions->OnCreate(pArgs->pEngine, pArgs->pCommand);
83 ExitOnFailure(hr, "Failed to create BA function");
84
85 pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc;
86 pResults->pvBAFunctionsProcContext = pBAFunctions;
87 pBAFunctions = NULL;
88
89 LExit:
90 ReleaseObject(pBAFunctions);
91
92 return hr;
93 }