void GetMsiProperty (MSIHANDLE hModule, char* propertyValue, char* propertyName) { if(!propertyName) return; MSIHANDLE hRecord, hView, hDatabase; // get hView & hDatabase hDatabase = MsiGetActiveDatabase(hModule); char pSelectSql[256] = {0}; sprintf(pSelectSql, "select * from Property where `Property`='%s'", propertyName); MsiDatabaseOpenView(hDatabase, pSelectSql, &hView); MsiViewExecute(hView, NULL); DWORD dwLength = 256; if (MsiViewFetch(hView, &hRecord) != ERROR_SUCCESS) return; MsiRecordGetString(hRecord, 2, propertyValue, &dwLength); // close all handles MsiCloseHandle(hRecord); MsiViewClose(hView); MsiCloseHandle(hView); MsiCloseHandle(hDatabase); }
/** * Extracts the jar file from the MSI database binary field * * @param hModule Specify the handle for the MSI database */ void ExtractBinaryFile (MSIHANDLE hModule, const char* pFieldName, const char* pDstFileName) { char cSelectSql[MAX_PATH_SIZE] = {0}; MSIHANDLE hRecord, hView, hDatabase; // get hView & hDatabase hDatabase = MsiGetActiveDatabase(hModule); sprintf(cSelectSql, "select * from Binary where `Name`='%s'", pFieldName); MsiDatabaseOpenView(hDatabase, cSelectSql, &hView); MsiViewExecute(hView, NULL); char szTemp[256] = {0}; DWORD dwLength = 256; if (MsiViewFetch(hView, &hRecord) != ERROR_SUCCESS) { return; } MsiRecordGetString(hRecord, 1, szTemp, &dwLength); if (strncmp(szTemp, pFieldName, strlen(pFieldName))) { return; } // write into installer.jar #define BUFFERSIZE 1024 char szBuffer[BUFFERSIZE] = {0}; DWORD cbBuf = BUFFERSIZE; DWORD countWrite = 0; FILE* fp = NULL; fp = fopen(pDstFileName, "wb+"); if (NULL == fp) { return; } do { if (MsiRecordReadStream(hRecord, 2, szBuffer, &cbBuf) !=ERROR_SUCCESS) break; // error countWrite = fwrite(szBuffer, 1, cbBuf, fp); } while (countWrite == BUFFERSIZE); fclose(fp); // close all handles MsiCloseHandle(hRecord); MsiViewClose(hView); MsiCloseHandle(hView); MsiCloseHandle(hDatabase); }
UINT KillRunningProcessesSlave( MSIHANDLE hInstall, BOOL bKill ) { UINT rv = ERROR_SUCCESS; _KillProc * kpList; int nKpList = 0; int i; int rowNum = 1; DWORD size; BOOL found = FALSE; MSIHANDLE hDatabase = NULL; MSIHANDLE hView = NULL; MSIHANDLE hViewInsert = NULL; MSIHANDLE hRecord = NULL; MSIHANDLE hRecordInsert = NULL; HANDLE hSnapshot = NULL; PROCESSENTRY32 pe; kpList = new _KillProc[MAX_KILL_PROCESSES]; memset(kpList, 0, sizeof(*kpList) * MAX_KILL_PROCESSES); hDatabase = MsiGetActiveDatabase( hInstall ); if( hDatabase == NULL ) { rv = GetLastError(); goto _cleanup; } // If we are only going to list out the processes, delete all the existing // entries first. if(!bKill) { rv = MsiDatabaseOpenView( hDatabase, _T( "DELETE FROM `ListBox` WHERE `ListBox`.`Property` = 'KillableProcesses'" ), &hView); RV_BAIL; rv = MsiViewExecute( hView, NULL ); RV_BAIL; MsiCloseHandle( hView ); hView = NULL; rv = MsiDatabaseOpenView( hDatabase, _T( "SELECT * FROM `ListBox` WHERE `Property` = 'KillableProcesses'" ), &hViewInsert); RV_BAIL; MsiViewExecute(hViewInsert, NULL); hRecordInsert = MsiCreateRecord(4); if(hRecordInsert == NULL) { rv = GetLastError(); goto _cleanup; } } // Open a view rv = MsiDatabaseOpenView( hDatabase, _T( "SELECT `Image`,`Desc` FROM `KillProcess`" ), &hView); RV_BAIL; rv = MsiViewExecute( hView, NULL ); RV_BAIL; do { rv = MsiViewFetch( hView, &hRecord ); if(rv != ERROR_SUCCESS) { if(hRecord) MsiCloseHandle(hRecord); hRecord = NULL; break; } kpList[nKpList].image = new TCHAR[ FIELD_SIZE ]; kpList[nKpList].image[0] = _T('\0'); kpList[nKpList].desc = new TCHAR[ FIELD_SIZE ]; kpList[nKpList].desc[0] = _T('\0'); nKpList++; size = FIELD_SIZE; rv = MsiRecordGetString(hRecord, 1, kpList[nKpList-1].image, &size); RV_BAIL; size = FIELD_SIZE; rv = MsiRecordGetString(hRecord, 2, kpList[nKpList-1].desc, &size); RV_BAIL; MsiCloseHandle(hRecord); } while(nKpList < MAX_KILL_PROCESSES); hRecord = NULL; // now we have all the processes in the array. Check if they are running. hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); if(hSnapshot == INVALID_HANDLE_VALUE) { rv = GetLastError(); goto _cleanup; } pe.dwSize = sizeof( PROCESSENTRY32 ); if(!Process32First( hSnapshot, &pe )) { // technically we should at least find the MSI process, but we let this pass rv = ERROR_SUCCESS; goto _cleanup; } do { for(i=0; i<nKpList; i++) { if(!_tcsicmp( kpList[i].image, pe.szExeFile )) { // got one if(bKill) { // try to kill the process HANDLE hProcess = NULL; // If we encounter an error, instead of bailing // out, we continue on to the next process. We // may not have permission to kill all the // processes we want to kill anyway. If there are // any files that we want to replace that is in // use, Windows Installer will schedule a reboot. // Also, it's not like we have an exhaustive list // of all the programs that use Kerberos anyway. hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pe.th32ProcessID); if(hProcess == NULL) { rv = GetLastError(); break; } if(!TerminateProcess(hProcess, 0)) { rv = GetLastError(); CloseHandle(hProcess); break; } CloseHandle(hProcess); } else { TCHAR buf[256]; // we are supposed to just list out the processes rv = MsiRecordClearData( hRecordInsert ); RV_BAIL; rv = MsiRecordSetString( hRecordInsert, 1, _T("KillableProcesses")); rv = MsiRecordSetInteger( hRecordInsert, 2, rowNum++ ); RV_BAIL; _itot( rowNum, buf, 10 ); rv = MsiRecordSetString( hRecordInsert, 3, buf ); RV_BAIL; if(_tcslen(kpList[i].desc)) { rv = MsiRecordSetString( hRecordInsert, 4, kpList[i].desc ); RV_BAIL; } else { rv = MsiRecordSetString( hRecordInsert, 4, kpList[i].image ); RV_BAIL; } MsiViewModify(hViewInsert, MSIMODIFY_INSERT_TEMPORARY, hRecordInsert); RV_BAIL; found = TRUE; } break; } } } while( Process32Next( hSnapshot, &pe ) ); if(!bKill) { // set the 'FoundProcceses' property if(found) { MsiSetProperty( hInstall, _T("FoundProcesses"), _T("1")); } else { MsiSetProperty( hInstall, _T("FoundProcesses"), _T("")); } } // Finally: rv = ERROR_SUCCESS; _cleanup: if(hRecordInsert) MsiCloseHandle(hRecordInsert); if(hViewInsert) MsiCloseHandle(hView); if(hSnapshot && hSnapshot != INVALID_HANDLE_VALUE) CloseHandle(hSnapshot); while(nKpList) { nKpList--; delete kpList[nKpList].image; delete kpList[nKpList].desc; } delete kpList; if(hRecord) MsiCloseHandle(hRecord); if(hView) MsiCloseHandle(hView); if(hDatabase) MsiCloseHandle(hDatabase); if(rv != ERROR_SUCCESS) { ShowMsiError(hInstall, ERR_PROC_LIST, rv); } return rv; }
MSICA_IMP ReplaceEula(MSIHANDLE hInstall) { // ::DebugBreak(); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); // // EULA File Content is MBCS (RTF) not Unicode AutoProcessHeapPtr<LPSTR> lpEula = pReadEulaFromFileA(hInstall); if (NULL == (LPSTR) lpEula) { _RPT0(_CRT_ERROR, "pReadEulaFromFile failed\n"); return ERROR_INSTALL_FAILURE; } _RPT0(_CRT_WARN, "ReplaceEula\n"); PMSIHANDLE hDatabase = MsiGetActiveDatabase(hInstall); if (0 == hDatabase) { _RPT0(_CRT_ERROR, "MsiGetActiveDatabase failed\n"); return ERROR_INSTALL_FAILURE; } PMSIHANDLE hView; LPCTSTR query = _T("SELECT * FROM `Control` WHERE `Dialog_` = 'LicenseAgreement' AND `Control` = 'Memo'"); UINT msiret = MsiDatabaseOpenView(hDatabase, query, &hView); if (ERROR_SUCCESS != msiret) { _RPT0(_CRT_ERROR, "MsiDatabaseOpenView failed\n"); return ERROR_INSTALL_FAILURE; } msiret = MsiViewExecute(hView, 0); if (ERROR_SUCCESS != msiret) { _RPT0(_CRT_ERROR, "MsiViewExecute failed\n"); return ERROR_INSTALL_FAILURE; } PMSIHANDLE hRecord; msiret = MsiViewFetch(hView, &hRecord); if (ERROR_SUCCESS != msiret) { _RPT0(_CRT_ERROR, "MsiViewFetch failed\n"); return ERROR_INSTALL_FAILURE; } msiret = MsiViewModify(hView, MSIMODIFY_DELETE, hRecord); if (ERROR_SUCCESS != msiret) { _RPT0(_CRT_ERROR, "MsiViewModify failed\n"); return ERROR_INSTALL_FAILURE; } UINT nFields = MsiRecordGetFieldCount(hRecord); AutoProcessHeapPtr<LPTSTR> buffer; DWORD chBuffer = 0; msiret = MsiRecordGetString(hRecord, 10, _T(""), &chBuffer); if (ERROR_MORE_DATA == msiret) { ++chBuffer; buffer = (LPTSTR) ::HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, chBuffer * sizeof(TCHAR)); msiret = MsiRecordGetString(hRecord, 1, buffer, &chBuffer); } msiret = MsiRecordSetStringA(hRecord, 10, lpEula); if (ERROR_SUCCESS != msiret) { _RPT0(_CRT_ERROR, "MsiRecordSetString failed\n"); return ERROR_INSTALL_FAILURE; } msiret = MsiViewModify(hView, MSIMODIFY_INSERT_TEMPORARY, hRecord); if (ERROR_SUCCESS != msiret) { _RPT0(_CRT_ERROR, "MsiViewModify failed\n"); return ERROR_INSTALL_FAILURE; } //msiret = MsiViewExecute(hView, hRecord); //if (ERROR_SUCCESS != msiret) //{ // return ERROR_INSTALL_FAILURE; //} _RPT0(_CRT_WARN, "ReplaceEula completed successfully.\n"); return ERROR_SUCCESS; }
static void test_system_tables( void ) { UINT r; const char *query; MSIHANDLE hproduct, hdb, hview, hrec; if (!pMsiApplyPatchA) { win_skip("MsiApplyPatchA is not available\n"); return; } if (is_process_limited()) { skip("process is limited\n"); return; } CreateDirectoryA( "msitest", NULL ); create_file( "msitest\\patch.txt", 1000 ); create_database( msifile, tables, sizeof(tables) / sizeof(struct msi_table) ); create_patch( mspfile ); MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL ); r = MsiInstallProductA( msifile, NULL ); if (r != ERROR_SUCCESS) { skip("Product installation failed with error code %d\n", r); goto cleanup; } r = MsiOpenProductA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", &hproduct ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); hdb = MsiGetActiveDatabase( hproduct ); ok( hdb, "failed to get database handle\n" ); r = find_entry( hdb, "_Streams", "\5SummaryInformation" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); query = "SELECT * FROM `_Storages`"; r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r ); r = find_entry( hdb, "_Tables", "Directory" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "File" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Component" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Feature" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "FeatureComponents" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Property" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "InstallExecuteSequence" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Media" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "_Property" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); MsiCloseHandle( hdb ); MsiCloseHandle( hproduct ); r = MsiApplyPatchA( mspfile, NULL, INSTALLTYPE_DEFAULT, NULL ); ok( r == ERROR_SUCCESS || broken( r == ERROR_PATCH_PACKAGE_INVALID ), /* version 2.0 */ "expected ERROR_SUCCESS, got %u\n", r ); if (r == ERROR_PATCH_PACKAGE_INVALID) { win_skip("Windows Installer < 3.0 detected\n"); goto uninstall; } r = MsiOpenProductA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", &hproduct ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); hdb = MsiGetActiveDatabase( hproduct ); ok( hdb, "failed to get database handle\n" ); r = find_entry( hdb, "_Streams", "\5SummaryInformation" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); query = "SELECT * FROM `_Storages`"; r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r ); r = find_entry( hdb, "_Tables", "Directory" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "File" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Component" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Feature" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "FeatureComponents" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Property" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "InstallExecuteSequence" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Media" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "_Property" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "MsiPatchHeaders" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "Patch" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); r = find_entry( hdb, "_Tables", "PatchPackage" ); ok( r == ERROR_SUCCESS, "failed to find entry %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); MsiCloseHandle( hdb ); MsiCloseHandle( hproduct ); uninstall: r = MsiInstallProductA( msifile, "REMOVE=ALL" ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); cleanup: DeleteFileA( msifile ); DeleteFileA( mspfile ); DeleteFileA( "msitest\\patch.txt" ); RemoveDirectoryA( "msitest" ); }
static void test_simple_patch( void ) { UINT r; DWORD size; char path[MAX_PATH], install_source[MAX_PATH], buffer[32]; const char *query; MSIHANDLE hpackage, hdb, hview, hrec; if (!pMsiApplyPatchA) { win_skip("MsiApplyPatchA is not available\n"); return; } if (is_process_limited()) { skip("process is limited\n"); return; } CreateDirectoryA( "msitest", NULL ); create_file( "msitest\\patch.txt", 1000 ); create_database( msifile, tables, sizeof(tables) / sizeof(struct msi_table) ); create_patch( mspfile ); MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL ); r = MsiInstallProductA( msifile, NULL ); if (r != ERROR_SUCCESS) { skip("Product installation failed with error code %u\n", r); goto cleanup; } size = get_pf_file_size( "msitest\\patch.txt" ); ok( size == 1000, "expected 1000, got %u\n", size ); size = sizeof(install_source); r = MsiGetProductInfoA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", "InstallSource", install_source, &size ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); strcpy( path, CURR_DIR ); strcat( path, "\\" ); strcat( path, msifile ); r = MsiOpenPackageA( path, &hpackage ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); hdb = MsiGetActiveDatabase( hpackage ); ok( hdb, "failed to get database handle\n" ); query = "SELECT * FROM `Property` where `Property` = 'PATCHNEWPACKAGECODE'"; r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); query = "SELECT * FROM `Property` WHERE `Property` = 'PATCHNEWSUMMARYSUBJECT' " "AND `Value` = 'Installer Database'"; r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); buffer[0] = 0; size = sizeof(buffer); r = MsiGetProperty( hpackage, "PATCHNEWSUMMARYSUBJECT", buffer, &size ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); ok( !strcmp( buffer, "Installer Database" ), "expected \'Installer Database\', got \'%s\'\n", buffer ); MsiCloseHandle( hdb ); MsiCloseHandle( hpackage ); r = MsiApplyPatchA( mspfile, NULL, INSTALLTYPE_DEFAULT, NULL ); ok( r == ERROR_SUCCESS || broken( r == ERROR_PATCH_PACKAGE_INVALID ), /* version 2.0 */ "expected ERROR_SUCCESS, got %u\n", r ); if (r == ERROR_PATCH_PACKAGE_INVALID) { win_skip("Windows Installer < 3.0 detected\n"); goto uninstall; } size = get_pf_file_size( "msitest\\patch.txt" ); ok( size == 1002, "expected 1002, got %u\n", size ); /* show that MsiOpenPackage applies registered patches */ r = MsiOpenPackageA( path, &hpackage ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); hdb = MsiGetActiveDatabase( hpackage ); ok( hdb, "failed to get database handle\n" ); query = "SELECT * FROM `Property` where `Property` = 'PATCHNEWPACKAGECODE'"; r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); query = "SELECT * FROM `Property` WHERE `Property` = 'PATCHNEWSUMMARYSUBJECT' " "AND `Value` = 'Installation Database'"; r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); buffer[0] = 0; size = sizeof(buffer); r = MsiGetProperty( hpackage, "PATCHNEWSUMMARYSUBJECT", buffer, &size ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); ok( !strcmp( buffer, "Installation Database" ), "expected \'Installation Database\', got \'%s\'\n", buffer ); MsiCloseHandle( hdb ); MsiCloseHandle( hpackage ); /* show that patches are not committed to the local package database */ size = sizeof(path); r = MsiGetProductInfoA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", "LocalPackage", path, &size ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiOpenDatabaseA( path, MSIDBOPEN_READONLY, &hdb ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiDatabaseOpenView( hdb, query, &hview ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewExecute( hview, 0 ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); r = MsiViewFetch( hview, &hrec ); ok( r == ERROR_NO_MORE_ITEMS, "expected ERROR_NO_MORE_ITEMS, got %u\n", r ); MsiCloseHandle( hrec ); MsiViewClose( hview ); MsiCloseHandle( hview ); MsiCloseHandle( hdb ); uninstall: size = sizeof(path); r = MsiGetProductInfoA( "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}", "InstallSource", path, &size ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); ok( !strcasecmp( path, install_source ), "wrong path %s\n", path ); r = MsiInstallProductA( msifile, "REMOVE=ALL" ); ok( r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", r ); ok( !delete_pf( "msitest\\patch.txt", TRUE ), "file not removed\n" ); ok( !delete_pf( "msitest", FALSE ), "directory not removed\n" ); cleanup: DeleteFileA( msifile ); DeleteFileA( mspfile ); DeleteFileA( "msitest\\patch.txt" ); RemoveDirectoryA( "msitest" ); }
///////////////////////////////////////////////////////////////////// // // Function: GetComponentKeyFilename // // Description: // ///////////////////////////////////////////////////////////////////// UINT BOINCCABase::GetComponentKeyFilename( const tstring strComponentName, tstring& strComponentKeyFilename ) { UINT uiReturnValue = 0; tstring strMessage; tstring strQuery; TCHAR szBuffer[256]; DWORD dwBufferSize = sizeof(szBuffer); MSIHANDLE hDatabase; MSIHANDLE hView; MSIHANDLE hRecComponentName; MSIHANDLE hRec; // Get the handle to the MSI package we are executing for. hDatabase = MsiGetActiveDatabase(m_hMSIHandle); if (!hDatabase) return ERROR_INSTALL_FAILURE; // Construct the query that is going to give us the result we need. strQuery = _T("SELECT `KeyPath` FROM `Component` WHERE `Component`= ?"); // Create the view uiReturnValue = MsiDatabaseOpenView(hDatabase, strQuery.c_str(), &hView); switch(uiReturnValue) { case ERROR_BAD_QUERY_SYNTAX: MsiCloseHandle(hDatabase); LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("MsiDatabaseOpenView reports an invalid query was issued") ); return ERROR_INSTALL_FAILURE; break; case ERROR_INVALID_HANDLE: MsiCloseHandle(hDatabase); LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("MsiDatabaseOpenView reports an invalid handle was used") ); return ERROR_INSTALL_FAILURE; break; } // Create query parameter hRecComponentName = MsiCreateRecord(1); uiReturnValue = MsiRecordSetString(hRecComponentName, 1, strComponentName.c_str()); switch(uiReturnValue) { case ERROR_INVALID_HANDLE: MsiCloseHandle(hRecComponentName); MsiCloseHandle(hDatabase); LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("MsiRecordSetString reports an invalid handle was used") ); return ERROR_INSTALL_FAILURE; break; case ERROR_INVALID_PARAMETER: MsiCloseHandle(hRecComponentName); MsiCloseHandle(hDatabase); LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("MsiRecordSetString reports an invalid parameter was used") ); return ERROR_INSTALL_FAILURE; break; } // Execute the query uiReturnValue = MsiViewExecute(hView, hRecComponentName); switch(uiReturnValue) { case ERROR_FUNCTION_FAILED: MsiViewClose(hView); MsiCloseHandle(hDatabase); LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("MsiViewExecute failed to execute the view") ); return ERROR_INSTALL_FAILURE; break; case ERROR_INVALID_HANDLE: MsiViewClose(hView); MsiCloseHandle(hDatabase); LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("MsiViewExecute reports an invalid handle was used") ); return ERROR_INSTALL_FAILURE; break; } // Only one row should be returned by the resultset, so there is no need // to execute MsiViewFetch more than once. uiReturnValue = MsiViewFetch(hView, &hRec); switch(uiReturnValue) { case ERROR_FUNCTION_FAILED: MsiViewClose(hView); MsiCloseHandle(hDatabase); LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("MsiViewFetch: An error occurred during fetching") ); return ERROR_INSTALL_FAILURE; break; case ERROR_INVALID_HANDLE: MsiViewClose(hView); MsiCloseHandle(hDatabase); LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("MsiViewFetch reports an invalid handle was used") ); return ERROR_INSTALL_FAILURE; break; case ERROR_INVALID_HANDLE_STATE: MsiViewClose(hView); MsiCloseHandle(hDatabase); LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("MsiViewFetch reports the handle was in an invalid state") ); return ERROR_INSTALL_FAILURE; break; } // Okay, now it is time to parse the string that was returned. uiReturnValue = MsiRecordGetString(hRec, 1, (LPTSTR)&szBuffer, &dwBufferSize); switch(uiReturnValue) { case ERROR_INVALID_HANDLE: MsiCloseHandle(hRec); MsiViewClose(hView); MsiCloseHandle(hDatabase); LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("MsiRecordGetString reports an invalid handle was used") ); return ERROR_INSTALL_FAILURE; break; case ERROR_INVALID_PARAMETER: MsiCloseHandle(hRec); MsiViewClose(hView); MsiCloseHandle(hDatabase); LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, _T("MsiRecordGetString reports an invalid parameter was used") ); return ERROR_INSTALL_FAILURE; break; } // Save the string strComponentKeyFilename = szBuffer; strMessage = _T("The key filename for component '"); strMessage += strComponentName; strMessage += _T("' is '"); strMessage += strComponentKeyFilename; strMessage += _T("'"); LogMessage( INSTALLMESSAGE_INFO, NULL, NULL, NULL, NULL, strMessage.c_str() ); return ERROR_SUCCESS; }
MSICA_IMP ReplaceEula(MSIHANDLE hInstall) { // ::DebugBreak(); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); // // EULA File Content is MBCS (RTF) not Unicode // XTL::AutoProcessHeapPtr<CHAR> lpEula = pReadEulaFromFile(hInstall); if (NULL == (LPSTR) lpEula) { pMsiLogMessage( hInstall, _T("EULACA: ReadEulaFromFile failed, error=0x%X"), GetLastError()); return ERROR_INSTALL_FAILURE; } // // Replacing EULA text control in the database // PMSIHANDLE hDatabase = MsiGetActiveDatabase(hInstall); if (0 == hDatabase) { pMsiLogMessage( hInstall, _T("EULACA: MsiGetActiveDatabase failed, error=0x%X"), GetLastError()); return ERROR_INSTALL_FAILURE; } PMSIHANDLE hView; LPCTSTR query = _T("SELECT * FROM `Control` ") _T(" WHERE `Dialog_` = 'LicenseAgreement' AND `Control` = 'Memo' "); UINT ret = MsiDatabaseOpenView(hDatabase, query, &hView); if (ERROR_SUCCESS != ret) { pMsiLogMessage( hInstall, _T("EULACA: MsiDatabaseOpenView failed, error=0x%X"), ret); return ERROR_INSTALL_FAILURE; } ret = MsiViewExecute(hView, 0); if (ERROR_SUCCESS != ret) { pMsiLogMessage( hInstall, _T("EULACA: MsiViewExecute failed, error=0x%X"), ret); return ERROR_INSTALL_FAILURE; } PMSIHANDLE hRecord; ret = MsiViewFetch(hView, &hRecord); if (ERROR_SUCCESS != ret) { pMsiLogMessage( hInstall, _T("EULACA: MsiViewFetch failed, error=0x%X"), ret); return ERROR_INSTALL_FAILURE; } ret = MsiViewModify(hView, MSIMODIFY_DELETE, hRecord); if (ERROR_SUCCESS != ret) { pMsiLogMessage( hInstall, _T("EULACA: MsiViewModify failed, error=0x%X"), ret); return ERROR_INSTALL_FAILURE; } // // 10th field is the Text column // // Dialog_, Control, Type, X, Y, // Width, Height, Attributes, Property, Text // Control_Next, Help // ret = MsiRecordSetStringA(hRecord, 10, lpEula); if (ERROR_SUCCESS != ret) { pMsiLogMessage( hInstall, _T("EULACA: MsiRecordSetString failed, error=0x%X"), ret); return ERROR_INSTALL_FAILURE; } // // Commit the changes temporarily // ret = MsiViewModify(hView, MSIMODIFY_INSERT_TEMPORARY, hRecord); if (ERROR_SUCCESS != ret) { pMsiLogMessage( hInstall, _T("EULACA: MsiViewModify failed, error=0x%X"), ret); return ERROR_INSTALL_FAILURE; } pMsiLogMessage( hInstall, _T("EULACA: EULA is replaced successfully.")); return ERROR_SUCCESS; }
/* ** Name:ingres_prepare_remove_dbms_files ** ** Description: ** Set up the RemoveFile table in DBMS Merge Module for the ** directories and files that were not installed as part of ** the initial installation so that they can be removed from ** the system during an uninstall. ** ** Inputs: ** hInstall Handle to the installation. ** ** Outputs: ** None. ** Returns: ** ERROR_SUCCESS The function succeeds. ** ERROR_INSTALL_FAILURE The function fails. ** Exceptions: ** None. ** ** Side Effects: ** None. ** ** History: ** 16-Aug-2001 (penga03) ** Created. ** 17-Aug-2001 (penga03) ** Do not put the INSTALLDIR in the RemoveFile table. ** 14-may-2004 (somsa01) ** Make sure we use the 64-bit GUID, ** 8CCBF50C_6C17_4366_B8FE_FBB31A4092E0, when needed. ** 17-may-2004 (somsa01) ** Backed out prior change, as it does NOT properly fix the problem. */ UINT __stdcall ingres_prepare_remove_dbms_files(MSIHANDLE hInstall) { TCHAR tchValue[MAX_PATH+1], ii_system[MAX_PATH+1], szBuf[MAX_PATH+1]; DWORD dwSize; MSIHANDLE hDatabase, hView, hRecord; TCHAR ConfigKey[256], Host[64]; INSTALLSTATE iInstalled, iAction; TCHAR inst_id[64] = "INSTALLDIR.870341B5_2D6D_11D5_BDFC_00B0D0AD4485"; TCHAR bin_id[64] = "Bin.870341B5_2D6D_11D5_BDFC_00B0D0AD4485"; char sharedDisk[3]; MsiGetFeatureState(hInstall, "IngresDBMS", &iInstalled, &iAction); if(iAction!=INSTALLSTATE_ABSENT) return ERROR_SUCCESS; dwSize=sizeof(ii_system); if(MsiGetTargetPath(hInstall, inst_id, ii_system, &dwSize)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; if(ii_system[lstrlen(ii_system)-1] == '\\') ii_system[lstrlen(ii_system)-1] = '\0'; SetEnvironmentVariable("II_SYSTEM", ii_system); MsiSetProperty(hInstall, "INGRES_CLUSTER_RESOURCE_INUSE", "0"); if(Local_NMgtIngAt("II_DATABASE", tchValue)==ERROR_SUCCESS) { strncpy(sharedDisk, tchValue, 2); sharedDisk[2]='\0'; if (GetFileAttributes(sharedDisk) == -1) { MsiSetProperty(hInstall, "INGRES_CLUSTER_RESOURCE_INUSE", "1"); return ERROR_SUCCESS; } } hDatabase=MsiGetActiveDatabase(hInstall); if(!hDatabase) return ERROR_INSTALL_FAILURE; if(MsiDatabaseOpenView(hDatabase, "INSERT INTO `RemoveFile` (`FileKey`, `Component_`, `FileName`, `DirProperty`, `InstallMode`) VALUES (?, ?, ?, ?, ?) TEMPORARY", &hView)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; hRecord=MsiCreateRecord(5); if(!hRecord) return ERROR_INSTALL_FAILURE; if(Local_NMgtIngAt("II_DATABASE", tchValue)==ERROR_SUCCESS) { int KeyCount; char szKey[MAX_PATH+1], szKey2[MAX_PATH+1]; wsprintf(szBuf, "%s\\ingres\\data", tchValue); Count=-1; CreateDirList(szBuf); for(KeyCount=0; KeyCount<=Count; KeyCount++) { wsprintf(szKey, "RemoveDatabaseDir_%d", KeyCount); wsprintf(szKey2, "RemoveDatabaseDir_%d_Dir", KeyCount); MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName); MsiRecordSetString(hRecord, 1, szKey); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, "*.*"); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } Count++; wsprintf(szKey, "RemoveDatabaseDir_%d", Count); wsprintf(szKey2, "RemoveDatabaseDir_%d_Dir", Count); wsprintf(szBuf, "%s\\ingres", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; Count++; wsprintf(szKey, "RemoveDatabaseDir_%d", Count); wsprintf(szKey2, "RemoveDatabaseDir_%d_Dir", Count); wsprintf(szBuf, "%s", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } if(Local_NMgtIngAt("II_CHECKPOINT", tchValue)==ERROR_SUCCESS) { int KeyCount; char szKey[MAX_PATH+1], szKey2[MAX_PATH+1]; wsprintf(szBuf, "%s\\ingres\\ckp", tchValue); Count=-1; CreateDirList(szBuf); for(KeyCount=0; KeyCount<=Count; KeyCount++) { wsprintf(szKey, "RemovecCheckpointDir_%d", KeyCount); wsprintf(szKey2, "RemoveCheckpointDir_%d_Dir", KeyCount); MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName); MsiRecordSetString(hRecord, 1, szKey); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, "*.*"); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } Count++; wsprintf(szKey, "RemovecCheckpointDir_%d", Count); wsprintf(szKey2, "RemovecCheckpointDir_%d_Dir", Count); wsprintf(szBuf, "%s\\ingres", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; Count++; wsprintf(szKey, "RemovecCheckpointDir_%d", Count); wsprintf(szKey2, "RemovecCheckpointDir_%d_Dir", Count); wsprintf(szBuf, "%s", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } if(Local_NMgtIngAt("II_JOURNAL", tchValue)==ERROR_SUCCESS) { int KeyCount; char szKey[MAX_PATH+1], szKey2[MAX_PATH+1]; wsprintf(szBuf, "%s\\ingres\\jnl", tchValue); Count=-1; CreateDirList(szBuf); for(KeyCount=0; KeyCount<=Count; KeyCount++) { wsprintf(szKey, "RemoveJournalDir_%d", KeyCount); wsprintf(szKey2, "RemoveJournalDir_%d_Dir", KeyCount); MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName); MsiRecordSetString(hRecord, 1, szKey); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, "*.*"); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } Count++; wsprintf(szKey, "RemoveJournalDir_%d", Count); wsprintf(szKey2, "RemoveJournalDir_%d_Dir", Count); wsprintf(szBuf, "%s\\ingres", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; Count++; wsprintf(szKey, "RemoveJournalDir_%d", Count); wsprintf(szKey2, "RemoveJournalDir_%d_Dir", Count); wsprintf(szBuf, "%s", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } if(Local_NMgtIngAt("II_DUMP", tchValue)==ERROR_SUCCESS) { int KeyCount; char szKey[MAX_PATH+1], szKey2[MAX_PATH+1]; wsprintf(szBuf, "%s\\ingres\\dmp", tchValue); Count=-1; CreateDirList(szBuf); for(KeyCount=0; KeyCount<=Count; KeyCount++) { wsprintf(szKey, "RemoveDumpDir_%d", KeyCount); wsprintf(szKey2, "RemoveDumpDir_%d_Dir", KeyCount); MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName); MsiRecordSetString(hRecord, 1, szKey); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, "*.*"); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } Count++; wsprintf(szKey, "RemoveDumpDir_%d", Count); wsprintf(szKey2, "RemoveDumpDir_%d_Dir", Count); wsprintf(szBuf, "%s\\ingres", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; Count++; wsprintf(szKey, "RemoveDumpDir_%d", Count); wsprintf(szKey2, "RemoveDumpDir_%d_Dir", Count); wsprintf(szBuf, "%s", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } if(Local_NMgtIngAt("II_WORK", tchValue)==ERROR_SUCCESS) { int KeyCount; char szKey[MAX_PATH+1], szKey2[MAX_PATH+1]; wsprintf(szBuf, "%s\\ingres\\work", tchValue); Count=-1; CreateDirList(szBuf); for(KeyCount=0; KeyCount<=Count; KeyCount++) { wsprintf(szKey, "RemoveWorkDir_%d", KeyCount); wsprintf(szKey2, "RemoveWorkDir_%d_Dir", KeyCount); MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName); MsiRecordSetString(hRecord, 1, szKey); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, "*.*"); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } Count++; wsprintf(szKey, "RemoveWorkDir_%d", Count); wsprintf(szKey2, "RemoveWorkDir_%d_Dir", Count); wsprintf(szBuf, "%s\\ingres", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; Count++; wsprintf(szKey, "RemoveWorkDir_%d", Count); wsprintf(szKey2, "RemoveWorkDir_%d_Dir", Count); wsprintf(szBuf, "%s", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } Local_PMhost(Host); wsprintf(ConfigKey, "ii.%s.rcp.log.log_file_parts", Host); if(Local_PMget(ConfigKey, tchValue) == ERROR_SUCCESS) { int num_logs, i; num_logs=atoi(tchValue); for(i=1; i<=num_logs; i++) { wsprintf(ConfigKey, "ii.%s.rcp.log.log_file_%d", Host, i); if(Local_PMget(ConfigKey, tchValue) == ERROR_SUCCESS) { int KeyCount; char szKey[MAX_PATH+1], szKey2[MAX_PATH+1]; StringReplace(tchValue); wsprintf(szBuf, "%s\\ingres\\log", tchValue); Count=-1; CreateDirList(szBuf); for(KeyCount=0; KeyCount<=Count; KeyCount++) { wsprintf(szKey, "RemoveLogDir_%d", KeyCount); wsprintf(szKey2, "RemoveLogDir_%d_Dir", KeyCount); MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName); MsiRecordSetString(hRecord, 1, szKey); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, "*.*"); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } Count++; wsprintf(szKey, "RemoveLogDir_%d", Count); wsprintf(szKey2, "RemoveLogDir_%d_Dir", Count); wsprintf(szBuf, "%s\\ingres", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; Count++; wsprintf(szKey, "RemoveLogDir_%d", Count); wsprintf(szKey2, "RemoveLogDir_%d_Dir", Count); wsprintf(szBuf, "%s", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } } } wsprintf(ConfigKey, "ii.%s.rcp.log.dual_log_1", Host); if(Local_PMget(ConfigKey, tchValue) == ERROR_SUCCESS) { int KeyCount; char szKey[MAX_PATH+1], szKey2[MAX_PATH+1]; StringReplace(tchValue); wsprintf(szBuf, "%s\\ingres\\log", tchValue); Count=-1; CreateDirList(szBuf); for(KeyCount=0; KeyCount<=Count; KeyCount++) { wsprintf(szKey, "RemoveDuallogDir_%d", KeyCount); wsprintf(szKey2, "RemoveDuallogDir_%d_Dir", KeyCount); MsiSetProperty(hInstall, szKey, DirList[KeyCount].DirName); MsiRecordSetString(hRecord, 1, szKey); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, "*.*"); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } Count++; wsprintf(szKey, "RemoveDuallogDir_%d", Count); wsprintf(szKey2, "RemoveDuallogDir_%d_Dir", Count); wsprintf(szBuf, "%s\\ingres", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; Count++; wsprintf(szKey, "RemoveDuallogDir_%d", Count); wsprintf(szKey2, "RemoveDuallogDir_%d_Dir", Count); wsprintf(szBuf, "%s", tchValue); MsiSetProperty(hInstall, szKey, szBuf); MsiRecordSetString(hRecord, 1, szKey2); MsiRecordSetString(hRecord, 2, bin_id); MsiRecordSetString(hRecord, 3, ""); MsiRecordSetString(hRecord, 4, szKey); MsiRecordSetInteger(hRecord, 5, 2); if(MsiViewExecute(hView, hRecord)!=ERROR_SUCCESS) return ERROR_INSTALL_FAILURE; } MsiCloseHandle(hRecord); MsiCloseHandle(hView); MsiCloseHandle(hDatabase); return ERROR_SUCCESS; }