Esempio n. 1
0
BOOL CDialog::OnCommand(int id, int code)
{
	switch(id)
	{
	case IDOK:
		if(m_bNewVersion)
		{
			if( Uninstall() )
				return Install();
			else
			{
				// Write something to RunOnce registry key
				// Keep in mind that Uninstall() already did!
				SetMessage( IDS_RESTARTBEFOREUPDATE );
			}
		}
		else if(m_bUnInstall)
			return Uninstall();
		else
			return Install();
		break;

	case IDCANCEL:
		if(m_bUnInstall)
			CreateUninstall(TRUE);
		::PostQuitMessage(1);
		break;
	}
	return FALSE;
}
Esempio n. 2
0
int Backend::GoBack(){
    QThread *worker = new QThread();;
    this->moveToThread(worker);
    worker->start();

    connect(this, SIGNAL(Uninstall()), this, SLOT(AsyncUninstall()));
    emit Uninstall();

    return Success;
}
Esempio n. 3
0
int OnUninstall(HWND hDlg)
{
  SetWindowText(GetDlgItem(hDlg, IDC_QUESTION_TEXT), L"");
  ShowWindow(GetDlgItem(hDlg, IDC_BTN_UNINSTALL), SW_HIDE);
  ShowWindow(GetDlgItem(hDlg, IDCANCEL), SW_HIDE);
  ShowWindow(GetDlgItem(hDlg, IDC_PROGRESS), SW_SHOW);
  SendMessage(GetDlgItem(hDlg, IDC_PROGRESS), PBM_SETRANGE, 0, (LPARAM) MAKELPARAM (0, c_nMaxDirs));
  SendMessage(GetDlgItem(hDlg, IDC_PROGRESS), PBM_SETPOS, 0, 0);

  UpdateWindow(hDlg); // make sure the text is drawn
  
  int ret = Uninstall(hDlg);

  if (ret == ErrOK)
  {
    SetWindowText(GetDlgItem(hDlg, IDC_STATIC_TEXT), Strings.GetString(StrID_UninstalledSuccessfully));
  }
  else
  {
    //TODO: Localize this message. It might be shown later when the errors will be handled
    SetWindowText(GetDlgItem(hDlg, IDC_STATIC_TEXT), L"There were errors during uninstallation.");
  }

  ShowWindow(GetDlgItem(hDlg, IDC_PROGRESS), SW_HIDE);
  ShowWindow(GetDlgItem(hDlg, IDOK), SW_SHOW);

  return ret;
}
Esempio n. 4
0
void Vehicle::Dismiss()
{
    sLog->outDebug(LOG_FILTER_VEHICLES, "Vehicle::Dismiss Entry: %u, GuidLow %u", _creatureEntry, _me->GetGUIDLow());
    Uninstall();
    _me->DestroyForNearbyPlayers();
    _me->AddObjectToRemoveList();
}
Esempio n. 5
0
status_t
BTeamDebugger::Install(team_id team)
{
	Uninstall();

	// create a debugger port
	char name[B_OS_NAME_LENGTH];
	snprintf(name, sizeof(name), "debugger for team %" B_PRId32, team);
	fDebuggerPort = create_port(100, name);
	if (fDebuggerPort < 0)
		return fDebuggerPort;

	port_id nubPort = install_team_debugger(team, fDebuggerPort);
	if (nubPort < 0) {
		delete_port(fDebuggerPort);
		fDebuggerPort = -1;
		return nubPort;
	}

	status_t error = BDebugContext::Init(team, nubPort);
	if (error != B_OK) {
		remove_team_debugger(team);
		delete_port(fDebuggerPort);
		fDebuggerPort = -1;
		return error;
	}

	return B_OK;
}
Esempio n. 6
0
STDAPI DllInstall( BOOL bInstall, LPCWSTR pszCmdLine )
{
	// To install into System32\ShellExt
	// regsvr32.exe /i /n HashCheck.dll
	//
	// To install without registering an uninstaller
	// regsvr32.exe /i:"NoUninstall" /n HashCheck.dll
	//
	// To install in-place (without copying the .dll anywhere)
	// regsvr32.exe /i:"NoCopy" /n HashCheck.dll
	//
	// To install with both options above
	// regsvr32.exe /i:"NoUninstall NoCopy" /n HashCheck.dll
	//
	// To uninstall
	// regsvr32.exe /u /i /n HashCheck.dll
	//
	// To install/uninstall silently
	// regsvr32.exe /s ...
	//
	// DllInstall can also be invoked from a RegisterDlls INF section or from
	// a UnregisterDlls INF section, if the registration flags are set to 2.
	// Consult the documentation for RegisterDlls/UnregisterDlls for details.

	return( (bInstall) ?
		Install(pszCmdLine == NULL || StrStrIW(pszCmdLine, L"NoUninstall") == NULL,
                pszCmdLine == NULL || StrStrIW(pszCmdLine, L"NoCopy")      == NULL) :
		Uninstall()
	);
}
Esempio n. 7
0
void CServiceModule::SetupAsLocalServer()
{
    USES_CONVERSION;
    CRegKey keyClasses,key;
    LPOLESTR pCLSID;

    Uninstall();

    if (keyClasses.Open(HKEY_CLASSES_ROOT, _T("CLSID")) != ERROR_SUCCESS)
        return;

    _ATL_OBJMAP_ENTRY* pEntry = m_pObjMap;
    while (pEntry->pclsid != NULL)
    {
        StringFromCLSID(*pEntry->pclsid, &pCLSID);
        CString csTemp = pCLSID;
        if (key.Open(keyClasses, (LPCTSTR)csTemp) == ERROR_SUCCESS)
        {
            TCHAR szModule[_MAX_PATH];
            key.DeleteValue(_T("AppID"));
            key.DeleteValue(_T("_LocalServer32"));
            GetModuleFileName(GetModuleInstance(), szModule, _MAX_PATH);
            key.SetKeyValue(_T("LocalServer32"), szModule, _T(""));
        }
        pEntry++;
    }
}
Esempio n. 8
0
	inline HRESULT RegisterAppId(bool bService = false) throw()
	{
		if (!Uninstall())
			return E_FAIL;

		HRESULT hr = UpdateRegistryAppId(TRUE);
		if (FAILED(hr))
			return hr;

		CRegKey keyAppID;
		LONG lRes = keyAppID.Open(HKEY_CLASSES_ROOT, _T("AppID"), KEY_WRITE);
		if (lRes != ERROR_SUCCESS)
			return AtlHresultFromWin32(lRes);

		CRegKey key;

		lRes = key.Create(keyAppID, GetAppIdT());
		if (lRes != ERROR_SUCCESS)
			return AtlHresultFromWin32(lRes);

		key.DeleteValue(_T("LocalService"));

		if (!bService)
			return S_OK;

		key.SetStringValue(_T("LocalService"), m_szServiceName);

		// Create service
		if (!Install())
			return E_FAIL;
		return S_OK;
	}
