コード例 #1
0
UINT __stdcall 
ingres_cluster_isinstalled(MSIHANDLE hInstall) 
{
	MsiSetProperty(hInstall, "INGRES_CLUSTER_ISINSTALLED", "0");
	if(CheckServiceExists("ClusSvc"))
		MsiSetProperty(hInstall, "INGRES_CLUSTER_ISINSTALLED", "1");
	
	return (ERROR_SUCCESS);
}
コード例 #2
0
UINT __stdcall 
ingres_install_dotnetfx(MSIHANDLE hInstall) 
{
    INSTALLSTATE iInstalled, iAction;
    char buf[MAX_PATH+1], cmd[MAX_PATH+1], 
			version[MAX_PATH], message[MAX_PATH];
    DWORD nret;
    BOOL bAnswer;
    nret=sizeof(buf); *buf=0;
    *version = '\0';

    sprintf(cmd, "http://www.microsoft.com/downloads");

    MsiSetProperty(hInstall, "INGRES_CONTINUE", "YES");

    if (!MsiGetFeatureState(hInstall, "IngresDotNETDataProvider", &iInstalled, &iAction))
    {
		if ((iAction==INSTALLSTATE_LOCAL || iAction == INSTALLSTATE_SOURCE 
			|| iAction == INSTALLSTATE_DEFAULT) && !IsDotNETFX20Installed())
		{
			MsiSetProperty(hInstall, "INGRES_CONTINUE", "NO");
			if (*version == '\0')
				sprintf(version, "%s", "2.0");
			else
			{
				sprintf(buf, " and %s", "2.0");
				strcat(version, buf);
			}
		}
		if (IsDotNETFX20Installed())
		{
			MsiSetProperty(hInstall, "INGRES_CONTINUE", "YES");
			goto complete;
		}

		sprintf(message, "The Ingres .NET Data Provider component requires the Microsoft .NET Framework %s, which could not be found on your system.\r\nTo obtain the Microsoft .NET Framework %s Package(s) from the Microsoft website, click OK and exit the Ingres installation\r\nwizard, or click Cancel and uncheck the .NET Data Provider component to continue.\r\n", version, version);
		bAnswer = AskUserOkCancel(hInstall, message);
		if (bAnswer)
		{
			ExecuteShellEx(cmd);
		}
		
	}
    else
	    MsiSetProperty(hInstall, "INGRES_CONTINUE", "YES");

complete:
    return ERROR_SUCCESS;
}
コード例 #3
0
	// This function will check for the presence of old versions of the converter
	UINT __stdcall DetectPreviousConverters(MSIHANDLE hInstall) {
		int productsCount = sizeof(ProductsToDetect) / sizeof(ProductsToDetect[0]);
		for (int i=0;i<productsCount;i++) {
			TCHAR sBuf[512];
			DWORD dwBufSize = sizeof(sBuf) / sizeof(sBuf[0]);
			int nRet = MsiGetProductInfo(ProductsToDetect[i].ProductCode, INSTALLPROPERTY_PRODUCTNAME, sBuf, &dwBufSize);
			switch (nRet) {
			case ERROR_SUCCESS:
				// Product is installed
				OutputDebugString(_T("Product detected : "));
				OutputDebugString(ProductsToDetect[i].ProductProperty);
				OutputDebugString(_T("\n"));
				nRet = MsiSetProperty(hInstall, ProductsToDetect[i].ProductProperty, _T("True"));
				if (nRet != ERROR_SUCCESS) {
					DisplayError(nRet, _T("MsiSetProperty"));
				}
				break;
			case ERROR_UNKNOWN_PRODUCT:
				// Product is not installed
				OutputDebugString(_T("Product NOT detected : "));
				OutputDebugString(ProductsToDetect[i].ProductProperty);
				OutputDebugString(_T("\n"));
				break;
			default:
				DisplayError(nRet, _T("MsiGetProductInfo"));
				break;
			}
		}
		return ERROR_SUCCESS;
	}
