OLD | NEW |
(Empty) | |
| 1 #pragma once |
| 2 //------------------------------------------------------------------------------
------------------- |
| 3 // <copyright file="wcautil.h" company="Outercurve Foundation"> |
| 4 // Copyright (c) 2004, Outercurve Foundation. |
| 5 // This software is released under Microsoft Reciprocal License (MS-RL). |
| 6 // The license and further copyright text can be found in the file |
| 7 // LICENSE.TXT at the root directory of the distribution. |
| 8 // </copyright> |
| 9 // |
| 10 // <summary> |
| 11 // Windows Installer XML CustomAction utility library. |
| 12 // </summary> |
| 13 //------------------------------------------------------------------------------
------------------- |
| 14 |
| 15 #ifdef __cplusplus |
| 16 extern "C" { |
| 17 #endif |
| 18 |
| 19 #define WIXAPI __stdcall |
| 20 #define ExitTrace WcaLogError |
| 21 #define ExitTrace1 WcaLogError |
| 22 #define ExitTrace2 WcaLogError |
| 23 #define ExitTrace3 WcaLogError |
| 24 |
| 25 #include "dutil/dutil.h" |
| 26 |
| 27 #define MessageExitOnLastError(x, e, s) { x = ::GetLastError(); x = HRESULT
_FROM_WIN32(x); if (FAILED(x)) { ExitTrace(x, "%s", s); WcaErrorMessage(e, x, MB
_OK, 0); goto LExit; } } |
| 28 #define MessageExitOnLastError1(x, e, f, s) { x = ::GetLastError(); x = HRESULT
_FROM_WIN32(x); if (FAILED(x)) { ExitTrace1(x, f, s); WcaErrorMessage(e, x, MB_O
K, 1, s); goto LExit; } } |
| 29 |
| 30 #define MessageExitOnFailure(x, e, s) if (FAILED(x)) { ExitTrace(x, "%
s", s); WcaErrorMessage(e, x, INSTALLMESSAGE_ERROR | MB_OK, 0); goto LExit; } |
| 31 #define MessageExitOnFailure1(x, e, f, s) if (FAILED(x)) { ExitTrace1(x, f
, s); WcaErrorMessage(e, x, INSTALLMESSAGE_ERROR | MB_OK, 1, s); goto LExit; } |
| 32 #define MessageExitOnFailure2(x, e, f, s, t) if (FAILED(x)) { ExitTrace2(x, f
, s, t); WcaErrorMessage(e, x, INSTALLMESSAGE_ERROR | MB_OK, 2, s, t); goto LEx
it; } |
| 33 #define MessageExitOnFailure3(x, e, f, s, t, u) if (FAILED(x)) { ExitTrace2(x, f
, s, t, u); WcaErrorMessage(e, x, INSTALLMESSAGE_ERROR | MB_OK, 3, s, t, u); go
to LExit; } |
| 34 |
| 35 #define MessageExitOnNullWithLastError(p, x, e, s) if (NULL == p) { x = ::GetLas
tError(); x = HRESULT_FROM_WIN32(x); if (!FAILED(x)) { x = E_FAIL; } ExitTrace(x
, "%s", s); WcaErrorMessage(e, x, MB_OK, 0); goto LExit; } |
| 36 #define MessageExitOnNullWithLastError1(p, x, e, f, s) if (NULL == p) { x = ::Ge
tLastError(); x = HRESULT_FROM_WIN32(x); if (!FAILED(x)) { x = E_FAIL; } ExitTra
ce(x, f, s); WcaErrorMessage(e, x, MB_OK, 1, s); goto LExit; } |
| 37 #define MessageExitOnNullWithLastError2(p, x, e, f, s, t) if (NULL == p) { x = :
:GetLastError(); x = HRESULT_FROM_WIN32(x); if (!FAILED(x)) { x = E_FAIL; } Exit
Trace(x, f, s, t); WcaErrorMessage(e, x, MB_OK, 2, s, t); goto LExit; } |
| 38 |
| 39 // Generic action enum. |
| 40 enum WCA_ACTION |
| 41 { |
| 42 WCA_ACTION_NONE, |
| 43 WCA_ACTION_INSTALL, |
| 44 WCA_ACTION_UNINSTALL, |
| 45 }; |
| 46 |
| 47 enum WCA_CASCRIPT |
| 48 { |
| 49 WCA_CASCRIPT_SCHEDULED, |
| 50 WCA_CASCRIPT_ROLLBACK, |
| 51 }; |
| 52 |
| 53 enum WCA_CASCRIPT_CLOSE |
| 54 { |
| 55 WCA_CASCRIPT_CLOSE_PRESERVE, |
| 56 WCA_CASCRIPT_CLOSE_DELETE, |
| 57 }; |
| 58 |
| 59 enum WCA_TODO |
| 60 { |
| 61 WCA_TODO_UNKNOWN, |
| 62 WCA_TODO_INSTALL, |
| 63 WCA_TODO_UNINSTALL, |
| 64 WCA_TODO_REINSTALL, |
| 65 }; |
| 66 |
| 67 typedef struct WCA_CASCRIPT_STRUCT |
| 68 { |
| 69 LPWSTR pwzScriptPath; |
| 70 HANDLE hScriptFile; |
| 71 } *WCA_CASCRIPT_HANDLE; |
| 72 |
| 73 void WIXAPI WcaGlobalInitialize( |
| 74 __in HINSTANCE hInst |
| 75 ); |
| 76 void WIXAPI WcaGlobalFinalize(); |
| 77 |
| 78 HRESULT WIXAPI WcaInitialize( |
| 79 __in MSIHANDLE hInstall, |
| 80 __in_z PCSTR szCustomActionLogName |
| 81 ); |
| 82 UINT WIXAPI WcaFinalize( |
| 83 __in UINT iReturnValue |
| 84 ); |
| 85 BOOL WIXAPI WcaIsInitialized(); |
| 86 |
| 87 MSIHANDLE WIXAPI WcaGetInstallHandle(); |
| 88 MSIHANDLE WIXAPI WcaGetDatabaseHandle(); |
| 89 |
| 90 const char* WIXAPI WcaGetLogName(); |
| 91 |
| 92 void WIXAPI WcaSetReturnValue( |
| 93 __in UINT iReturnValue |
| 94 ); |
| 95 BOOL WIXAPI WcaCancelDetected(); |
| 96 |
| 97 const int LOG_BUFFER = 2048; |
| 98 enum LOGLEVEL |
| 99 { |
| 100 LOGMSG_TRACEONLY, // Never written to the log file (except in DEBUG builds) |
| 101 LOGMSG_VERBOSE, // Written to log when LOGVERBOSE |
| 102 LOGMSG_STANDARD // Written to log whenever informational logging is enabl
ed |
| 103 }; |
| 104 |
| 105 void __cdecl WcaLog( |
| 106 __in LOGLEVEL llv, |
| 107 __in_z __format_string PCSTR fmt, ... |
| 108 ); |
| 109 BOOL WIXAPI WcaDisplayAssert( |
| 110 __in LPCSTR sz |
| 111 ); |
| 112 void __cdecl WcaLogError( |
| 113 __in HRESULT hr, |
| 114 __in LPCSTR szMessage, |
| 115 ... |
| 116 ); |
| 117 |
| 118 UINT WIXAPI WcaProcessMessage( |
| 119 __in INSTALLMESSAGE eMessageType, |
| 120 __in MSIHANDLE hRecord |
| 121 ); |
| 122 UINT __cdecl WcaErrorMessage( |
| 123 __in int iError, |
| 124 __in HRESULT hrError, |
| 125 __in UINT uiType, |
| 126 __in DWORD cArgs, |
| 127 ... |
| 128 ); |
| 129 HRESULT WIXAPI WcaProgressMessage( |
| 130 __in UINT uiCost, |
| 131 __in BOOL fExtendProgressBar |
| 132 ); |
| 133 |
| 134 BOOL WIXAPI WcaIsInstalling( |
| 135 __in INSTALLSTATE isInstalled, |
| 136 __in INSTALLSTATE isAction |
| 137 ); |
| 138 BOOL WIXAPI WcaIsReInstalling( |
| 139 __in INSTALLSTATE isInstalled, |
| 140 __in INSTALLSTATE isAction |
| 141 ); |
| 142 BOOL WIXAPI WcaIsUninstalling( |
| 143 __in INSTALLSTATE isInstalled, |
| 144 __in INSTALLSTATE isAction |
| 145 ); |
| 146 |
| 147 HRESULT WIXAPI WcaSetComponentState( |
| 148 __in_z LPCWSTR wzComponent, |
| 149 __in INSTALLSTATE isState |
| 150 ); |
| 151 |
| 152 HRESULT WIXAPI WcaTableExists( |
| 153 __in_z LPCWSTR wzTable |
| 154 ); |
| 155 |
| 156 HRESULT WIXAPI WcaOpenView( |
| 157 __in_z LPCWSTR wzSql, |
| 158 __out MSIHANDLE* phView |
| 159 ); |
| 160 HRESULT WIXAPI WcaExecuteView( |
| 161 __in MSIHANDLE hView, |
| 162 __in MSIHANDLE hRec |
| 163 ); |
| 164 HRESULT WIXAPI WcaOpenExecuteView( |
| 165 __in_z LPCWSTR wzSql, |
| 166 __out MSIHANDLE* phView |
| 167 ); |
| 168 HRESULT WIXAPI WcaFetchRecord( |
| 169 __in MSIHANDLE hView, |
| 170 __out MSIHANDLE* phRec |
| 171 ); |
| 172 HRESULT WIXAPI WcaFetchSingleRecord( |
| 173 __in MSIHANDLE hView, |
| 174 __out MSIHANDLE* phRec |
| 175 ); |
| 176 |
| 177 HRESULT WIXAPI WcaGetProperty( |
| 178 __in_z LPCWSTR wzProperty, |
| 179 __inout LPWSTR* ppwzData |
| 180 ); |
| 181 HRESULT WIXAPI WcaGetFormattedProperty( |
| 182 __in_z LPCWSTR wzProperty, |
| 183 __out LPWSTR* ppwzData |
| 184 ); |
| 185 HRESULT WIXAPI WcaGetFormattedString( |
| 186 __in_z LPCWSTR wzString, |
| 187 __out LPWSTR* ppwzData |
| 188 ); |
| 189 HRESULT WIXAPI WcaGetIntProperty( |
| 190 __in_z LPCWSTR wzProperty, |
| 191 __inout int* piData |
| 192 ); |
| 193 HRESULT WIXAPI WcaGetTargetPath( |
| 194 __in_z LPCWSTR wzFolder, |
| 195 __out LPWSTR* ppwzData |
| 196 ); |
| 197 HRESULT WIXAPI WcaSetProperty( |
| 198 __in_z LPCWSTR wzPropertyName, |
| 199 __in_z LPCWSTR wzPropertyValue |
| 200 ); |
| 201 HRESULT WIXAPI WcaSetIntProperty( |
| 202 __in_z LPCWSTR wzPropertyName, |
| 203 __in int nPropertyValue |
| 204 ); |
| 205 BOOL WIXAPI WcaIsPropertySet( |
| 206 __in LPCSTR szProperty |
| 207 ); |
| 208 BOOL WIXAPI WcaIsUnicodePropertySet( |
| 209 __in LPCWSTR wzProperty |
| 210 ); |
| 211 |
| 212 HRESULT WIXAPI WcaGetRecordInteger( |
| 213 __in MSIHANDLE hRec, |
| 214 __in UINT uiField, |
| 215 __inout int* piData |
| 216 ); |
| 217 HRESULT WIXAPI WcaGetRecordString( |
| 218 __in MSIHANDLE hRec, |
| 219 __in UINT uiField, |
| 220 __inout LPWSTR* ppwzData |
| 221 ); |
| 222 HRESULT WIXAPI WcaGetRecordFormattedInteger( |
| 223 __in MSIHANDLE hRec, |
| 224 __in UINT uiField, |
| 225 __out int* piData |
| 226 ); |
| 227 HRESULT WIXAPI WcaGetRecordFormattedString( |
| 228 __in MSIHANDLE hRec, |
| 229 __in UINT uiField, |
| 230 __inout LPWSTR* ppwzData |
| 231 ); |
| 232 |
| 233 HRESULT WIXAPI WcaAllocStream( |
| 234 __deref_out_bcount_part(cbData, 0) BYTE** ppbData, |
| 235 __in DWORD cbData |
| 236 ); |
| 237 HRESULT WIXAPI WcaFreeStream( |
| 238 __in BYTE* pbData |
| 239 ); |
| 240 |
| 241 HRESULT WIXAPI WcaGetRecordStream( |
| 242 __in MSIHANDLE hRecBinary, |
| 243 __in UINT uiField, |
| 244 __deref_out_bcount_full(*pcbData) BYTE** ppbData, |
| 245 __out DWORD* pcbData |
| 246 ); |
| 247 HRESULT WIXAPI WcaSetRecordString( |
| 248 __in MSIHANDLE hRec, |
| 249 __in UINT uiField, |
| 250 __in_z LPCWSTR wzData |
| 251 ); |
| 252 HRESULT WIXAPI WcaSetRecordInteger( |
| 253 __in MSIHANDLE hRec, |
| 254 __in UINT uiField, |
| 255 __in int iValue |
| 256 ); |
| 257 |
| 258 HRESULT WIXAPI WcaDoDeferredAction( |
| 259 __in_z LPCWSTR wzAction, |
| 260 __in_z LPCWSTR wzCustomActionData, |
| 261 __in UINT uiCost |
| 262 ); |
| 263 DWORD WIXAPI WcaCountOfCustomActionDataRecords( |
| 264 __in_z LPCWSTR wzData |
| 265 ); |
| 266 |
| 267 HRESULT WIXAPI WcaReadStringFromCaData( |
| 268 __deref_in LPWSTR* ppwzCustomActionData, |
| 269 __deref_out_z LPWSTR* ppwzString |
| 270 ); |
| 271 HRESULT WIXAPI WcaReadIntegerFromCaData( |
| 272 __deref_in LPWSTR* ppwzCustomActionData, |
| 273 __out int* piResult |
| 274 ); |
| 275 |
| 276 HRESULT WIXAPI WcaWriteStringToCaData( |
| 277 __in_z LPCWSTR wzString, |
| 278 __deref_inout_z LPWSTR* ppwzCustomActionData |
| 279 ); |
| 280 HRESULT WIXAPI WcaWriteIntegerToCaData( |
| 281 __in int i, |
| 282 __deref_out_z_opt LPWSTR* ppwzCustomActionData |
| 283 ); |
| 284 |
| 285 HRESULT __cdecl WcaAddTempRecord( |
| 286 __inout MSIHANDLE* phTableView, |
| 287 __inout MSIHANDLE* phColumns, |
| 288 __in_z LPCWSTR wzTable, |
| 289 __out_opt MSIDBERROR* pdbError, |
| 290 __in UINT uiUniquifyColumn, |
| 291 __in UINT cColumns, |
| 292 ... |
| 293 ); |
| 294 |
| 295 HRESULT WIXAPI WcaDumpTable( |
| 296 __in_z LPCWSTR wzTable |
| 297 ); |
| 298 |
| 299 HRESULT WIXAPI WcaDeferredActionRequiresReboot(); |
| 300 BOOL WIXAPI WcaDidDeferredActionRequireReboot(); |
| 301 |
| 302 HRESULT WIXAPI WcaCaScriptCreateKey( |
| 303 __out LPWSTR* ppwzScriptKey |
| 304 ); |
| 305 |
| 306 HRESULT WIXAPI WcaCaScriptCreate( |
| 307 __in WCA_ACTION action, |
| 308 __in WCA_CASCRIPT script, |
| 309 __in BOOL fImpersonated, |
| 310 __in_z LPCWSTR wzScriptKey, |
| 311 __in BOOL fAppend, |
| 312 __out WCA_CASCRIPT_HANDLE* phScript |
| 313 ); |
| 314 |
| 315 HRESULT WIXAPI WcaCaScriptOpen( |
| 316 __in WCA_ACTION action, |
| 317 __in WCA_CASCRIPT script, |
| 318 __in BOOL fImpersonated, |
| 319 __in_z LPCWSTR wzScriptKey, |
| 320 __out WCA_CASCRIPT_HANDLE* phScript |
| 321 ); |
| 322 |
| 323 void WIXAPI WcaCaScriptClose( |
| 324 __in_opt WCA_CASCRIPT_HANDLE hScript, |
| 325 __in WCA_CASCRIPT_CLOSE closeOperation |
| 326 ); |
| 327 |
| 328 HRESULT WIXAPI WcaCaScriptReadAsCustomActionData( |
| 329 __in WCA_CASCRIPT_HANDLE hScript, |
| 330 __out LPWSTR* ppwzCustomActionData |
| 331 ); |
| 332 |
| 333 HRESULT WIXAPI WcaCaScriptWriteString( |
| 334 __in WCA_CASCRIPT_HANDLE hScript, |
| 335 __in_z LPCWSTR wzValue |
| 336 ); |
| 337 |
| 338 HRESULT WIXAPI WcaCaScriptWriteNumber( |
| 339 __in WCA_CASCRIPT_HANDLE hScript, |
| 340 __in DWORD dwValue |
| 341 ); |
| 342 |
| 343 void WIXAPI WcaCaScriptFlush( |
| 344 __in WCA_CASCRIPT_HANDLE hScript |
| 345 ); |
| 346 |
| 347 void WIXAPI WcaCaScriptCleanup( |
| 348 __in_z LPCWSTR wzProductCode, |
| 349 __in BOOL fImpersonated |
| 350 ); |
| 351 |
| 352 HRESULT WIXAPI QuietExec( |
| 353 __inout_z LPWSTR wzCommand, |
| 354 __in DWORD dwTimeout |
| 355 ); |
| 356 |
| 357 WCA_TODO WIXAPI WcaGetComponentToDo( |
| 358 __in_z LPCWSTR wzComponentId |
| 359 ); |
| 360 |
| 361 #ifdef __cplusplus |
| 362 } |
| 363 #endif |
OLD | NEW |