UINT __stdcall ingres_cluster_unregister_service(MSIHANDLE hInstall) { HCLUSTER hCluster; HRESOURCE hResource; WCHAR wszResourceName[256]; char szResourceName[256]; char szInstallCode[3]; DWORD dwSize; INSTALLSTATE iInstalled, iAction; char szBuf[256]; MsiGetFeatureState(hInstall, "IngresDBMS", &iInstalled, &iAction); if(iAction != INSTALLSTATE_ABSENT) return ERROR_SUCCESS; dwSize=sizeof(szBuf); *szBuf=0; if (!MsiGetProperty(hInstall, "INGRES_CLUSTER_RESOURCE_INUSE", szBuf, &dwSize) && !strcmp(szBuf, "1")) return ERROR_SUCCESS; dwSize=sizeof(szResourceName); *szResourceName=0; MsiGetProperty(hInstall, "INGRES_CLUSTER_RESOURCE", szResourceName, &dwSize); mbstowcs(wszResourceName, szResourceName, sizeof(szResourceName)); dwSize=sizeof(szInstallCode); *szInstallCode=0; MsiGetProperty(hInstall, "II_INSTALLATION", szInstallCode, &dwSize); hCluster = OpenCluster(NULL); if(hCluster) { hResource = OpenClusterResource(hCluster, wszResourceName); if(hResource) { if (!DeleteClusterResource(hResource)) SetupRegistryKeys(hResource, szInstallCode, FALSE); CloseClusterResource(hResource); } CloseCluster(hCluster); } return ERROR_SUCCESS; }
void WcDependencies::GetDependencies(void) { HRESOURCE hRes = OpenClusterResource(thePreSetup.m_hCluster, CT2CW(thePreSetup.m_ResourceName.GetBuffer())); if (hRes == NULL) return; DWORD dwResult = ERROR_SUCCESS; // Captures return values DWORD dwIndex = 0; // Enumeration index DWORD dwType = CLUSTER_RESOURCE_ENUM_DEPENDS; // Type of object to enumerate DWORD cbNameAlloc = // Allocated size of the name buffer MAXIMUM_NAMELENGTH * sizeof( WCHAR ); DWORD cchName = 0; // Size of the resulting name as a count of wchars LPWSTR lpszName = // Buffer to hold enumerated names (LPWSTR) LocalAlloc( LPTR, cbNameAlloc ); if (lpszName == NULL) { dwResult = GetLastError(); goto endf; } // Open enumeration handle. HRESENUM hResEnum = ClusterResourceOpenEnum( hRes, dwType ); if (hResEnum == NULL) { dwResult = GetLastError(); goto endf; } while(dwResult == ERROR_SUCCESS) { cchName = cbNameAlloc / sizeof( WCHAR ); dwResult = ClusterResourceEnum( hResEnum, dwIndex, &dwType, lpszName, &cchName); // Reallocate the name buffer if not big enough. if (dwResult == ERROR_MORE_DATA) { cchName++; // Leave room for terminating NULL. cbNameAlloc = cchName / sizeof( WCHAR ); LocalFree( lpszName ); lpszName = (LPWSTR) LocalAlloc( LPTR, cbNameAlloc ); if ( lpszName == NULL ) { dwResult = GetLastError(); goto endf; } dwResult = ClusterResourceEnum( hResEnum, dwIndex, &dwType, lpszName, &cchName ); } if( dwResult == ERROR_SUCCESS ) { int nItem = FindDependency(lpszName, m_ResourceListCtrl); if (nItem >= 0) MoveItem(nItem, /*from*/m_ResourceListCtrl, /*to*/m_DependencyListCtrl); } else if( dwResult == ERROR_NO_MORE_ITEMS ) { break; } else // enum failed for another reason { dwResult = GetLastError(); goto endf; } dwIndex++; } // End while. endf: CloseClusterResource(hRes); }
/** ** This routine will handle upgrade/modify installs only. ** This dialog will only be displayed if ingres is being modified or upgraded. */ BOOL InstanceList::OnWizardFinish() { char code[3]; char ach[2048], ii_system[1024]; int flag=0; BOOL bInstalled=FALSE; sprintf(code, "%s", m_iicode); thePreInstall.m_InstallCode=m_iicode; if(strlen(code)!=2 || !isalpha(code[0]) || !isalnum(code[1])) { Error(IDS_INVALIDINSTALLATIONCODE, code); return FALSE; } CInstallation *inst=NULL; for(int i=0; i<thePreInstall.m_Installations.GetSize(); i++) { inst=(CInstallation *) thePreInstall.m_Installations.GetAt(i); if (inst && !thePreInstall.m_InstallCode.CompareNoCase(inst->m_id)) { bInstalled=TRUE; sprintf(ii_system, "%s", inst->m_path); thePreInstall.m_UpgradeType=CompareIngresVersion(ii_system); if (thePreInstall.m_DBATools) thePreInstall.m_UpgradeType=inst->m_UpgradeCode; if (inst->m_ver25) { thePreInstall.m_Ver25 ="1"; thePreInstall.m_EmbeddedRelease =inst->m_embedded; } break; } } if (!(bInstalled && (!thePreInstall.m_Ver25.Compare("1") || thePreInstall.m_UpgradeType))) goto Label; char buf[2048], szInstallCode[3]; char szKey[256], szResName[256]; int idx; HKEY hKey; BOOL bCluster; sprintf(szInstallCode, thePreInstall.m_InstallCode.GetBuffer(3)); if (_stricmp(szInstallCode, "II")) { /* Compute the GUID index from the installation code */ idx = (toupper(szInstallCode[0]) - 'A') * 26 + toupper(szInstallCode[1]) - 'A'; if (idx <= 0) idx = (toupper(szInstallCode[0]) - 'A') * 26 + toupper(szInstallCode[1]) - '0'; sprintf(szKey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{A78D%04X-2979-11D5-BDFA-00B0D0AD4485}",idx); } else sprintf(szKey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{A78D00D8-2979-11D5-BDFA-00B0D0AD4485}"); thePreInstall.m_InstallCode.ReleaseBuffer(); bCluster=FALSE; if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_QUERY_VALUE, &hKey)) { char szData[2]; DWORD dwSize; dwSize=sizeof(szData); *szData=0; if (!RegQueryValueEx(hKey,"IngresClusterInstall", NULL, NULL, (BYTE *)szData, &dwSize) && !strcmp(szData, "1")) bCluster=TRUE; dwSize=sizeof(szResName); *szResName=0; if (!RegQueryValueEx(hKey,"IngresClusterResource", NULL, NULL, (BYTE *)szResName, &dwSize)) sprintf(szResName, "Ingres Service [ %s ]", szInstallCode); RegCloseKey(hKey); } SetEnvironmentVariable("II_SYSTEM", ii_system); GetEnvironmentVariable("PATH", buf, sizeof(buf)); sprintf(ach, "%s\\ingres\\bin;%s\\ingres\\utility;%s", ii_system, ii_system, buf); SetEnvironmentVariable("PATH", ach); while(IngresAlreadyRunning()==1) { thePreInstall.m_RestartIngres=1; MessageBeep(MB_ICONEXCLAMATION); if(!flag && AskUserYN(IDS_INGRESRUNNING)) { CWaitCursor wait; flag=1; if (!bCluster) { sprintf(ach, "\"%s\\ingres\\bin\\winstart.exe\"", ii_installpath); Execute(ach, "/stop", FALSE); Sleep(1000); while(WinstartRunning()) { Sleep(1000); GetParent()->UpdateWindow(); } } else { HCLUSTER hCluster = NULL; HRESOURCE hResource = NULL; WCHAR lpwResourceName[256]; hCluster = OpenCluster(NULL); if (hCluster) { mbstowcs(lpwResourceName, szResName, 256); hResource = OpenClusterResource(hCluster, lpwResourceName); if (hResource) { OfflineClusterResource(hResource); CloseClusterResource(hResource); } } while (IngresAlreadyRunning()==1) Sleep(1000); } } else { GotoDlgCtrl(&m_list); return FALSE; } } sprintf(ach, "\"%s\\ingres\\bin\\ivm.exe\"", ii_installpath); if (!Execute(ach, "-stop", FALSE)) { sprintf(ach, "\"%s\\ingres\\vdba\\ivm.exe\"", ii_installpath); Execute(ach, "-stop", FALSE); } if(IngresAlreadyRunning()==0) { if ((thePreInstall.m_UpgradeType ==1 || thePreInstall.m_UpgradeType ==2) && !thePreInstall.m_DBATools) { CString charset; if (IsPre92Release(inst->m_ReleaseVer)) { Local_NMgtIngAt("II_CHARSET", inst->m_path, charset); if (charset.IsEmpty()) { char charsetinst[MAX_PATH]; sprintf(charsetinst, "II_CHARSET%s", inst->m_id); Local_NMgtIngAt(charsetinst, inst->m_path, charset); } if (!charset.IsEmpty() && charset.CompareNoCase("UTF8")==0) { Error(IDS_BLOCKUPGRADE, code); return FALSE; } } if (thePreInstall.m_Ver25.Compare("1")) { if(!AskUserYN(IDS_UPGRADE)) { thePreInstall.m_UpgradeType=0; } } else { if (!AskUserYN(IDS_MUSTUPGRADEVER25, thePreInstall.m_InstallCode)) { GotoDlgCtrl(&m_list); return FALSE; } } } } Label: if(!thePreInstall.LaunchWindowsInstaller(!bInstalled)) exit(0); return TRUE; }