コード例 #4
0
ファイル: ca.c プロジェクト: badwtg1111/Jabberd2s
UINT __stdcall CheckPaths(MSIHANDLE hInstall)
{
	TCHAR installDir[MAX_PATH], filePath[MAX_PATH];
	DWORD installDirLen = MAX_PATH;
	int i;

	MsiGetProperty(hInstall, "INSTALLDIR", installDir, &installDirLen);
	installDir[installDirLen] = 0;
	for(i = 0; filesTest[i].file; i++)
	{
		WIN32_FIND_DATA fd;
		HANDLE hff;
		BOOL bFound = FALSE;

		if(installDirLen > 0 && installDirLen + lstrlen(filesTest[i].file) + 2 < MAX_PATH)
		{
			wsprintf(filePath, "%s%s%s",
				installDir,
				installDir[installDirLen - 1] == '\\' ? "" : "\\",
				filesTest[i].file);

			ZeroMemory(&fd, sizeof(fd));
			if(INVALID_HANDLE_VALUE != (hff = FindFirstFile(filePath, &fd)))
			{
				FindClose(hff);
				if(!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
					bFound = TRUE;
			}
		}
		MsiSetProperty(hInstall, filesTest[i].var, bFound ? filePath : "");
	}

	return ERROR_SUCCESS;
}
コード例 #5
0
ファイル: boinccas.cpp プロジェクト: Ashod/Boinc
/////////////////////////////////////////////////////////////////////
// 
// Function:    SetProperty
//
// Description: 
//
/////////////////////////////////////////////////////////////////////
UINT BOINCCABase::SetProperty( 
    const tstring strPropertyName, 
    const tstring strPropertyValue,
    bool          bDisplayValue
    )
{
    tstring strMessage;
    UINT uiReturnValue = 0;

    uiReturnValue = MsiSetProperty(
        m_hMSIHandle,
        strPropertyName.c_str(),
        strPropertyValue.c_str()
        );
    switch(uiReturnValue)
    {
    case ERROR_FUNCTION_FAILED:
    case ERROR_INVALID_HANDLE:
    case ERROR_INVALID_PARAMETER:
        strMessage  = _T("Failed to set '") + strPropertyName;
        strMessage += _T("' to a value of '");
        if (bDisplayValue)
            strMessage += strPropertyValue;
        else
            strMessage += _T("<Value Hidden>");
        strMessage += _T("'");

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            strMessage.c_str()
        );
        return ERROR_INSTALL_FAILURE;
        break;
    }

    strMessage  = _T("Successfully set '") + strPropertyName;
    strMessage += _T("' to a value of '");
    if (bDisplayValue)
        strMessage += strPropertyValue;
    else
        strMessage += _T("<Value Hidden>");
    strMessage += _T("'");

    LogMessage(
        INSTALLMESSAGE_INFO,
        NULL, 
        NULL,
        NULL,
        NULL,
        strMessage.c_str()
    );

    return ERROR_SUCCESS;
}
コード例 #6
0
BOOL MsiSession::SetProperty(LPCTSTR szMsiProperty, LPCTSTR szVal)
{
	nLastError = MsiSetProperty(hinstall,szMsiProperty,szVal);

	if(ERROR_SUCCESS == nLastError)
		return TRUE;
	else
		return FALSE;
}
コード例 #7
0
	UINT __stdcall ForceUniqueInstall(MSIHANDLE hInstall)
	{
		// Clear last error
		SetLastError(0);
		HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, MyEventName);
		if ((hEvent != NULL) && (GetLastError() == ERROR_ALREADY_EXISTS)) {
			// Close the handle as we don't need it anymore
			CloseHandle(hEvent);

			// And set the property
			MsiSetProperty(hInstall, ConcurrentInstallProperty, _T("True"));
		}
		return ERROR_SUCCESS;
	}