Esempio n. 9
0
CHook::~CHook()
{
	if ( Installed() )
	{
		Uninstall();
	}

	if ( m_lpBack != NULL )
	{
		delete [] m_lpBack;
		m_lpBack = NULL;
	}

	if ( m_pMProt != NULL )
	{
		MemoryHackingFactory::DestroyMProt( m_pMProt );
		m_pMProt = NULL;
	}

	if ( m_pMAlloc != NULL )
	{
		MemoryHackingFactory::DestroyMAlloc( m_pMAlloc );
		m_pMProt = NULL;
	}
}
Esempio n. 10
0
bool	DumpInstaller::Install(Dumper* dumper, int level)
{
	globalDumper = dumper;
	globalDumpLevel = level;

	// win32 api handler
	if (prevUEFilter == NULL) prevUEFilter = ::SetUnhandledExceptionFilter(TopLevelFilter);

	// crt handler
	if (prevPCHandler == NULL) prevPCHandler = ::_set_purecall_handler(CrtPurecallHandler);
	if (prevIPHandler == NULL) prevIPHandler = ::_set_invalid_parameter_handler(CrtInvalidParameterHandler);

	if (previousNewMode == -1) previousNewMode = ::_set_new_mode(1); // Force malloc() to call new handler too
	if (previousNewHandler == NULL) previousNewHandler = ::_set_new_handler(CrtNewHandler);

	if (previousSIGABRTHandler == NULL) previousSIGABRTHandler = ::signal(SIGABRT, SignalHandler);
	if (previousSIGFPEHandler == NULL) previousSIGFPEHandler = ::signal(SIGFPE, SignalHandler);
	if (previousSIGILLHandler == NULL) previousSIGILLHandler = ::signal(SIGILL, SignalHandler);
	if (previousSIGSEGVHandler == NULL) previousSIGSEGVHandler = ::signal(SIGSEGV, SignalHandler);
	if (previousSIGTERMHandler == NULL) previousSIGTERMHandler = ::signal(SIGTERM, SignalHandler);

	if (previousCrtReportMode == -1) previousCrtReportMode = ::_CrtSetReportMode(_CRT_ASSERT, 0);

	InstallPerThread();

	if (DumpRunner::Start() == false)
	{
		Uninstall();
		return false;
	}

	return true;
}
void ServiceUninstall::PreUninstall()
{
	ip = new IniParser();
	ip->Parse(UninstallIniPath);
	if (ip->Error != 0)
	{
		if (dialog)
		{
			String s = "Errore durante il parse del file INI: " + to_wstring(ip->Error);
			MessageBox(dialog->m_hWnd, s.lpcwstr(), _T("INI Parse Error"), 0);
			dialog->EndDialog(-1);
		}
		return;
	}

	String s = "Uninstall "+ ip->AppName + " - "+ ip->AppVersion.getVersion();

	if (dialog)
	{
		SetDlgItemText(dialog->m_hWnd, IDC_STATIC_TITOLO, s.lpcwstr());
		SetWindowText(dialog->m_hWnd, s.lpcwstr());
	}
	



	if (dialog)
		UninstallGUI();
	else
		Uninstall();

}
Esempio n. 12
0
    int win_svc_base::Main( int argc, char * argv[] )
    {
        //////////////////////////////////////////////////////////////////////////
        /// 命令行参数解析
        boost::program_options::options_description opts;
        opts.add_options()
            ("help", "options: --install --uninstall")
            ("install", "")
            ("uninstall", "")
            ("auto-start", "");

        boost::program_options::store(
            boost::program_options::parse_command_line(argc, argv, opts)
            , m_vm );

        //////////////////////////////////////////////////////////////////////////
        /// 定义SERVICE_TABLE_ENTRY DispatchTable[] 结构
        SERVICE_TABLE_ENTRYA DispatchTable[2] = 
        {
            {(char*)GetServiceName(), (LPSERVICE_MAIN_FUNCTIONA)GetServiceStartFunction()},                  
            {NULL, NULL}
        };

        if ( m_vm.count("help") )
        {
            /// 帮助
            std::cout << opts << std::endl;
        }
        else if ( m_vm.count("install") )
        {
            bool bAutoStart = (m_vm.count("auto-start") > 0);
            /// 安装服务
            if ( Install(bAutoStart) )
            {
                std::cout << "安装成功!" << std::endl;
                OnInstall(bAutoStart);
            }
            else
                std::cout << "安装失败!" << std::endl;
        }
        else if ( m_vm.count("uninstall") )
        {
            /// 卸载服务
            if ( Uninstall() )
                std::cout << "卸载成功!" << std::endl;
            else
                std::cout << "卸载失败!" << std::endl;
        }
        else
        {
            /// OS启动该程序
            BOOL bSuccessed = ::StartServiceCtrlDispatcherA(DispatchTable);
            //if (bSuccessed)
            //    LOG << "服务入口函数注册成功!" << std::endl;
            //else
            //    LOG << "服务入口函数注册失败!" << std::endl;
        }
        return 0;
    }
