| 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 | class CWixSampleBAFunctions : public CBalBaseBAFunctions |
| 8 | { |
| 9 | public: // IBootstrapperApplication |
| 10 | virtual STDMETHODIMP OnDetectBegin( |
| 11 | __in BOOL fCached, |
| 12 | __in BOOTSTRAPPER_REGISTRATION_TYPE registrationType, |
| 13 | __in DWORD cPackages, |
| 14 | __inout BOOL* pfCancel |
| 15 | ) |
| 16 | { |
| 17 | HRESULT hr = S_OK; |
| 18 | |
| 19 | BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Running detect begin BA function. fCached=%d, registrationType=%d, cPackages=%u, fCancel=%d", fCached, registrationType, cPackages, *pfCancel); |
| 20 | |
| 21 | //------------------------------------------------------------------------------------------------- |
| 22 | // YOUR CODE GOES HERE |
| 23 | BalExitOnFailure(hr, "Change this message to represent real error handling."); |
| 24 | //------------------------------------------------------------------------------------------------- |
| 25 | |
| 26 | LExit: |
| 27 | return hr; |
| 28 | } |
| 29 | |
| 30 | public: // IBAFunctions |
| 31 | virtual STDMETHODIMP OnPlanBegin( |
| 32 | __in DWORD cPackages, |
| 33 | __inout BOOL* pfCancel |
| 34 | ) |
| 35 | { |
| 36 | HRESULT hr = S_OK; |
| 37 | |
| 38 | BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Running plan begin BA function. cPackages=%u, fCancel=%d", cPackages, *pfCancel); |
| 39 | |
| 40 | //------------------------------------------------------------------------------------------------- |
| 41 | // YOUR CODE GOES HERE |
| 42 | BalExitOnFailure(hr, "Change this message to represent real error handling."); |
| 43 | //------------------------------------------------------------------------------------------------- |
| 44 | |
| 45 | LExit: |
| 46 | return hr; |
| 47 | } |
| 48 | |
| 49 | public: |
| 50 | // |
| 51 | // Constructor - initialize member variables. |
| 52 | // |
| 53 | CWixSampleBAFunctions( |
| 54 | __in HMODULE hModule |
| 55 | ) : CBalBaseBAFunctions(hModule) |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | // |
| 60 | // Destructor - release member variables. |
| 61 | // |
| 62 | ~CWixSampleBAFunctions() |
| 63 | { |
| 64 | } |
| 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 | CWixSampleBAFunctions* pBAFunctions = NULL; |
| 76 | |
| 77 | pBAFunctions = new CWixSampleBAFunctions(hModule); |
| 78 | ExitOnNull(pBAFunctions, hr, E_OUTOFMEMORY, "Failed to create new CWixSampleBAFunctions object."); |
| 79 | |
| 80 | hr = pBAFunctions->OnCreate(pArgs->pEngine, pArgs->pCommand); |
| 81 | ExitOnFailure(hr, "Failed to call OnCreate CPrereqBaf."); |
| 82 | |
| 83 | pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc; |
| 84 | pResults->pvBAFunctionsProcContext = pBAFunctions; |
| 85 | pBAFunctions = NULL; |
| 86 | |
| 87 | LExit: |
| 88 | ReleaseObject(pBAFunctions); |
| 89 | |
| 90 | return hr; |
| 91 | } |