aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Bal/Samples/bafunctions/Readme.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/ext/Bal/Samples/bafunctions/Readme.txt')
-rw-r--r--src/ext/Bal/Samples/bafunctions/Readme.txt85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/ext/Bal/Samples/bafunctions/Readme.txt b/src/ext/Bal/Samples/bafunctions/Readme.txt
new file mode 100644
index 00000000..517d0d4c
--- /dev/null
+++ b/src/ext/Bal/Samples/bafunctions/Readme.txt
@@ -0,0 +1,85 @@
1
2This is a sample project showing how to create a BA function assembly.
3
4The four interfaces are in the WixSampleBAFunctions.cpp file.
5
6
7Example code:
8~~~~~~~~~~~~~
9
10
11 HRESULT hr = S_OK;
12 HKEY hkKey = NULL;
13 LPWSTR sczValue = NULL;
14 LPWSTR sczFormatedValue = NULL;
15
16
17 //---------------------------------------------------------------------------------------------
18 // Example of BA function failure
19 hr = E_NOTIMPL;
20 BalExitOnFailure(hr, "Test failure.");
21 //---------------------------------------------------------------------------------------------
22
23 //---------------------------------------------------------------------------------------------
24 // Example of setting a variables
25 hr = m_pEngine->SetVariableString(L"Variable1", L"String value");
26 BalExitOnFailure(hr, "Failed to set variable.");
27 hr = m_pEngine->SetVariableNumeric(L"Variable2", 1234);
28 BalExitOnFailure(hr, "Failed to set variable.");
29 //---------------------------------------------------------------------------------------------
30
31 //---------------------------------------------------------------------------------------------
32 // Example of reading burn variable.
33 BalGetStringVariable(L"WixBundleName", &sczValue);
34 BalExitOnFailure(hr, "Failed to get variable.");
35
36 hr = m_pEngine->SetVariableString(L"Variable4", sczValue);
37 BalExitOnFailure(hr, "Failed to set variable.");
38 //---------------------------------------------------------------------------------------------
39
40 ReleaseNullStr(sczValue); // Release string so it can be re-used
41
42 //---------------------------------------------------------------------------------------------
43 // Examples of reading burn variable and formatting it.
44 BalGetStringVariable(L"InstallFolder", &sczValue);
45 BalExitOnFailure(hr, "Failed to get variable.");
46
47 hr = m_pEngine->SetVariableString(L"Variable5", sczValue);
48 BalExitOnFailure(hr, "Failed to set variable.");
49
50 BalFormatString(sczValue, &sczFormatedValue);
51 BalExitOnFailure(hr, "Failed to format variable.");
52
53 hr = m_pEngine->SetVariableString(L"Variable6", sczFormatedValue);
54 BalExitOnFailure(hr, "Failed to set variable.");
55 //---------------------------------------------------------------------------------------------
56
57 ReleaseNullStr(sczValue); // Release string so it can be re-used
58
59 //---------------------------------------------------------------------------------------------
60 // Example of reading 64 bit registry and setting the InstallFolder variable to the value read.
61 hr = RegOpen(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v3.5", KEY_READ | KEY_WOW64_64KEY, &hkKey);
62 BalExitOnFailure(hr, "Failed to open registry key.");
63
64 hr = RegReadString(hkKey, L"InstallPath", &sczValue);
65 BalExitOnFailure(hr, "Failed to read registry value.");
66
67 // Example of function call
68 PathBackslashTerminate(&sczValue);
69
70 hr = m_pEngine->SetVariableString(L"InstallFolder", sczValue);
71 BalExitOnFailure(hr, "Failed to set variable.");
72 //---------------------------------------------------------------------------------------------
73
74 ReleaseNullStr(sczValue); // Release string so it can be re-used
75
76 //---------------------------------------------------------------------------------------------
77 // Example of calling a function that return HRESULT
78 hr = GetFileVersion();
79 BalExitOnFailure(hr, "Failed to get version.");
80 //---------------------------------------------------------------------------------------------
81
82 LExit:
83 ReleaseRegKey(hkKey);
84 ReleaseStr(sczValue);
85 ReleaseStr(sczFormatedValue);