Esempio n. 13
0
void Vehicle::Dismiss()
{
    sLog.outDebug("Vehicle::Dismiss %u", me->GetEntry());
    Uninstall();
    me->SendObjectDeSpawnAnim(me->GetGUID());
    me->CombatStop();
    me->AddObjectToRemoveList();
}
Esempio n. 14
0
void
BPackageManager::Uninstall(const char* const* packages, int packageCount)
{
	BSolverPackageSpecifierList packagesToUninstall;
	if (!packagesToUninstall.AppendSpecifiers(packages, packageCount))
		throw std::bad_alloc();
	Uninstall(packagesToUninstall);
}
Esempio n. 15
0
void Vehicle::Dismiss()
{
	if (GetBase()->GetTypeId() != TYPEID_UNIT)
		return;

	sLog->outDebug(LOG_FILTER_VEHICLES, "Vehicle::Dismiss Entry: %u, GuidLow %u", _creatureEntry, _me->GetGUIDLow());
	Uninstall();
	GetBase()->ToCreature()->DespawnOrUnsummon();
}
Esempio n. 16
0
	long ServiceModule::RegisterServer(bool bService)
	{
		LOG4CPLUS_DEBUG(log,"register server.");
		Uninstall();
		if (bService)
		{
			return Install();
		}
		return 0;
	}
