diff options
Diffstat (limited to 'src/ext/Bal/Samples/bafunctions/WixSampleBAFunctions.cpp')
| -rw-r--r-- | src/ext/Bal/Samples/bafunctions/WixSampleBAFunctions.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/ext/Bal/Samples/bafunctions/WixSampleBAFunctions.cpp b/src/ext/Bal/Samples/bafunctions/WixSampleBAFunctions.cpp new file mode 100644 index 00000000..531b86a3 --- /dev/null +++ b/src/ext/Bal/Samples/bafunctions/WixSampleBAFunctions.cpp | |||
| @@ -0,0 +1,95 @@ | |||
| 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 fInstalled, | ||
| 12 | __in DWORD cPackages, | ||
| 13 | __inout BOOL* pfCancel | ||
| 14 | ) | ||
| 15 | { | ||
| 16 | HRESULT hr = S_OK; | ||
| 17 | |||
| 18 | BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Running detect begin BA function. fInstalled=%d, cPackages=%u, fCancel=%d", fInstalled, cPackages, *pfCancel); | ||
| 19 | |||
| 20 | //------------------------------------------------------------------------------------------------- | ||
| 21 | // YOUR CODE GOES HERE | ||
| 22 | BalExitOnFailure(hr, "Change this message to represent real error handling."); | ||
| 23 | //------------------------------------------------------------------------------------------------- | ||
| 24 | |||
| 25 | LExit: | ||
| 26 | return hr; | ||
| 27 | } | ||
| 28 | |||
| 29 | public: // IBAFunctions | ||
| 30 | virtual STDMETHODIMP OnPlanBegin( | ||
| 31 | __in DWORD cPackages, | ||
| 32 | __inout BOOL* pfCancel | ||
| 33 | ) | ||
| 34 | { | ||
| 35 | HRESULT hr = S_OK; | ||
| 36 | |||
| 37 | BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Running plan begin BA function. cPackages=%u, fCancel=%d", cPackages, *pfCancel); | ||
| 38 | |||
| 39 | //------------------------------------------------------------------------------------------------- | ||
| 40 | // YOUR CODE GOES HERE | ||
| 41 | BalExitOnFailure(hr, "Change this message to represent real error handling."); | ||
| 42 | //------------------------------------------------------------------------------------------------- | ||
| 43 | |||
| 44 | LExit: | ||
| 45 | return hr; | ||
| 46 | } | ||
| 47 | |||
| 48 | public: | ||
| 49 | // | ||
| 50 | // Constructor - initialize member variables. | ||
| 51 | // | ||
| 52 | CWixSampleBAFunctions( | ||
| 53 | __in HMODULE hModule, | ||
| 54 | __in IBootstrapperEngine* pEngine, | ||
| 55 | __in const BA_FUNCTIONS_CREATE_ARGS* pArgs | ||
| 56 | ) : CBalBaseBAFunctions(hModule, pEngine, pArgs) | ||
| 57 | { | ||
| 58 | } | ||
| 59 | |||
| 60 | // | ||
| 61 | // Destructor - release member variables. | ||
| 62 | // | ||
| 63 | ~CWixSampleBAFunctions() | ||
| 64 | { | ||
| 65 | } | ||
| 66 | }; | ||
| 67 | |||
| 68 | |||
| 69 | HRESULT WINAPI CreateBAFunctions( | ||
| 70 | __in HMODULE hModule, | ||
| 71 | __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, | ||
| 72 | __inout BA_FUNCTIONS_CREATE_RESULTS* pResults | ||
| 73 | ) | ||
| 74 | { | ||
| 75 | HRESULT hr = S_OK; | ||
| 76 | CWixSampleBAFunctions* pBAFunctions = NULL; | ||
| 77 | IBootstrapperEngine* pEngine = NULL; | ||
| 78 | |||
| 79 | // This is required to enable logging functions. | ||
| 80 | hr = BalInitializeFromCreateArgs(pArgs->pBootstrapperCreateArgs, &pEngine); | ||
| 81 | ExitOnFailure(hr, "Failed to initialize Bal."); | ||
| 82 | |||
| 83 | pBAFunctions = new CWixSampleBAFunctions(hModule, pEngine, pArgs); | ||
| 84 | ExitOnNull(pBAFunctions, hr, E_OUTOFMEMORY, "Failed to create new CWixSampleBAFunctions object."); | ||
| 85 | |||
| 86 | pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc; | ||
| 87 | pResults->pvBAFunctionsProcContext = pBAFunctions; | ||
| 88 | pBAFunctions = NULL; | ||
| 89 | |||
| 90 | LExit: | ||
| 91 | ReleaseObject(pBAFunctions); | ||
| 92 | ReleaseObject(pEngine); | ||
| 93 | |||
| 94 | return hr; | ||
| 95 | } | ||
