UINT __stdcall ingres_set_rep_reg_entries (MSIHANDLE ihnd) { HKEY hKey; char KeyName[256]; int status = 0; DWORD dwSize, dwDisposition, dwType; TCHAR tchValue[2048]; INSTALLSTATE iInstalled, iAction; BOOL bInstalled, bVer25, bVersion9X; char szID[3], szComponentGUID[39], szProductGUID[39]; bInstalled=bVer25=bVersion9X=FALSE; if (!MsiGetFeatureState(ihnd, "IngresReplicator", &iInstalled, &iAction)) { if (iInstalled==INSTALLSTATE_ABSENT && iAction==INSTALLSTATE_UNKNOWN) return ERROR_SUCCESS; } else return ERROR_SUCCESS; dwSize = sizeof(tchValue); if (MsiGetProperty( ihnd, "II_INSTALLATION", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { sprintf(KeyName, "Software\\IngresCorporation\\Ingres\\%s_Installation", tchValue); status = RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition); } if (iInstalled == INSTALLSTATE_LOCAL) { /* ** Set up the InstalledFeatures registry key for possible use. */ dwType = REG_SZ; dwSize = sizeof(tchValue); if (RegQueryValueEx(hKey, "InstalledFeatures", NULL, &dwType, tchValue, &dwSize) != ERROR_SUCCESS) { strcpy(tchValue, "REP"); } else if (!strstr(tchValue, "REP")) strcat(tchValue, ",REP"); status = RegSetValueEx( hKey, "InstalledFeatures", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } dwSize=sizeof(szID); MsiGetProperty(ihnd, "II_INSTALLATION", szID, &dwSize); if (!_stricmp(szID, "II")) strcpy(szComponentGUID, "{531C8AD8-2F05-11D5-BDFC-00B0D0AD4485}"); else { int idx; idx = (toupper(szID[0]) - 'A') * 26 + toupper(szID[1]) - 'A'; if (idx <= 0) idx = (toupper(szID[0]) - 'A') * 26 + toupper(szID[1]) - '0'; sprintf(szComponentGUID, "{531C8AD8-2F05-11D5-%04X-%012X}", idx, idx*idx); } dwSize=sizeof(szProductGUID); MsiGetProperty(ihnd, "ProductCode", szProductGUID, &dwSize); if (iAction==INSTALLSTATE_ABSENT && GetRefCount(szComponentGUID, szProductGUID)==0) { /* ** Set up the RemovedFeatures registry key for use later on. */ dwType = REG_SZ; dwSize = sizeof(tchValue); if (RegQueryValueEx(hKey, "RemovedFeatures", NULL, &dwType, tchValue, &dwSize) != ERROR_SUCCESS) { strcpy(tchValue, "REP"); } else if (!strstr(tchValue, "REP")) strcat(tchValue, ",REP"); status = RegSetValueEx( hKey, "RemovedFeatures", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); RegCloseKey(hKey); return (status==ERROR_SUCCESS ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE); } else if (iInstalled == INSTALLSTATE_LOCAL || iAction != INSTALLSTATE_LOCAL) { dwSize = sizeof(tchValue); if (!MsiGetProperty(ihnd, "INGRES_UPGRADE", tchValue, &dwSize) && strcmp(tchValue, "2")) { RegCloseKey(hKey); return (ERROR_SUCCESS); } } strcpy(tchValue, "TRUE"); status = RegSetValueEx( hKey, "Ingres/Replicator", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 ); dwType = REG_SZ; dwSize = sizeof(tchValue); if (RegQueryValueEx(hKey, "PostInstallationNeeded", NULL, &dwType, tchValue, &dwSize) != ERROR_SUCCESS) { dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_SERVICEAUTO", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { char szBuf[MAX_PATH+1]; sprintf(szBuf, "Ingres_Database_%s", szID); if (CheckServiceExists(szBuf)) { if (IsServiceStartupTypeAuto(szBuf)) sprintf(tchValue, "1"); else sprintf(tchValue, "0"); status = RegSetValueEx( hKey, "serviceauto", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } else status = RegSetValueEx( hKey, "serviceauto", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_SERVICELOGINID", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { status = RegSetValueEx( hKey, "serviceloginid", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_SERVICEPASSWORD", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { /* Clear the password from the property table. */ MsiSetProperty(ihnd, "INGRES_SERVICEPASSWORD", ""); MsiSetProperty(ihnd, "INGRES_SERVICEPASSWORD2", ""); status = RegSetValueEx( hKey, "servicepassword", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } strcpy(tchValue, "YES"); status = RegSetValueEx( hKey, "PostInstallationNeeded", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); MsiSetProperty(ihnd, "INGRES_POSTINSTALLATIONNEEDED", "1"); dwSize = sizeof(tchValue); MsiGetProperty(ihnd, "INGRES_RSP_LOC", tchValue, &dwSize); if (tchValue[0] && strcmp(tchValue, "0")) { strcpy(tchValue, "YES"); RegSetValueEx( hKey, "SilentInstall", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); MsiGetProperty(ihnd, "Installed", tchValue, &dwSize); if (tchValue[0]) bInstalled=TRUE; dwSize = sizeof(tchValue); MsiGetProperty(ihnd, "INGRES_VER25", tchValue, &dwSize); if (tchValue[0] && !strcmp(tchValue, "1")) bVer25=0; dwSize=sizeof(tchValue); MsiGetProperty(ihnd, "Version9X", tchValue, &dwSize); if (tchValue[0]) bVersion9X=TRUE; if (!bInstalled && !bVer25 && bVersion9X) { strcpy(tchValue, "YES"); RegSetValueEx( hKey, "RebootNeeded", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 ); } } return (status == ERROR_SUCCESS ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE); }
UINT __stdcall ingres_set_odbc_reg_entries (MSIHANDLE ihnd) { HKEY hKey, hKey2; char KeyName[256], KeyNameODBC[256]; int status = 0; DWORD dwSize, dwDisposition, dwType; TCHAR tchValue[2048]; INSTALLSTATE iInstalled, iAction; BOOL ODBC_Installed = FALSE; BOOL bInstalled, bVer25, bVersion9X; char szCode[3], szComponent[39], szProduct[39]; ODBC_Installed = FALSE; bInstalled=bVer25=bVersion9X=FALSE; if (!MsiGetComponentState(ihnd, "Bin.70DC58B6_2D77_11D5_BDFC_00B0D0AD4485", &iInstalled, &iAction)) { if (iInstalled==INSTALLSTATE_ABSENT && iAction==INSTALLSTATE_UNKNOWN) return ERROR_SUCCESS; } else return ERROR_SUCCESS; dwSize = sizeof(tchValue); if (MsiGetProperty( ihnd, "II_INSTALLATION", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { strcpy(szCode, tchValue); sprintf(KeyName, "Software\\IngresCorporation\\Ingres\\%s_Installation", tchValue); status = RegCreateKeyEx(HKEY_LOCAL_MACHINE, KeyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition); } dwSize = sizeof(szProduct); MsiGetProperty(ihnd, "ProductCode", szProduct, &dwSize); if (!_stricmp(szCode, "II")) strcpy(szComponent, "{8FA72934-D481-405A-AD90-B7BDE7988247}"); else { int idx; idx = (toupper(szCode[0]) - 'A') * 26 + toupper(szCode[1]) - 'A'; if (idx <= 0) idx = (toupper(szCode[0]) - 'A') * 26 + toupper(szCode[1]) - '0'; sprintf(szComponent, "{8FA72934-D481-405A-%04X-%012X}", idx, idx*idx); } dwSize=sizeof(tchValue); MsiGetComponentPath(szProduct, szComponent, tchValue, &dwSize); if (tchValue[0] && iInstalled==INSTALLSTATE_LOCAL) ODBC_Installed = TRUE; if (ODBC_Installed) { /* ** Set up the InstalledFeatures registry key for possible use. */ dwType = REG_SZ; dwSize = sizeof(tchValue); if (RegQueryValueEx(hKey, "InstalledFeatures", NULL, &dwType, tchValue, &dwSize) != ERROR_SUCCESS) { strcpy(tchValue, "ODBC"); } else strcat(tchValue, ",ODBC"); status = RegSetValueEx( hKey, "InstalledFeatures", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } if (iAction==INSTALLSTATE_ABSENT) { /* ** Set up the RemovedFeatures registry key for use later on. */ dwType = REG_SZ; dwSize = sizeof(tchValue); if (RegQueryValueEx(hKey, "RemovedFeatures", NULL, &dwType, tchValue, &dwSize) != ERROR_SUCCESS) { strcpy(tchValue, "ODBC"); } else strcat(tchValue, ",ODBC"); status = RegSetValueEx( hKey, "RemovedFeatures", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); RegCloseKey(hKey); return (status==ERROR_SUCCESS ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE); } else if (ODBC_Installed || iAction!=INSTALLSTATE_LOCAL) { dwSize = sizeof(tchValue); if (!MsiGetProperty(ihnd, "INGRES_UPGRADE", tchValue, &dwSize) && strcmp(tchValue, "2")) { RegCloseKey(hKey); return (ERROR_SUCCESS); } } dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_ODBC", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { status = RegSetValueEx( hKey, "setup_ingresodbc", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_ODBC_READONLY", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { status = RegSetValueEx( hKey, "setup_ingresodbcreadonly", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } //check if read-only odbc driver was installed by ODBC patch installer if ((!strcmp(tchValue, "") || !strcmp(tchValue, "0")) && ODBC_Installed && iAction==INSTALLSTATE_LOCAL) { sprintf(KeyNameODBC, "SOFTWARE\\ODBC\\ODBCINST.INI\\Ingres"); if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, KeyNameODBC, 0, KEY_QUERY_VALUE, &hKey2)) { /* the comment out part is a better way of doing the check but Ingres isn't ready for it ** b/c of older releases DriverReadOnly can't be trusted yet. */ /*dwSize=sizeof(tchValue); if ((status = RegQueryValueEx(hKey2, "DriverReadOnly", 0, NULL, (BYTE *)tchValue, &dwSize)) == ERROR_SUCCESS) { if (!strcmp(tchValue, "Y")) status = RegSetValueEx( hKey, "setup_ingresodbcreadonly", 0, REG_SZ, "1", strlen("1") + 1 ); } else if (status == ERROR_FILE_NOT_FOUND) {*/ dwSize=sizeof(tchValue); if (!RegQueryValueEx(hKey2, "Driver", 0, NULL, (BYTE *)tchValue, &dwSize)) { if (strstr(tchValue, "caiiro") > 0) { status = RegSetValueEx( hKey, "setup_ingresodbcreadonly", 0, REG_SZ, "1", strlen("1") + 1 ); //Update the property for future possible upgrades of the release MsiSetProperty( ihnd, "INGRES_ODBC_READONLY", "1" ); } } //} RegCloseKey(hKey2); } } strcpy(tchValue, "TRUE"); status = RegSetValueEx( hKey, "Ingres ODBC Driver", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 ); dwType = REG_SZ; dwSize = sizeof(tchValue); if (RegQueryValueEx(hKey, "PostInstallationNeeded", NULL, &dwType, tchValue, &dwSize) != ERROR_SUCCESS) { dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_SERVICEAUTO", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { char szBuf[MAX_PATH+1]; sprintf(szBuf, "Ingres_Database_%s", szCode); if (CheckServiceExists(szBuf)) { if (IsServiceStartupTypeAuto(szBuf)) sprintf(tchValue, "1"); else sprintf(tchValue, "0"); status = RegSetValueEx( hKey, "serviceauto", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } else status = RegSetValueEx( hKey, "serviceauto", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_SERVICELOGINID", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { status = RegSetValueEx( hKey, "serviceloginid", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); if (status || MsiGetProperty( ihnd, "INGRES_SERVICEPASSWORD", tchValue, &dwSize ) != ERROR_SUCCESS) { return (ERROR_INSTALL_FAILURE); } else { /* Clear the password from the property table. */ MsiSetProperty(ihnd, "INGRES_SERVICEPASSWORD", ""); MsiSetProperty(ihnd, "INGRES_SERVICEPASSWORD2", ""); status = RegSetValueEx( hKey, "servicepassword", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); } strcpy(tchValue, "YES"); status = RegSetValueEx( hKey, "PostInstallationNeeded", 0, REG_SZ, tchValue, strlen(tchValue) + 1 ); MsiSetProperty(ihnd, "INGRES_POSTINSTALLATIONNEEDED", "1"); dwSize = sizeof(tchValue); MsiGetProperty(ihnd, "INGRES_RSP_LOC", tchValue, &dwSize); if (tchValue[0] && strcmp(tchValue, "0")) { strcpy(tchValue, "YES"); RegSetValueEx( hKey, "SilentInstall", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 ); } dwSize = sizeof(tchValue); MsiGetProperty(ihnd, "Installed", tchValue, &dwSize); if (tchValue[0]) bInstalled=TRUE; dwSize = sizeof(tchValue); MsiGetProperty(ihnd, "INGRES_VER25", tchValue, &dwSize); if (tchValue[0] && !strcmp(tchValue, "1")) bVer25=0; dwSize=sizeof(tchValue); MsiGetProperty(ihnd, "Version9X", tchValue, &dwSize); if (tchValue[0]) bVersion9X=TRUE; if (!bInstalled && !bVer25 && bVersion9X) { strcpy(tchValue, "YES"); RegSetValueEx( hKey, "RebootNeeded", 0, REG_SZ, (CONST BYTE *)&tchValue, strlen(tchValue) + 1 ); } } return (status == ERROR_SUCCESS ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE); }