Esempio n. 17
0
// Returns TRUE if it found an arg it recognised, FALSE if not
// Note: processing some arguments causes output to stdout to be generated.
BOOL CNTService::ParseStandardArgs(int argc, char* argv[])
{
    // See if we have any command line args we recognise
    if (argc <= 1) return FALSE;

    if (_stricmp(argv[1], "-v") == 0) {

        // Spit out version info
        _tprintf(_T("%s Version %d.%d\n"),
               m_szServiceName, m_iMajorVersion, m_iMinorVersion);
        _tprintf(_T("The service is %s installed\n"),
               IsInstalled() ? _T("currently") : _T("not"));
        return TRUE; // say we processed the argument

    } else if (_stricmp(argv[1], "-i") == 0) {

        // Request to install.
        if (IsInstalled()) {
            _tprintf(_T("%s is already installed\n"), m_szServiceName);
        } else {
            // Try and install the copy that's running
            if (Install()) {
                _tprintf(_T("%s installed\n"), m_szServiceName);
            } else {
                _tprintf(_T("%s failed to install. Error %d\n"),
					m_szServiceName, GetLastError());
            }
        }
        return TRUE; // say we processed the argument

    } else if (_stricmp(argv[1], "-u") == 0) {

        // Request to uninstall.
        if (!IsInstalled()) {
            _tprintf(_T("%s is not installed\n"), m_szServiceName);
        } else {
            // Try and remove the copy that's installed
            if (Uninstall()) {
                // Get the executable file path
                TCHAR szFilePath[_MAX_PATH];
                ::GetModuleFileName(NULL, szFilePath, sizeof(szFilePath));
                _tprintf(_T("%s removed. (You must delete the file (%s) yourself.)\n"),
                       m_szServiceName, szFilePath);
            } else {
                _tprintf(_T("Could not remove %s. Error %d\n"),
					m_szServiceName, GetLastError());
            }
        }
        return TRUE; // say we processed the argument
    
    }
         
    // Don't recognise the args
    return FALSE;
}
Esempio n. 18
0
//-----------------------------------------------------------------------------
// main()
//-----------------------------------------------------------------------------
// 
//-----------------------------------------------------------------------------
int main(int argc, _TCHAR* argv[])
{
	int rc=0;
	
	TRACE_OPEN();
	TRACE((TRACE_ENTER,_F_,""));
	SERVICE_TABLE_ENTRY st[] =
    {
        { "swSSORecoverSvc", (LPSERVICE_MAIN_FUNCTION)ServiceMain },
        { NULL, NULL }
    };
	gdwThreadID = GetCurrentThreadId();
	ghServiceStatus = NULL;
    gServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
    gServiceStatus.dwCurrentState = SERVICE_STOPPED;
    gServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
    gServiceStatus.dwWin32ExitCode = 0;
    gServiceStatus.dwServiceSpecificExitCode = 0;
    gServiceStatus.dwCheckPoint = 0;
    gServiceStatus.dwWaitHint = 0;
	if (argc==2)
	{
		if (strcmp(argv[1],"install")==0)
		{
			if (IsInstalled()) { printf ("Already installed\n"); goto end; }
			rc=Install();
			if (rc==0)
				printf("Service installed successfully\n"); 
			else
				printf("Service installation failed\n");
		}
		else if (strcmp(argv[1],"uninstall")==0)
		{
			if (!IsInstalled()) { printf ("Not installed\n"); goto end; }
			rc=Uninstall();
			if (rc==0)
				printf("Service uninstalled successfully\n"); 
			else
				printf("Service installation failed\n");
		}
		else
			{ Usage(); rc=-1; goto end; }
	}
	else if (argc==1)
	{ 
		StartServiceCtrlDispatcher(st);
	}
	else 
		{ Usage(); rc=-1; goto end; }
end:
	TRACE((TRACE_LEAVE,_F_,""));
	TRACE_CLOSE();
	return rc;
}
Esempio n. 19
0
void Vehicle::Dismiss()
{
    if (GetBase()->GetTypeId() != TYPEID_UNIT)
        return;

#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
    sLog->outDebug(LOG_FILTER_VEHICLES, "Vehicle::Dismiss Entry: %u, GuidLow %u", _creatureEntry, _me->GetGUIDLow());
#endif
    Uninstall();
    GetBase()->ToCreature()->DespawnOrUnsummon();
}
Esempio n. 20
0
void XBMCHelper::HandleLaunchAgent()
{
  int oldAlwaysOn = m_alwaysOn;
  m_alwaysOn = CSettings::Get().GetBool(CSettings::SETTING_INPUT_APPLEREMOTEALWAYSON);

  // Installation/uninstallation.
  if (oldAlwaysOn == false && m_alwaysOn == true)
    Install();
  if (oldAlwaysOn == true && m_alwaysOn == false)
    Uninstall();
}
Esempio n. 21
0
void CrashRptAPITests::Test_AddFile()
{   
  LPVOID pState = InstallW(NULL, L"*****@*****.**", L"Error report");
  TEST_ASSERT(pState==NULL);

  AddFileW(NULL, L"abc.log", L"Log!");

  AddFileA(NULL, "abc.log", "Log!");
  
  __TEST_CLEANUP__;

  Uninstall(NULL);
}
Esempio n. 22
0
inline HRESULT CServiceModule::UnregisterServer()
{
    // Remove service entries
    UpdateRegistryFromResource(IDR_Transport, FALSE);
    // Remove service
//	CRouter::Uninstall();

    Uninstall();
    // Remove object entries
    CComModule::UnregisterServer(TRUE);
	::CoUninitialize();

    return S_OK;
}
Esempio n. 23
0
/**
	@param nArgs Number of command line arguments
	@param pArgs Pointer to an array of command line arguments
	@param bNoUI Reference to a silent command flag, filled upon exit
	@param lpRelativeDriverFolder Folder name (relative to the current module) where the printer driver files can be found
	@return true if any command lines variables were detected and acted upon

	Command line usage:
	To install the printer:
	<app.exe> [/NoUI] /InstallPrinter
	To uninstall the printer:
	<app.exe> [/NoUI] /UninstallPrinter 
	Note that the object must be initialized for this to work!
*/
bool PrinterInstall::DoCommandLine(int nArgs, TCHAR** pArgs, bool& bNoUI, LPCTSTR lpRelativeDriverFolder)
{
	// Initialize stuff
	bNoUI = false;
	ResetError();

	// Go over variables
	for (int i = 1; i < nArgs; i++)
	{
		if (_tcscmp(pArgs[i], PARAM_NOUI) == 0)
			// NoUI (silent) parameter
			bNoUI = true;
		else if (_tcscmp(pArgs[i], PARAM_INSTALLPRINTER) == 0)
		{
			// Printer installation:
			TCHAR cPath[MAX_PATH + 2];
			// Retrieve the current module path
			if (!::GetModuleFileName(NULL, cPath, MAX_PATH + 1))
				// Can't?!
				SetError(-100);
			else
			{
				// Remove the actual module name (we need the folder)
				TCHAR* pSlash = _tcsrchr(cPath, '\\');
				if (pSlash == NULL)
					SetError(-101);
				else
				{
					// Add the printer driver folder
					*(pSlash + 1) = '\0';
					_tcscat_s(cPath, _S(cPath), lpRelativeDriverFolder);
					// And install
					Install(cPath, NULL, cPath);
				}
			}
			// We did something here
			return true;
		}
		else if (_tcscmp(__targv[i], PARAM_REMOVEPRINTER) == 0)
		{
			// Printer removal
			Uninstall(NULL);
			return true;
		}
	}

	// We didn't do nothing
	return false;
}
Esempio n. 24
0
void CrashRptAPITests::Test_InstallA()
{   
  // Test InstallA 
  
  // Should succeed
  LPVOID pState = InstallA(NULL, "*****@*****.**", "Error report");
  TEST_ASSERT(pState==NULL);

  // Call twice - should fail
  InstallA(NULL, "*****@*****.**", "Error report");
  
  __TEST_CLEANUP__;

  Uninstall(NULL);
}
Esempio n. 25
0
inline HRESULT CServiceModule::UnregisterServer()
{
    HRESULT hr = CoInitialize(NULL);
    if (FAILED(hr))
        return hr;

    // Remove service entries
    UpdateRegistryFromResource(IDR_Lobby, FALSE);
    // Remove service
    Uninstall();
    // Remove object entries
    CComModule::UnregisterServer(TRUE);
    CoUninitialize();
    return S_OK;
}
Esempio n. 26
0
int main(int argc, char* argv[])
{
    argc; // this is to avoid C4100 unreferenced formal parameter warning
    argv; // this is to avoid C4100 unreferenced formal parameter warning

    // Install crash reporting

    CR_INSTALL_INFO info;
    memset(&info, 0, sizeof(CR_INSTALL_INFO));
    info.cb = sizeof(CR_INSTALL_INFO);             // Size of the structure
    info.pszAppName = _T("CrashRpt Console Test"); // App name
    info.pszAppVersion = _T("1.0.0");              // App version
    info.pszEmailSubject = _T("CrashRpt Console Test 1.0.0 Error Report"); // Email subject
    info.pszEmailTo = _T("*****@*****.**");      // Email recipient address

    // Install crash handlers
    int nInstResult = crInstall(&info);            
    assert(nInstResult==0);

    // Check result
    if(nInstResult!=0)
    {
        TCHAR buff[256];
        crGetLastErrorMsg(buff, 256); // Get last error
        _tprintf(_T("%s\n"), buff); // and output it to the screen
        return FALSE;
    }

    printf("Press Enter to simulate a null pointer exception or any other key to exit...\n");
    int n = _getch();
    if(n==13)
    {
        int *p = 0;
        *p = 0; // Access violation
    }

#ifdef TEST_DEPRECATED_FUNCS
    Uninstall(lpvState); // Uninstall exception handlers
#else
    int nUninstRes = crUninstall(); // Uninstall exception handlers
    assert(nUninstRes==0);
    nUninstRes;
#endif //TEST_DEPRECATED_FUNCS

    // Exit
    return 0;
}
Esempio n. 27
0
	inline HRESULT RegisterAppId(bool bService = false) throw()
	{
		if (!Uninstall())
			return E_FAIL;

		HRESULT hr = UpdateRegistryAppId(TRUE);
		if (FAILED(hr))
			return hr;

		CRegKey keyAppID;
		LONG lRes = keyAppID.Open(HKEY_CLASSES_ROOT, _T("AppID"), KEY_WRITE);
		if (lRes != ERROR_SUCCESS)
			return AtlHresultFromWin32(lRes);

		CRegKey key;

		lRes = key.Create(keyAppID, GetAppIdT());
		if (lRes != ERROR_SUCCESS)
			return AtlHresultFromWin32(lRes);

		key.DeleteValue(_T("LocalService"));

		if (!bService)
			return S_OK;

		key.SetStringValue(_T("LocalService"), m_szServiceName);

		// change LaunchACL and AccessACL,so that no "Administrator" privileges is need.
		//S-1-5-32-545 is USERS's SID
		TCHAR szUsersSID[] = _T("S-1-5-32-545");
		DWORD error = ChangeAppIDLaunchACL(GetAppIdT(),szUsersSID,true,true,COM_RIGHTS_ACTIVATE_LOCAL);
		if(error){
			DebugOutF(filelog::log_error,"ChangeAppIDLaunchACL failed with %d",error);
		}
		error = ChangeAppIDAccessACL(GetAppIdT(),szUsersSID,true,true,COM_RIGHTS_EXECUTE_LOCAL);
		
		if(error){
			DebugOutF(filelog::log_error,"ChangeAppIDAccessACL failed with %d",error);
		}

		// Create service
		if (!Install())
			return E_FAIL;
		return S_OK;
	}