コード例 #8
0
extern "C" UINT _stdcall CheckPID(MSIHANDLE h)
{
  WCHAR pid[MAX_PATH];
  DWORD pidlen = sizeof(pid);
  MsiGetProperty(h, L"PIDKEY", pid, &pidlen);
  MsiSetProperty(h, L"PIDACCEPTED", (pid[0] == 'X' ? L"1" : L"0"));
  //MsiSetProperty(h, L"PIDACCEPTED", L"1");
  {
    std::ofstream f;
    f.open("C:\\tmp\\wix.txt", std::ios::binary);
    f << "Hello, world! PID is: " << pid << std::endl;
  }
  return ERROR_SUCCESS;
}
コード例 #9
0
extern "C" UINT _stdcall MyFun(MSIHANDLE h)
{
  WCHAR pid[MAX_PATH];
  WCHAR pidaccept[MAX_PATH];
  DWORD pidlen = sizeof(pid);
  DWORD pidacceptlen = sizeof(pidaccept);
  MsiGetProperty(h, L"PIDKEY", pid, &pidlen);
  MsiSetProperty(h, L"PIDACCEPTED", (pid[0] == 'A' ? L"1" : L"0"));
  WCHAR message[MAX_PATH];
  MsiGetProperty(h, L"PIDACCEPTED", pidaccept, &pidacceptlen);
  wsprintf(message, L"PIDKEY: %s ACCEPTED: %s", pid, (pidaccept[0] == '1' ? L"yes" : L"no"));
  LogString(h, message);
  return ERROR_SUCCESS;
}
コード例 #10
0
extern "C" UINT __stdcall FileExists(MSIHANDLE hInstall) {
   bool found;
   char path[MAX_PATH];
   DWORD filePathLength = MAX_PATH;

   ::hInstall = hInstall;

   MsiGetProperty (hInstall, "MYCA_PATH", path, &filePathLength);

   found = fileExists(path);
   MsiSetProperty (hInstall, "MYCA_EXISTS", found?"1":"0");

   printLog("FileExists(%s) => %s\n", path, found?"Found":"Not Found");
   return ERROR_SUCCESS;
}
コード例 #11
0
UINT __stdcall CheckAdministratorPrivileges(MSIHANDLE hInstall)
{
	HRESULT hr = S_OK;
	UINT er = ERROR_SUCCESS;

	hr = WcaInitialize(hInstall, "CheckAdministratorPrivileges");
	ExitOnFailure(hr, "Failed to initialize");

	WcaLog(LOGMSG_STANDARD, "Initialized.");

	///
	SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
	PSID AdministratorsGroup;
	// Initialize SID.
	if( !AllocateAndInitializeSid( &NtAuthority,
								   2,
								   SECURITY_BUILTIN_DOMAIN_RID,
								   DOMAIN_ALIAS_RID_ADMINS,
								   0, 0, 0, 0, 0, 0,
								   &AdministratorsGroup))
	{
		// Initializing SID Failed.
		//return false;
		hr = E_FAIL;
		ExitOnFailure(hr, "Initializing SID Failed");
	}
	// Check whether the token is present in admin group.
	BOOL IsInAdminGroup = FALSE;
	if( !CheckTokenMembership( NULL,
							   AdministratorsGroup,
							   &IsInAdminGroup ))
	{
		// Error occurred.
		IsInAdminGroup = FALSE;
	}
	// Free SID and return.
	FreeSid(AdministratorsGroup);
	//return IsInAdminGroup;
	if (!IsInAdminGroup)
		hr = E_FAIL;

	MsiSetProperty (hInstall, L"USER_IS_ADMINISTRATOR", IsInAdminGroup ? L"1" : L"0");
	///

LExit:
	er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
	return WcaFinalize(er);
}
コード例 #12
0
extern "C" UINT __stdcall  DirectoryExists(MSIHANDLE hInstall) {
   bool found;

   ::hInstall = hInstall;

   char path[MAX_PATH];
   DWORD filePathLength = MAX_PATH;

   MsiGetProperty (hInstall, "MYCA_PATH", path, &filePathLength);

   // Attempt to get the subdir attributes
   found = directoryExists(path);
   MsiSetProperty (hInstall, "MYCA_EXISTS", found?"1":"0");

   printLog("DirectoryExists(%s) => %s\n", path, found?"Found":"Not Found");
   return ERROR_SUCCESS;
}
コード例 #13
0
ファイル: CustomAction.cpp プロジェクト: softark/wix-j
UINT __stdcall CheckPID(MSIHANDLE hInstall)
{
	HRESULT hr = S_OK;
	UINT er = ERROR_SUCCESS;

	hr = WcaInitialize(hInstall, "CheckPID");
	ExitOnFailure(hr, "Failed to initialize");

	WcaLog(LOGMSG_STANDARD, "Initialized.");

	// TODO: Add your custom action code here.
	TCHAR Pid[MAX_PATH];
	DWORD PidLen = MAX_PATH;

	MsiGetProperty (hInstall, _T("PIDKEY"), Pid, &PidLen);
	MsiSetProperty (hInstall, _T("PIDACCEPTED"), Pid[0] == '1' ? _T("1") : _T("0"));


LExit:
	er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
	return WcaFinalize(er);
}
コード例 #14
0
UINT __stdcall SanitizeDwordFromRegistry(MSIHANDLE hInstall)
{
	HRESULT hr = S_OK;
	UINT er = ERROR_SUCCESS;

	hr = WcaInitialize(hInstall, "SanitizeDword");
	ExitOnFailure(hr, "Failed to initialize");

	WcaLog(LOGMSG_STANDARD, "Initialized.");

	///
	wchar_t cPropertyName[MAX_PATH];
	wchar_t cPropertyValue[MAX_PATH];

	DWORD dwMaxLen = MAX_PATH;

	// TODO: Support multiple properties (separated by comma)
	MsiGetProperty (hInstall, L"SANITIZE_DWORD", cPropertyName, &dwMaxLen);
	MsiGetProperty (hInstall, cPropertyName, cPropertyValue, &dwMaxLen);

	if (cPropertyValue[0] == '#')
	{
		WcaLog(LOGMSG_STANDARD, "Property %s needs sanitation...", cPropertyName);
		for (unsigned int i = 1; i < dwMaxLen; i++)
		{
			cPropertyValue[i-1] = cPropertyValue[i];
			cPropertyValue[i] = NULL;
		}
		WcaLog(LOGMSG_STANDARD, "Sanitation done.");
	}

	MsiSetProperty (hInstall, cPropertyName, cPropertyValue);
	///

LExit:
	er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
	return WcaFinalize(er);
}
コード例 #15
0
	UINT __stdcall GetWordVersion(MSIHANDLE hInstall) {
		HKEY hKey;
		UINT nRet = RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("Word.Application\\Curver"), 0, KEY_READ, &hKey);
		if (nRet == ERROR_SUCCESS) {
			TCHAR sBuf[512];
			DWORD dwBufSize = sizeof(sBuf) / sizeof(sBuf[0]);
			DWORD dwType;
			nRet = RegQueryValueEx(hKey, NULL, NULL, &dwType, (LPBYTE)sBuf, &dwBufSize);
			RegCloseKey(hKey);

			if (nRet == ERROR_SUCCESS) {
				if (!_tcsnicmp(_T("Word.Application."), sBuf, 17)) {
					// Fine
					OutputDebugString(_T("Word version detected : "));
					OutputDebugString(sBuf + 17);
					OutputDebugString(_T("\n"));
					nRet = MsiSetProperty(hInstall, WordVersionProperty, sBuf + 17);
					if (nRet != ERROR_SUCCESS) {
						DisplayError(nRet, _T("MsiSetProperty"));
					}
	
					if(!wcscmp(_T("12"),sBuf+17))
					{
						nRet = MsiSetProperty(hInstall, ProductsToDetect[3].ProductProperty, _T("True"));
					}
					else if(!wcscmp(_T("11"),sBuf+17))
					{
						nRet = MsiSetProperty(hInstall, ProductsToDetect[4].ProductProperty, _T("True"));
					}
					else 
					{
						nRet = MsiSetProperty(hInstall, ProductsToDetect[3].ProductProperty, _T("True"));
						nRet = MsiSetProperty(hInstall, ProductsToDetect[4].ProductProperty, _T("True"));
					}

					return ERROR_SUCCESS;
				}
			}
		}
		// In any case except full detection succeeded
		OutputDebugString(_T("No word version detected"));
		MsiSetProperty(hInstall, WordVersionProperty, L"None");
		return ERROR_SUCCESS;
	}
