HRESULT ScaWebAppExtensionsRead( LPCWSTR wzApplication, SCA_WEB_APPLICATION_EXTENSION** ppswappextList ) { HRESULT hr = S_OK; PMSIHANDLE hView, hRec; SCA_WEB_APPLICATION_EXTENSION* pswappext = NULL; LPWSTR pwzData = NULL; // check pre-requisites hr = WcaTableExists(L"IIsWebApplicationExtension"); if (S_FALSE == hr) ExitFunction(); // convert the string into a msi record hRec = ::MsiCreateRecord(1); hr = WcaSetRecordString(hRec, 1, wzApplication); ExitOnFailure(hr, "Failed to set record to look up Web Application"); // open and execute the view on the applicatoin extension table hr = WcaOpenView(vcsWebAppExtensionQuery, &hView); ExitOnFailure(hr, "Failed to open view on IIsWebApplicationExtension table"); hr = WcaExecuteView(hView, hRec); ExitOnFailure1(hr, "Failed to execute view on IIsWebApplicationExtension table looking Application: %S", wzApplication); // get the application extention information while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) { hr = NewAppExt(&pswappext); ExitOnFailure(hr, "failed to create new web app extension"); // get the extension hr = WcaGetRecordString(hRec, wappextqExtension, &pwzData); ExitOnFailure(hr, "Failed to get Web Application Extension"); StringCchCopyW(pswappext->wzExtension, countof(pswappext->wzExtension), pwzData); // application extension verbs hr = WcaGetRecordString(hRec, wappextqVerbs, &pwzData); ExitOnFailure1(hr, "Failed to get Verbs for Application: '%S'", wzApplication); StringCchCopyW(pswappext->wzVerbs, countof(pswappext->wzVerbs), pwzData); // extension executeable hr = WcaGetRecordFormattedString(hRec, wappextqExecutable, &pwzData); ExitOnFailure1(hr, "Failed to get Executable for Application: '%S'", wzApplication); StringCchCopyW(pswappext->wzExecutable, countof(pswappext->wzExecutable), pwzData); hr = WcaGetRecordInteger(hRec, wappextqAttributes, &pswappext->iAttributes); if (S_FALSE == hr) { pswappext->iAttributes = 0; hr = S_OK; } ExitOnFailure(hr, "Failed to get App isolation"); *ppswappextList = AddAppExtToList(*ppswappextList, pswappext); pswappext = NULL; // set the appext NULL so it doesn't accidentally get freed below } if (E_NOMOREITEMS == hr) hr = S_OK; LExit: // if anything was left over after an error clean it all up if (pswappext) ScaWebAppExtensionsFreeList(pswappext); ReleaseStr(pwzData); return hr; }
HRESULT ScaWebAppExtensionsRead( __in LPCWSTR wzApplication, __in WCA_WRAPQUERY_HANDLE hWebAppExtQuery, __inout SCA_WEB_APPLICATION_EXTENSION** ppswappextList ) { HRESULT hr = S_OK; MSIHANDLE hRec; SCA_WEB_APPLICATION_EXTENSION* pswappext = NULL; LPWSTR pwzData = NULL; // Reset back to the first record WcaFetchWrappedReset(hWebAppExtQuery); // get the application extension information while (S_OK == (hr = WcaFetchWrappedRecordWhereString(hWebAppExtQuery, wappextqApplication, wzApplication, &hRec))) { hr = NewAppExt(&pswappext); ExitOnFailure(hr, "failed to create new web app extension"); // get the extension hr = WcaGetRecordString(hRec, wappextqExtension, &pwzData); ExitOnFailure(hr, "Failed to get Web Application Extension"); hr = ::StringCchCopyW(pswappext->wzExtension, countof(pswappext->wzExtension), pwzData); ExitOnFailure(hr, "Failed to copy extension string to webappext object"); // application extension verbs hr = WcaGetRecordString(hRec, wappextqVerbs, &pwzData); ExitOnFailure1(hr, "Failed to get Verbs for Application: '%ls'", wzApplication); hr = ::StringCchCopyW(pswappext->wzVerbs, countof(pswappext->wzVerbs), pwzData); ExitOnFailure(hr, "Failed to copy verbs string to webappext object"); // extension executeable hr = WcaGetRecordString(hRec, wappextqExecutable, &pwzData); ExitOnFailure1(hr, "Failed to get Executable for Application: '%ls'", wzApplication); hr = ::StringCchCopyW(pswappext->wzExecutable, countof(pswappext->wzExecutable), pwzData); ExitOnFailure(hr, "Failed to copy executable string to webappext object"); hr = WcaGetRecordInteger(hRec, wappextqAttributes, &pswappext->iAttributes); if (S_FALSE == hr) { pswappext->iAttributes = 0; hr = S_OK; } ExitOnFailure(hr, "Failed to get App isolation"); *ppswappextList = AddAppExtToList(*ppswappextList, pswappext); pswappext = NULL; // set the appext NULL so it doesn't accidentally get freed below } if (E_NOMOREITEMS == hr) { hr = S_OK; } LExit: // if anything was left over after an error clean it all up if (pswappext) { ScaWebAppExtensionsFreeList(pswappext); } ReleaseStr(pwzData); return hr; }