// Remove any existing updates of TW4
int RemovePreviousTW4Updates(SoftwareProduct * /*Product*/)
{
	int nResult = 0;

	// First check that TW4 is installed:
	_TCHAR * pszTW4 = NewRegString(HKEY_LOCAL_MACHINE,
		_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Translator's Workplace 4"),
		_T("TW4Folder"));

	if (pszTW4)
	{
		delete[] pszTW4;
		pszTW4 = NULL;
	}
	else
	{
		MessageBox(NULL,
			_T("Translator's Workplace 4 cannot be located on this system, therefore the Update will not be installed."),
			g_pszTitle, MB_OK | MB_ICONSTOP);
		return -2;
	}

	// List of all previous FW product codes:
	const TCHAR * pszProductCode[] = 
	{
		_T("{3C9E2078-EBBD-43EF-837F-2AC26AF618BC}"), // TW4 Update 1
		_T("{D938E793-A00B-4849-BCA8-9C25B4A6C081}"), // TW4 Update 2
	};
	for (int i = 0; i < (sizeof(pszProductCode) / sizeof(pszProductCode[0])); i++)
	{
		g_Log.Write(_T("Uninstalling earlier TW update (Product code %s)."), pszProductCode[i]);
		DWORD dwResult = Uninstall(pszProductCode[i], _T("Preparing for the new TW update."));
		if (dwResult == 0)
			g_Log.Write(_T("Uninstall succeeded."));
		else
		{
			g_Log.Write(_T("Uninstall failed with error code %d."), dwResult);
			nResult = (int)dwResult;
			return nResult;
		}
	}

	return nResult;
}
Esempio n. 29
0
inline HRESULT CServiceModule::RegisterServer(BOOL bRegTypeLib)
{
    HRESULT hr = CoInitialize(NULL);
    if (FAILED(hr))
        return hr;

    // Remove any previous service since it may point to
    // the incorrect file
    Uninstall();
    // Add service entries
    UpdateRegistryFromResource(IDR_DrawServ, TRUE);
    // Create service
    Install();
    // Add object entries
    HRESULT hRes = CComModule::RegisterServer(bRegTypeLib);

    CoUninitialize();
    return hRes;
}
Esempio n. 30
0
inline HRESULT CServiceModule::RegisterServer(BOOL bRegTypeLib, BOOL bService)
{
    HRESULT hr;

    // Remove any previous service since it may point to
    // the incorrect file
	//CRouter::Uninstall();
    Uninstall();

    // Add service entries
    UpdateRegistryFromResource(IDR_Transport, TRUE);

    // Adjust the AppID for Local Server or Service
	CEgRegKey keyAppID;
    LONG lRes = keyAppID.Open(HKEY_CLASSES_ROOT, _T("AppID"), KEY_WRITE);
    if (lRes != ERROR_SUCCESS)
        return lRes;

	CEgRegKey key;
    lRes = key.Open(keyAppID, _T("{3E3E8035-5318-47A7-8E6E-4DB1C16E21C2}"), KEY_WRITE);
    if (lRes != ERROR_SUCCESS)
        return lRes;
    key.DeleteValue(_T("LocalService"));
    
    if (bService)
    {
        key.SetValue(TRANSPORT_SERVICE, _T("LocalService"));
        key.SetValue(_T("-Service"), _T("ServiceParameters"));
        // Create service
        Install();

//		CRouter::Install();
    }

    // Add object entries
    hr = CComModule::RegisterServer(bRegTypeLib);

	::CoUninitialize();

    return hr;
}