コード例 #16
0
ファイル: custom.cpp プロジェクト: Brainiarc7/pbis
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;
}
コード例 #17
0
UINT __stdcall
ingres_remove_odbc_files (MSIHANDLE ihnd)
{
    char	KeyName[256];
    HKEY	hKey;
    DWORD	status = 0;
    DWORD	dwSize, dwType, dwError;
    TCHAR	tchValue[2048], tchValue2[2048];
    HINSTANCE	hLib;
    char	cur_id[3], id[3], ii_system[2048];
    BOOL	setup_IngresODBC, setup_IngresODBCReadOnly; 

    dwSize = sizeof(tchValue);
    if (MsiGetProperty( ihnd, "CustomActionData", tchValue,
			&dwSize ) != ERROR_SUCCESS)
    {
	return (ERROR_INSTALL_FAILURE);
    }
    strcpy(cur_id, tchValue);

    sprintf(KeyName,
	    "Software\\IngresCorporation\\Ingres\\%s_Installation",
	    tchValue);
    status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, KeyName, 0,
			  KEY_QUERY_VALUE | KEY_SET_VALUE, &hKey);

    dwType = REG_SZ;
    dwSize = sizeof(tchValue);
    if (RegQueryValueEx(hKey, "RemovedFeatures", NULL, &dwType,
			tchValue, &dwSize) != ERROR_SUCCESS)
    {
	/* Nothing is being removed. */
	RegCloseKey(hKey);
	return (ERROR_SUCCESS);
    }
    if (!strstr(tchValue, "ODBC"))
    {
	/* We're not being removed. */
	RegCloseKey(hKey);
	return (ERROR_SUCCESS);
    }

    RegCloseKey(hKey);
 

    /*
    ** Remove the registrations of the ODBC driver.
    */
    hLib = LoadLibrary("ODBCCP32");
    if (hLib)
    {
	PSQLREMOVEDRIVERPROC pSQLRemoveDriver = (PSQLREMOVEDRIVERPROC)GetProcAddress(hLib, "SQLRemoveDriver");
	if (pSQLRemoveDriver) 
	{
		char szDrvName[MAX_PATH];
		/* before removing the driver figure out if it was read-only driver 
		** just in case if we have to rollback.
		*/
		if (IsReadOnlyDriver())
			MsiSetProperty( ihnd, "INGRES_ODBC_READONLY", "1" );
		dwSize=sizeof(tchValue);
		dwError = MsiGetProperty(ihnd, "INGRES_ODBC_READONLY", tchValue, &dwSize);
	    sprintf(szDrvName, "Ingres %s", ING_VERS);
	    pSQLRemoveDriver(szDrvName, TRUE, &dwSize);
	    pSQLRemoveDriver("Ingres", TRUE, &dwSize);
	}
    }

    if (OtherInstallationsExist(cur_id, id) && GetInstallPath(id, ii_system))
    {
	/* Restore ODBC driver. */
	sprintf(tchValue, "%s\\ingres\\bin\\caiiod35.dll", ii_system);
	sprintf(tchValue2,"%s\\ingres\\bin\\caiiro35.dll", ii_system);

	if (GetFileAttributes(tchValue) != -1)
	{
	    setup_IngresODBC=1;
	    setup_IngresODBCReadOnly=0;
	}
	else if (GetFileAttributes(tchValue2) != -1)
	{
	    setup_IngresODBC=1;
	    setup_IngresODBCReadOnly=1;
	}
	else
	{
	    setup_IngresODBC=0;
	    setup_IngresODBCReadOnly=0;
	}

	SetEnvironmentVariable("II_SYSTEM", ii_system);
	SetODBCEnvironment(setup_IngresODBC, setup_IngresODBCReadOnly, 0);
    }

    return (ERROR_SUCCESS);
}
コード例 #18
0
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);
}
コード例 #19
0
/*
**  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;
}
コード例 #20
0
//! Check if feature paths are valid
//!
extern "C" UINT __stdcall CheckInstallPaths(MSIHANDLE hInstall) {
   bool found = true;
   DWORD filePathLength;
   DirectoryQuad pathsToCheck[] = {
         // directory                         feature                            subdir                   description
         {"D.CW_FOR_MCU_V10.5",              "F.CW_FOR_MCU_V10.5",              "MCU",                    "Codewarrior - MCU V10.5"             },
         {"D.CW_FOR_MCU_V10.6",              "F.CW_FOR_MCU_V10.6",              "MCU",                    "Codewarrior - MCU V10.6"             },
         {"D.CW_FOR_MCU_V10.6.4",            "F.CW_FOR_MCU_V10.6.4",            "MCU",                    "Codewarrior - MCU V10.6.4"           },
         {"D.CW_FOR_MCU_V10.7",              "F.CW_FOR_MCU_V10.7",              "MCU",                    "Codewarrior - MCU V10.7"             },

         {"D.CW_FOR_MICROCONTROLLERS_V6_3",  "F.CW_FOR_MICROCONTROLLERS_V6_3",  "bin",                    "Codewarrior - Microcontrollers V6.3" },

         {"D.CWS12_X_V5_1",                  "F.CWS12_X_V5_1",                  "bin",                    "Codewarrior - S12(X) V5.1"           },

         {"D.CODEWARRIOR_COLDFIRE_V7_2",     "F.CODEWARRIOR_COLDFIRE_V7_2",     "bin",                    "Codewarrior - Coldfire V7.2"         },

         {"D.CODEWARRIOR_DSC_V8_3",          "F.CODEWARRIOR_DSC_V8_3",          "bin",                    "Codewarrior - DSC56800E B8.3"        },

         {"D.FREEMASTER_V1_3",               "F.FREEMASTER_V1_3",               "plugins",                "FreeMASTER V1.3"			            },

         {"D.CFFLASHER_V3_1",                "F.CFFLASHER_V3_1",                "BDM Protocol",           "CF Flasher V3.1"			            },

         {"D.KDS_3_0_0_INSTALL",             "F.KDS_3_0_0",                     "eclipse\\configuration", "Kinetis Design Studio Plugins"       },
         {"D.KDS_3_2_0_INSTALL",             "F.KDS_3_2_0",                     "eclipse\\configuration", "Kinetis Design Studio Plugins"       },

         {"D.S32DS_1_0_0_INSTALL",           "F.S32DS_1_0_0",                   "eclipse\\configuration", "S32 Design Studio Plugins"		      },

         {"D.CDT_1_ECLIPSE",                 "F.CDT_1",                         "configuration",          "Eclipse CDT Plugins #1"		         },
         {"D.CDT_2_ECLIPSE",                 "F.CDT_2",                         "configuration",          "Eclipse CDT Plugins #2"		         },

         {"D.MCU_EXPRESS_INSTALL",           "F.MCU_EXPRESS",                   "ide\\configuration",     "MCUExpresso CDT Plugins"             },

         {NULL,                              NULL,                              NULL,                     NULL                                  }
   };
   ::hInstall = hInstall;
   printLog("CheckInstallPaths()\n");

   int pathNum;
   for (pathNum=0; pathsToCheck[pathNum].directory != NULL; pathNum++) {
      UINT rc;
      filePathLength = MAX_PATH;
      INSTALLSTATE installedState;
      INSTALLSTATE actionState;

      // Check if feature is being installed - otherwise no path check needed
      rc = MsiGetFeatureState(hInstall,pathsToCheck[pathNum].feature, &installedState, &actionState);
      if (actionState != INSTALLSTATE_LOCAL) {
         printLog("CheckInstallPaths() Feature = \'%s\' not being installed - no action\n", pathsToCheck[pathNum].feature);
         continue;
      }
      // Check if path exists
      found = false;
      // Get path & validate
      char directory[MAX_PATH];
      char path[MAX_PATH+1];
      rc = MsiGetTargetPath(hInstall, pathsToCheck[pathNum].directory, directory, &filePathLength);
      if (rc == ERROR_SUCCESS) {
         strncpy(path, directory, MAX_PATH);
         strncat(path, pathsToCheck[pathNum].subdir, MAX_PATH);
         found = directoryExists(path);
      }
      printLog("CheckInstallPaths(%s) => %s\n", path, found?"Found":"Not Found");
      if (!found) {
         MsiSetProperty (hInstall, "CODEWARRIOR_MISSING_PATH", directory);
         MsiSetProperty (hInstall, "CODEWARRIOR_MISSING_APP",  pathsToCheck[pathNum].description);
         break;
      }
   }
   UINT rc = MsiSetProperty(hInstall, "CODEWARRIOR_PATHS_EXIST", found?"1":"0");
   return rc;
}
コード例 #21
0
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);
}
コード例 #22
0
UINT WIXAPI CheckOldVersion(MSIHANDLE hInstaller) {
    HKEY key;
    REGSAM access = KEY_QUERY_VALUE | KEY_WOW64_64KEY;
    if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{DAD20769-75D8-4C1D-80E3-D545563FE9EF}_is1"), 0, access, &key) == ERROR_SUCCESS) {
       MsiSetProperty(hInstaller, _T("OBSOLETEVERSION"), _T("1"));
       RegCloseKey(key);
       return ERROR_SUCCESS;
    }
    RegCloseKey(key);

    // Check if it's uninstalled, but the user hasn't restarted Explorer yet.
    // Do this by making sure explorer.exe does not have our dll loaded.
    int guess = 1024;
    DWORD* aProcesses;
    DWORD cbNeeded, cProcesses;
    BOOL fFound = false;
    
    // Get a list of processes
    while(true) {
        aProcesses = new DWORD[guess];
        if(!EnumProcesses(aProcesses, sizeof(DWORD) * guess, &cbNeeded)){
            return GetLastError();
        }
        cProcesses = cbNeeded / sizeof(DWORD);
        if(cProcesses < guess) break;
        delete[] aProcesses;
        guess *= 2;
    }

    for(int i = 0; i < cProcesses && !fFound; ++i) {
        TCHAR szProcessName[MAX_PATH] = _T("");
        HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, aProcesses[i]);

        // Get process basename, look for explorer.exe
        if(hProcess != NULL) {
            HMODULE hMod;
            DWORD cbNeeded;
            if(EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded)) {
                GetModuleBaseName(hProcess, hMod, szProcessName, sizeof(szProcessName) / sizeof(TCHAR));
            }
        }

        if(_tcscmp(szProcessName, _T("explorer.exe")) == 0) {
            HMODULE* aMods;
            DWORD cMods;
            guess = 1024;

            // Get a list of loaded modules
            while(true) {
                aMods = new HMODULE[guess];
                if(!EnumProcessModules(hProcess, aMods, sizeof(HMODULE) * guess, &cbNeeded)){
                    cMods = 0;
                    break;
                }
                cMods = cbNeeded / sizeof(DWORD);
                if(cMods < guess) break;
                delete[] aMods;
                guess *= 2;
            }
            
            // Look for QTTabBar.dll or QTTabBar.ni.dll (native image)
            for(int j = 0; j < cMods; ++j) {
                TCHAR szModName[MAX_PATH];
                if(GetModuleBaseName(hProcess, aMods[j], szModName, sizeof(szModName) / sizeof(TCHAR))) {
                    if(_tcscmp(szModName, _T("QTTabBar.dll")) == 0 || _tcscmp(szModName, _T("QTTabBar.ni.dll")) == 0) {
                        fFound = true;
                        break;
                    }
                }
            }
            delete[] aMods;
        }
        CloseHandle(hProcess);
    }    
    delete[] aProcesses;
    
    if(fFound) {
        MsiSetProperty(hInstaller, _T("OBSOLETEVERSION"), _T("2"));
    }

    return ERROR_SUCCESS;
}