diff options
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/polcutil.cpp')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/polcutil.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/polcutil.cpp b/src/libs/dutil/WixToolset.DUtil/polcutil.cpp index 1fdfa18c..c2247bc1 100644 --- a/src/libs/dutil/WixToolset.DUtil/polcutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/polcutil.cpp | |||
@@ -102,6 +102,49 @@ LExit: | |||
102 | return hr; | 102 | return hr; |
103 | } | 103 | } |
104 | 104 | ||
105 | extern "C" HRESULT DAPI PolcReadUnexpandedString( | ||
106 | __in_z LPCWSTR wzPolicyPath, | ||
107 | __in_z LPCWSTR wzPolicyName, | ||
108 | __in_z_opt LPCWSTR wzDefault, | ||
109 | __inout BOOL* pfNeedsExpansion, | ||
110 | __deref_out_z LPWSTR* pscz | ||
111 | ) | ||
112 | { | ||
113 | HRESULT hr = S_OK; | ||
114 | HKEY hk = NULL; | ||
115 | |||
116 | hr = OpenPolicyKey(wzPolicyPath, &hk); | ||
117 | if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) | ||
118 | { | ||
119 | ExitFunction1(hr = S_FALSE); | ||
120 | } | ||
121 | PolcExitOnFailure(hr, "Failed to open policy key: %ls", wzPolicyPath); | ||
122 | |||
123 | hr = RegReadUnexpandedString(hk, wzPolicyName, pfNeedsExpansion, pscz); | ||
124 | if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) | ||
125 | { | ||
126 | ExitFunction1(hr = S_FALSE); | ||
127 | } | ||
128 | PolcExitOnFailure(hr, "Failed to open policy key: %ls, name: %ls", wzPolicyPath, wzPolicyName); | ||
129 | |||
130 | LExit: | ||
131 | ReleaseRegKey(hk); | ||
132 | |||
133 | if (S_FALSE == hr || FAILED(hr)) | ||
134 | { | ||
135 | if (NULL == wzDefault) | ||
136 | { | ||
137 | ReleaseNullStr(*pscz); | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | hr = StrAllocString(pscz, wzDefault, 0); | ||
142 | } | ||
143 | } | ||
144 | |||
145 | return hr; | ||
146 | } | ||
147 | |||
105 | 148 | ||
106 | // internal functions | 149 | // internal functions |
107 | 150 | ||