Exemple #1
0
DWORD ServiceParametersBase::ServiceParamInstall(void)
{
	RegistryKey				regKey;		// Registry key wrapper object
	PSERVICE_PARAMETER_MAP	pParamMap;	// Pointer to a SERVICE_PARAMETER_ENTRY
	DWORD					dwResult;	// Result from function call

	// Attempt to create the service parameters registry key object, and
	// open it with both KEY_READ and KEY_WRITE access

	dwResult = regKey.Create(HKEY_LOCAL_MACHINE, GetParametersKeyName(), 
		KEY_READ | KEY_WRITE);

	if(dwResult != ERROR_SUCCESS) return dwResult;

	pParamMap = GetParameterMap();		// Retrieve the PARAMETER_MAP
	_ASSERTE(pParamMap != NULL);		// Should never be NULL

	// Loop through the PARAMETER_MAP and add any parameters that are not already
	// set up in the registry key.  We don't worry about failure too much in here,
	// since the Parameter class will always provide a default value if need be
	
	while(pParamMap->pEntry) {

		if(pParamMap->pEntry->Load(regKey) != ERROR_SUCCESS) 
			pParamMap->pEntry->Save(regKey);

		pParamMap++;					// Move to the next parameter
	}

	return ERROR_SUCCESS;
}
Exemple #2
0
void GetCurrentParamsPath(TSTRING &tsPath) {

  RegistryKey Key;

  if (!Key.Create(FURR_ROOTREGISTRYKEY, FURR_REGISTRYCONFIGSPATH)) {

    MessageBox(GetForegroundWindow(), _T("Failed to open registry key that contains current image parameters file path;")
                                      _T(" reverting to defaults."), _T("FURR - Error"), MB_OK | MB_ICONSTOP);

    GetAppPath(tsPath);
    tsPath += FURR_DEFIMAGEPARAMSFILE;

  }

  if (!Key.ReadString(FURR_CURIMAGEPARAMSVALUE, tsPath)) {

    MessageBox(GetForegroundWindow(), _T("Failed to read registry key that contains current image parameters file path;")
                                      _T(" reverting to defaults."), _T("FURR - Error"), MB_OK | MB_ICONSTOP);

    GetAppPath(tsPath);
    tsPath += FURR_DEFIMAGEPARAMSFILE;

  }

  if (_T("") == tsPath) {

    MessageBox(GetForegroundWindow(), _T("No current image parameters file is saved in the registry; reverting to defaults."),
                                      _T("FURR - Information"), MB_OK | MB_ICONINFORMATION);

    GetAppPath(tsPath);
    tsPath += FURR_DEFIMAGEPARAMSFILE;

  }

}
Exemple #3
0
History::History (const char *name) : mName (name)
{
    if (name == 0)
	throw AppException (WHERE, ERR_INTERNAL);

    for (int i = 0; i < HIST_SIZE; i++)
	mpText[i] = 0;

    char subKey[256];
    strcpy (subKey, HKCU_SUBKEY_HERMIT "\\");
    strcat (subKey, mName);
    try {
	RegistryKey k (HKEY_CURRENT_USER, subKey, KEY_READ | KEY_WRITE);
	DWORD type;
	char str[3];
	for (int j = 0; j < HIST_SIZE; j++) {
	    wsprintf (str, "%d", j);
	    char *value = k.queryValue (str, type);
	    if (type == REG_SZ  &&  value != 0  &&  value[0] != '\0') {
		mpText[j] = _strdup (value);
		delete [] value;
		if (mpText[j] == 0)
		    throw AppException (WHERE, ERR_OUT_OF_MEMORY);
	    }
	    else {
		delete [] value;
		break;
	    }
	}
    }
    catch (const std::exception&) {
	// oh well, it's only the history
    }
}
BOOL SQLWriteDSNToIni(
     LPCSTR   lpszDSN,
     LPCSTR   lpszDriver) {
  LoggerPtr logger = Logger::getLogger("install");
  LOG_DEBUG(logger, "received a call to SQLWriteDSNtoIni");

  BOOL rtnValue = FALSE;

  try {
    RegistryKey odbcIni(HKEY_CURRENT_USER, "Software\\ODBC\\ODBC.INI");

    string dsn(lpszDSN);
    RegistryKey driver = odbcIni.merge(dsn);

    // Driver / REG_SZ / location of driver
    const string driverLoc = install_path() + "o2jb.dll";
    size_t len = driverLoc.length();
    driver.set_value("Driver", REG_SZ, (BYTE*)driverLoc.c_str(), len);

    // SafeTransactions / REG_DWORD / 0
    int zero = 0;
    driver.set_value("SafeTransactions", REG_DWORD, (BYTE*)&zero, sizeof(zero));

    // Add the data source
    RegistryKey dataSrcs = odbcIni.merge("ODBC Data Sources");
    len = strlen(lpszDriver);
    dataSrcs.set_value(dsn, REG_SZ, (BYTE*)lpszDriver, len);

    rtnValue = TRUE;
  } catch (registry_exception& e) {
    LOG_FATAL(logger, string("Failed to create the keys:  ") + e.what());
  }
  return rtnValue;
}
Exemple #5
0
RegistryKey *MainWindow::registerOptions()
{
	RegistryKey *r;
	RegistryKey *software = new RegistryKey(_T("HKEY_CURRENT_USER\\Software"));
	r = software->createSubKey(_T("Light Focus"));
	delete software;
	RegistryKey::Value *v;
	v = r->createValue(_T("SavePath"), REG_SZ);
	v->setString(_T("C:\\"));
	delete v;
	v = r->createValue(_T("HookPrintScreen"), REG_DWORD);
	v->setDword(1);
	delete v;
	v = r->createValue(_T("IncludeBackground"), REG_DWORD);
	v->setDword(0);
	delete v;
	v = r->createValue(_T("Delay"), REG_DWORD);
	v->setDword(0);
	delete v;
	v = r->createValue(_T("SaveType"), REG_DWORD);
	v->setDword(1);
	delete v;
	v = r->createValue(_T("CaptureMode"), REG_DWORD);
	v->setDword(1);
	delete v;
	r->refresh();
	return r;
}
	int RegistryKey::GetDWORD(HKEY key, tchar const *keyname, tchar const *valuename, uint32 &value)
	{
		RegistryKey bob;
		SXR(bob.Open(key, keyname));
		tstring path;
		SXR(bob.GetDWORDValue(valuename, value));
		return ERROR_SUCCESS;
	}
void InitializeParameters::save() {
  RegistryKey key = getKey();

  key.setValue(_T("elementcount")    ,(UINT)m_elementCount          );
  key.setValue(_T("elementsize")     ,m_elementSize                 );
  key.setValue(_T("initmethod")      ,initMethodToName(m_initMethod));
  key.setValue(_T("randomize")       ,m_randomizationMethod         );
  key.setValue(_T("seed")            ,m_seed                        );
  key.setValue(_T("periodcount")     ,m_periodCount                 );
  key.setValue(_T("filename")        ,m_fileName                    );
}
Exemple #8
0
void GetCurrentPreviewImage(TSTRING &tsImgPath) {


  RegistryKey Key;

  if (!Key.Create(FURR_ROOTREGISTRYKEY, FURR_REGISTRYCONFIGSPATH)) {

    MessageBox(GetForegroundWindow(), _T("Failed to open registry key that contains current preview image path!"),
                                      _T("FURR - Error"), MB_OK | MB_ICONSTOP);

  }

  Key.ReadString(FURR_CURPREVIEWIMAGEVALUE, tsImgPath);

}
	System::Void add_remove_contacts::remove()
	{
		label1->Visible = false;
		label2->Visible = false;
		label3->Visible = true;
		comboBox1->Visible = true;
		textBox1->Visible = false;
		textBox2->Visible = false;
		this->Text = "Apagar Contacto";
		add_or_remove = 1;
		RegistryKey * pRegKey = Registry::CurrentUser->OpenSubKey(L"Software\\Zip\\dotSMS\\Contacts" , true);
		if( pRegKey != NULL )
		{
			String* valueNames __gc [] = pRegKey->GetValueNames();
			comboBox1->Items->AddRange(valueNames);
		}
Exemple #10
0
bool SetCurrentParamsPath(CTSTRING &tsPath) {

  bool r = false;
  RegistryKey Key;

  if (Key.Create(FURR_ROOTREGISTRYKEY, FURR_REGISTRYCONFIGSPATH)) {

    if (Key.WriteString(FURR_CURIMAGEPARAMSVALUE, tsPath)) {
    
      r = true;

    }

  }

  return r;
}
Exemple #11
0
void MainWindow::saveOptions()
{
	RegistryKey *r;
	RegistryKey::Value *v;
	r = new RegistryKey(_T("HKEY_CURRENT_USER\\Software\\Light Focus"));
	v = r->loadValue(_T("SavePath"));
	v->setString(_savePath);
	delete v;
	v = r->loadValue(_T("HookPrintScreen"));
	if (_isHookPrintScreen) {
		v->setDword(1);
	} else {
		v->setDword(0);
	}
	delete v;
	v = r->loadValue(_T("IncludeBackground"));
	if (_isIncludeBackground) {
		v->setDword(1);
	} else {
		v->setDword(0);
	}
	delete v;
	v = r->loadValue(_T("Delay"));
	v->setDword(_delay);
	delete v;
	v = r->loadValue(_T("SaveType"));
	v->setDword(_saveType);
	delete v;
	v = r->loadValue(_T("CaptureMode"));
	v->setDword(_captureMode);
	delete v;
	delete r;
}
Exemple #12
0
gcc_pure
static bool
CompareRegistryValue(const RegistryKey &registry,
                     const TCHAR *name, const TCHAR *value)
{
  TCHAR real_value[64];
  return registry.GetValue(name, real_value, 64) &&
    StringIsEqualIgnoreCase(value, real_value);
}
Exemple #13
0
gcc_pure
static bool
CompareRegistryValue(const RegistryKey &registry,
                     const TCHAR *name, const TCHAR *value)
{
  TCHAR real_value[64];
  return registry.get_value(name, real_value, 64) &&
    _tcsicmp(value, real_value) == 0;
}
Exemple #14
0
void CommandIgnore::InstallCommand(RegistryKey& configKey)
{
	vector<wstring> commands;
	wstring temp, entry;
	HidStatus status;

	temp.insert(0, m_targetImage.size() + HID_NORMALIZATION_OVERHEAD, L'\0');

	status = Hid_NormalizeFilePath(m_targetImage.c_str(), const_cast<wchar_t*>(temp.c_str()), temp.size());
	if (!HID_STATUS_SUCCESSFUL(status))
		throw WException(HID_STATUS_CODE(status), L"Error, can't normalize path, 'ignore' rejected");

	entry += temp.c_str();
	entry += L";";
	entry += ConvertInheritTypeToUnicode(m_inheritType);

	configKey.GetMultiStrValue(L"Hid_IgnoredImages", commands);
	commands.push_back(entry);
	configKey.SetMultiStrValue(L"Hid_IgnoredImages", commands);

	g_stderr << L"Install 'ignore' successful" << endl;
}
Exemple #15
0
void RemoveSelectLetterCommandKeys()
{
	std::set<String, String::_CaseInsensitiveLess> classes;
	for each(const wchar_t *pExt in g_Extensions)
	{
		classes.insert(String::sFormat(L"BazisVirtualCD.%s", pExt));
		classes.insert(RegistryKey(HKEY_CLASSES_ROOT, String::sFormat(L".%s", pExt).c_str())[NULL]);
	}

	for each(const String &str in classes)
	{
		if (str.empty())
			continue;
		RegistryKey key(HKEY_CLASSES_ROOT, str.c_str());
		if (!key.Valid())
			continue;
		RegistryKey keyShell = key[L"shell"];
		if (keyShell.Valid())
			keyShell.DeleteSubKeyRecursive(L"Select drive letter && mount");
	}

}
BOOL SQLRemoveDSNFromIni(
     LPCSTR   lpszDSN) {
  LoggerPtr logger = Logger::getLogger("install");
  LOG_DEBUG(logger, "received a call to SQLRemoveDSNFromIni");

  BOOL rtnValue = FALSE;

  try {
    RegistryKey odbcIni(HKEY_CURRENT_USER, "Software\\ODBC\\ODBC.INI");

    // remove the data source tag
    RegistryKey dataSrcs = odbcIni.merge("ODBC Data Sources");
    dataSrcs.unset_value(lpszDSN);

    // remove the DSN tree
    odbcIni.remove(lpszDSN);

    rtnValue = TRUE;
  } catch (registry_exception& e) {
    LOG_FATAL(logger, string("Failed to create the keys:  ") + e.what());
  }
  return rtnValue;
}  
Exemple #17
0
History::~History ()
{
    char subKey[256];
    strcpy (subKey, HKCU_SUBKEY_HERMIT "\\");
    strcat (subKey, mName);
    try {
	RegistryKey k (HKEY_CURRENT_USER, subKey, KEY_READ | KEY_WRITE);
	char str[3];
	for (int j = 0; j < HIST_SIZE; j++) {
	    wsprintf (str, "%d", j);
	    const char *value = mpText[j];
	    if (value == 0)
		value = "";
	    k.setValue (str, value);
	}
    }
    catch (const std::exception&) {
	// oh well, it's only the history
    }

    for (int i = 0; i < HIST_SIZE; i++)
	if (mpText[i] != 0)
	    free (mpText[i]);
}
void Options::load() {
  try {
    RegistryKey settings = getKey();
    const DefaultOptions defaultOptions;
    m_dirList           = settings.getString(_T("dirlist")         , defaultOptions.m_dirList           );
    m_startSelectDir    = settings.getString(_T("startselectdir")  , defaultOptions.m_startSelectDir    );
    m_confirmChoise     = settings.getBool(  _T("confirmchoise")   , defaultOptions.m_confirmChoise     );
    m_autoSelect        = settings.getBool(  _T("autoselect")      , defaultOptions.m_autoSelect        );
    m_allowDuplicates   = settings.getBool(  _T("allowduplicates") , defaultOptions.m_allowDuplicates   );
    m_md5password       = settings.getString(_T("password")        , defaultOptions.m_md5password       );
    m_maxChoise         = settings.getInt(   _T("maxchoise")       , defaultOptions.m_maxChoise         );
    m_volume            = settings.getInt(   _T("volume")          , defaultOptions.m_volume            );
    m_backgroundColor   = settings.getUint(  _T("backgroundcolor") , defaultOptions.m_backgroundColor   );
    m_currentTrackColor = settings.getUint(  _T("currentcolor")    , defaultOptions.m_currentTrackColor );
    m_mediaQueueColor   = settings.getUint(  _T("playqueuecolor")  , defaultOptions.m_mediaQueueColor   );
  } catch(Exception e) {
    showException(e);
  }
}
void Options::save() {
  try {
    RegistryKey settings = getKey();

    settings.setValue(_T("dirlist")         ,m_dirList           );
    settings.setValue(_T("startselectdir")  ,m_startSelectDir    );
    settings.setValue(_T("confirmchoise")   ,m_confirmChoise     );
    settings.setValue(_T("autoselect")      ,m_autoSelect        );
    settings.setValue(_T("allowduplicates") ,m_allowDuplicates   );
  //  settings.setValue(_T("password")        ,m_md5password       ); // NB
    settings.setValue(_T("maxchoise")       ,m_maxChoise         );
    settings.setValue(_T("volume")          ,m_volume            );
    settings.setValue(_T("backgroundcolor") ,m_backgroundColor   );
    settings.setValue(_T("currentcolor")    ,m_currentTrackColor );
    settings.setValue(_T("playqueuecolor")  ,m_mediaQueueColor   );
  } catch(Exception e) {
    showException(e);
  }
}
void InitializeParameters::load() {
  try {
    InitializeParameters defaultValues;
    RegistryKey key = getKey();
    m_elementCount        =  key.getInt(   _T("elementcount")    , (UINT)defaultValues.m_elementCount);
    m_elementSize         =  key.getInt(   _T("elementsize")     , defaultValues.m_elementSize );
    String initMethodName =  key.getString(_T("initmethod")      , _T("random")                    );
    m_initMethod = nameToInitMethod(initMethodName);

    m_randomizationMethod = (RandomizationMethod)key.getInt(    _T("randomize")       , defaultValues.m_randomizationMethod);
    m_seed                = key.getUint(   _T("seed")            , defaultValues.m_seed        );
    m_periodCount         = key.getUint(   _T("periodcount")     , defaultValues.m_periodCount );
    m_fileName            = key.getString( _T("filename")        , defaultValues.m_fileName    );
    if(m_initMethod == IDC_RADIO_FILEDATA) {
      readTextFile(m_fileName);
    }
  } catch(Exception e) {
    setDefault();
  }
}
// Add Python installations at the given root to the supplied map.
//
void Installer::iterPython(HKEY root, map<wstring, wstring> &pyInstalls) {
	RegistryKey key;
	if ( key.open(root, PY_ROOT ) ) {
		RegistryKey installPath;
		vector<wstring> children;
		key.enumChildren(RegistryKey::EnumKeys, children);
		for ( vector<wstring>::const_iterator i = children.begin(); i != children.end(); i++ ) {
			const wstring &version = *i;
			wstring installPathName = PY_ROOT;
			installPathName += L'\\';
			installPathName += version;
			installPathName += L"\\InstallPath";
			if ( installPath.open(root, installPathName ) ) {
				pyInstalls.insert(make_pair(version, installPath.getValueAsString(L"")));
			}
		}
	}
}
Exemple #22
0
void MainWindow::loadOptions()
{
	RegistryKey *r;
	RegistryKey::Value *v;
	try {
		r = new RegistryKey(_T("HKEY_CURRENT_USER\\Software\\Light Focus"));
	} catch (Exception &e) {
		r = registerOptions();
	}
	v = r->loadValue(_T("SavePath"));
	_savePath = v->getString();
	delete v;
	v = r->loadValue(_T("HookPrintScreen"));
	if (v->getDword() == 1) {
		setHook(_handle);
		_isHookPrintScreen = true;
	} else {
		_isHookPrintScreen = false;
	}
	delete v;
	v = r->loadValue(_T("IncludeBackground"));
	if (v->getDword() == 1) {
		_isIncludeBackground = true;
	} else {
		_isIncludeBackground = false;
	}
	delete v;
	v = r->loadValue(_T("Delay"));
	_delay = v->getDword();
	delete v;
	v = r->loadValue(_T("SaveType"));
	_saveType = v->getDword();
	delete v;
	v = r->loadValue(_T("CaptureMode"));
	_captureMode = v->getDword();
	delete v;
	delete r;
}
    Service::Service( std::wstring const& serviceName, std::wstring const& displayName, SERVICE_STATUS const& status, SC_HANDLE scmHandle ) 
        : serviceName(serviceName)
        , displayName(displayName)
        , svchostDamaged(false)
    {
        // Set the state
        switch (status.dwCurrentState)
        {
        case SERVICE_STOPPED:
            this->state = L"S";
            break;
        case SERVICE_START_PENDING:
            this->state = L"R?";
            break;
        case SERVICE_STOP_PENDING:
            this->state = L"S?";
            break;
        case SERVICE_RUNNING:
            this->state = L"R";
            break;
        case SERVICE_CONTINUE_PENDING:
            this->state = L"C?";
            break;
        case SERVICE_PAUSE_PENDING:
            this->state = L"P?";
            break;
        case SERVICE_PAUSED:
            this->state = L"P";
            break;
        default:
            this->state = L"?";
            break;
        }

        serviceHandle = OpenServiceW(scmHandle, this->serviceName.c_str(), SERVICE_QUERY_CONFIG);
        if (serviceHandle == NULL)
        {
            Win32Exception::ThrowFromLastError();
        }
        std::aligned_storage<8192 /* (8K bytes maximum size) */, std::alignment_of<QUERY_SERVICE_CONFIGW>::value>::type
            queryServiceConfigBuffer;
        DWORD bytesNeeded = 0; // not needed
        if (QueryServiceConfig(serviceHandle, reinterpret_cast<LPQUERY_SERVICE_CONFIGW>(&queryServiceConfigBuffer), 8192, &bytesNeeded) == false)
        {
            Win32Exception::ThrowFromLastError();
        }
        QUERY_SERVICE_CONFIGW *queryServiceConfig = reinterpret_cast<QUERY_SERVICE_CONFIGW*>(&queryServiceConfigBuffer);

        // Set the start type
        this->start = queryServiceConfig->dwStartType;

        // Set the file
        this->filepath = queryServiceConfig->lpBinaryPathName;
        if (filepath.empty())
        {
            if (queryServiceConfig->dwServiceType == SERVICE_KERNEL_DRIVER || queryServiceConfig->dwServiceType == SERVICE_FILE_SYSTEM_DRIVER)
            {
                filepath = Path::Append(Path::GetWindowsPath(), L"System32\\Drivers\\" + serviceName + L".sys");
            }
            else
            {
                filepath = Path::Append(Path::GetWindowsPath(), L"System32\\" + serviceName + L".exe");
            }
        }
        Path::ResolveFromCommandLine(this->filepath);

        static std::wstring svchostPath(Path::Append(Path::GetWindowsPath(), L"System32\\Svchost.exe"));
        // Set the svchost group, dll path, and damaged status if applicable
        if (boost::iequals(filepath, svchostPath))
        {
            // Get the svchost group
            this->svchostGroup = queryServiceConfig->lpBinaryPathName;
            this->svchostGroup.erase(this->svchostGroup.begin(), boost::ifind_first(this->svchostGroup, L"-k").end());            
            boost::trim(this->svchostGroup);
            
            std::wstring serviceKeyName = L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\" + this->serviceName;
            // Get the dll path
            RegistryKey serviceParameters = RegistryKey::Open(
                 serviceKeyName + L"\\Parameters", KEY_QUERY_VALUE);
            if (serviceParameters.Invalid())
            {
                serviceParameters = RegistryKey::Open(serviceKeyName, KEY_QUERY_VALUE);
            }
            if (serviceParameters.Invalid())
            {
                Win32Exception::ThrowFromNtError(::GetLastError());
            }
            RegistryValue serviceDllValue = serviceParameters.GetValue(L"ServiceDll");
            this->svchostDll = serviceDllValue.GetStringStrict();
            Path::ResolveFromCommandLine(this->svchostDll);

            // Check to see if it's damaged
            RegistryKey svchostGroupKey = RegistryKey::Open(L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Svchost", KEY_QUERY_VALUE);
            RegistryValue svchostGroupRegistration = svchostGroupKey.GetValue(this->svchostGroup);
            std::vector<std::wstring> svchostGroupRegistrationStrings = svchostGroupRegistration.GetMultiStringArray();
            auto groupRef = std::find_if(svchostGroupRegistrationStrings.begin(), svchostGroupRegistrationStrings.end(),
                [&] (std::wstring const& a) -> bool { return boost::iequals(a, serviceName, std::locale()); } );
            svchostDamaged = groupRef == svchostGroupRegistrationStrings.end();
        }
    }
// Populate the lists of installed software for display in the drop-downs.
//
Installer::Installer(void) :
	m_vsSelect(-1), m_pySelect(-1), m_iseSelect(-1), m_x64(det64()),
	m_hdlUseable(false), m_linkName(L"makestuff-base")
{
	RegistryKey key;

	// See if Windows SDK v7.1 is installed
	if ( key.open(HKEY_LOCAL_MACHINE, SDK_ROOT) ) {
		wstring target = L"\"";
		target += key.getValueAsString(L"InstallationFolder");
		m_vsInstalls.push_back(
			VSInstall(
				L"sdk7.1.x86",
				L"Windows SDK v7.1 C/C++ Compiler (x86)",
				target + L"Bin\\SetEnv.cmd\" /x86&&set MACHINE=x86&&"
			)
		);
		if ( m_x64 ) {
			m_vsInstalls.push_back(
				VSInstall(
					L"sdk7.1.x64",
					L"Windows SDK v7.1 C/C++ Compiler (x64)",
					target + L"Bin\\SetEnv.cmd\" /x64&&set MACHINE=x64&&"
				)
			);
		}
	}

	// See which versions (if any) of Visual Studio are installed
	if ( key.open(HKEY_LOCAL_MACHINE, VS_ROOT) ) {
		const wstring baseName = L"Visual Studio ";
		vector<wstring> children;
		key.enumChildren(RegistryKey::EnumValues, children);
		for ( vector<wstring>::const_iterator i = children.begin(); i != children.end(); i++ ) {
			const wstring &version = *i;
			const int majorVersion = getMajorVersion(i->c_str());
			const wstring thisName = baseName + version;
			wstring thisTarget = L"\"";
			thisTarget += key.getValueAsString(version);
			m_vsInstalls.push_back(
				VSInstall(
					L"vs" + version + L".x86",
					thisName + L" C/C++ Compiler (x86)",
					thisTarget + L"VC\\vcvarsall.bat\" x86&&set MACHINE=x86&&"
				)
			);
			if ( m_x64 && majorVersion > 10 ) {
				// 64-bit compilers are only available after VS2010, and realistically only on Windows x64.
				m_vsInstalls.push_back(
					VSInstall(
						L"vs" + version + L".x64",
						thisName + L" C/C++ Compiler (x64)",
						thisTarget + L"VC\\vcvarsall.bat\" x86_amd64&&set MACHINE=x64&&"
					)
				);
			}
		}
	}

	// See which versions (if any) of Python are installed
	map<wstring, wstring> pyInstalls;
	iterPython(HKEY_CURRENT_USER, pyInstalls);
	iterPython(HKEY_LOCAL_MACHINE, pyInstalls);
	for ( map<wstring, wstring>::const_iterator i = pyInstalls.begin(); i != pyInstalls.end(); i++ ) {
		m_pyInstalls.push_back(
			make_pair(
				i->first,
				i->second
			)
		);
	}

	// See which versions (if any) of Xilinx ISE are installed
	if ( key.open(HKEY_CURRENT_USER, ISE_ROOT) ) {
		const wstring baseName = L"Xilinx ISE ";
		vector<wstring> children;
		key.enumChildren(RegistryKey::EnumKeys, children);
		for ( vector<wstring>::const_iterator i = children.begin(); i != children.end(); i++ ) {
			const wstring &version = *i;
			const wstring thisName = baseName + version;
			const wstring thisTarget = grandParent(
				key.getValueAsString(
					version +
					L"\\Project Navigator\\Project Manager\\Preferences\\PlanAheadBinDirUserVal"
				)
			) + (m_x64 ? L"\\ISE\\bin\\nt64" : L"\\ISE\\bin\\nt");
			m_iseInstalls.push_back(
				make_pair(version, thisTarget)
			);
		}
	}
}
Exemple #25
0
void ConfigScroller::exportReg ()
{
    int exitCode = KB_ESC;
    char path[512];
    *path = 0;
    {
	InputDialog dlg (myScreen, "Export Custom Commands", "Enter the pathname:",
			 path, 511, &mRegHist);
	dlg.run ();
	exitCode = dlg.getExitCode ();
    }
    if (exitCode != KB_ESC) {

	if (_access (path, 0) == 0)
	    if (myScreen.ask ("Confirm File Replace", "Overwrite the existing file?") == 0)
		return;

	FILE *file = fopen (path, "w");
	if (file == NULL) {
	    myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) "Could not create file."));
	    return;
	}

	for (int i = 0; i < 2; i++) {
	    int st, fn;
	    if (i == 0) {
		st = 'A';
		fn = 'Z';
	    }
	    else if (i == 1) {
		st = '0';
		fn = '9';
	    }

	    for (char c = st; c <= fn; c++) {
		try {
		    // Open registry key
		    RegistryKey k (HKEY_CURRENT_USER, HKCU_SUBKEY_HERMIT "\\Commands", KEY_READ);

		    char valname[2];
		    valname[0] = c;
		    valname[1] = '\0';
		    // try to read the current value
		    char *value = 0;
		    DWORD type;
		    try {
			value = k.queryValue (valname, type);
			if (type == REG_SZ  &&  value != 0  &&  value[0] != '\0') {
			    fprintf (file, "%c,%s\n", c, value);
			}
			delete [] value;
		    }
		    catch (const std::exception&) {
		    }
		}
		catch (const std::exception&) {
		}
	    }
	}
	fclose (file);
	myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) "Commands exported."));
    }
}
Exemple #26
0
const char *ConfigScroller::importCommands (const char *path)
{
    FILE *file = fopen (path, "r");
    if (file == NULL)
	return "Could not open file";

    ArrayPtr<char> str = new char [COMMAND_SIZE + 3];
    if (str == 0)
	throw AppException (WHERE, ERR_OUT_OF_MEMORY);
    char *status = 0;
    while (fgets (str, COMMAND_SIZE + 3, file) != NULL) {
	// Remove trailing whitespace
	int n = (int) strlen (str);
	while (n > 0  &&  (str[n - 1] == '\n'  ||  str[n - 1] == '\t'  ||  str[n - 1] == ' ')) {
	    str[n - 1] = '\0';
	    n--;
	}
	// If string is empty, just ignore it
	if (str[0] == '\0')
	    continue;
	// Uppercase the first letter
	str[0] = toupper (str[0]);
	// Make sure the command format is [A-Z,0-9],
	if ((!(str[0] >= 'A'  &&  str[0] <= 'Z')  &&
	     !(str[0] >= '0'  &&  str[0] <= '9')) ||  str[1] != ',') {
	    status = "A read error occurred.";
	    break;
	}
	// Create the value name string
	char valname[2];
	valname[0] = str[0];
	valname[1] = '\0';
	// Save to registry
	try {
	    // Open registry key
	    RegistryKey k (HKEY_CURRENT_USER, HKCU_SUBKEY_HERMIT "\\Commands", KEY_READ | KEY_WRITE);
	    k.setValue (valname, &str[2]);
	}
	catch (const std::exception&) {
	    status = "Error saving key to registry";
	    break;
	}
    }

    if (ferror (file) != 0)
	status = "A read error occurred.";

    if (status == 0) {
	// Set initialized state (actually no reason...we use Commands key)
#if 0
	try {
	    RegistryKey k (HKEY_CURRENT_USER, HKCU_SUBKEY_HERMIT "\\Initialized", KEY_READ | KEY_WRITE);
	}
	catch (const std::exception&) {
	}
#endif
	// Set message
	status = "Commands imported.";
    }

    fclose (file);

    return status;
}
void
CConfigDisplay::StoreReg(RegistryKey & reg) {
    AutoLog alog("CCD::StoreREg");

    reg.Write(RegWindowsColorBkPanel, MBUtil::CrToRGB(m_vBkPanel));
    reg.Write(RegWindowsColorBkNormal, MBUtil::CrToRGB(m_vBkNormal));
    reg.Write(RegWindowsColorBkHigh, MBUtil::CrToRGB(m_vBkHigh));
    reg.Write(RegWindowsColorBkSel, MBUtil::CrToRGB(m_vBkSel));
    reg.Write(RegWindowsColorTxPanel, MBUtil::CrToRGB(m_vTxPanel));
    reg.Write(RegWindowsColorTxNormal, MBUtil::CrToRGB(m_vTxNormal));
    reg.Write(RegWindowsColorTxHigh, MBUtil::CrToRGB(m_vTxHigh));
    reg.Write(RegWindowsColorTxSel, MBUtil::CrToRGB(m_vTxSel));
    reg.Write(RegWindowsColorBkColHdr, MBUtil::CrToRGB(m_vBkColHdr));
    reg.Write(RegWindowsColorTxColHdr, MBUtil::CrToRGB(m_vTxColHdr));

    MBCONFIG_WRITE_COLOR_3D(reg,MB3DCOLHDRCOLOR,
                            m_vcrColHdrInUL,m_vcrColHdrInLR,m_vcrColHdrOutUL,m_vcrColHdrOutLR);

    MBCONFIG_WRITE_COLOR_3D(reg,MB3DDATACOLOR,
                            m_vcrDataInUL,m_vcrDataInLR,m_vcrDataOutUL,m_vcrDataOutLR);

    MBCONFIG_WRITE_COLOR_3D(reg,MB3DSTATUSCOLOR,
                            m_vcrStatusInUL,m_vcrStatusInLR,m_vcrStatusOutUL,m_vcrStatusOutLR);

    if (IsWindow(m_3dDataCheck.m_hWnd)) {
        m_3dColHdr = m_3dColHdrsCheck.GetCheck();
        m_3dData = m_3dDataCheck.GetCheck();
        m_3dStatus = m_3dStatusCheck.GetCheck();
    }

    reg.Write(MB3DDATA,m_3dData );
    reg.Write(MB3DCOLHDRS,m_3dColHdr );
    reg.Write(MB3DSTATUS,m_3dStatus );

    int sel = m_SkinList.GetCurSel();
    if (sel > -1) {
        m_SkinList.GetLBText(sel, m_sSkinName);
    } else {
        m_SkinList.GetWindowText(m_sSkinName);
    }

    sel = m_BorderWidth.GetCurSel();
    if (sel > -1) {
        CString tmp;
        m_BorderWidth.GetLBText(sel, tmp);
        m_vBorderWidth = atoi(tmp);
    } else {
        CString tmp;
        m_BorderWidth.GetWindowText(tmp);
        m_vBorderWidth = atoi(tmp);
    }
    reg.Write(RegWindowsBorderWidth, m_vBorderWidth);
    reg.Write(RegWindowsBorderHorz, m_vBorderHorz);
    reg.Write(RegWindowsBorderVert, m_vBorderVert);

    CString fontstr = MBUtil::LogFont2FontStr(&m_lfTitles);
    reg.Write(RegWindowsFontTitles, fontstr);

    fontstr = MBUtil::LogFont2FontStr(&m_lfPanel);
    reg.Write(RegWindowsFontPanel, fontstr);

    fontstr = MBUtil::LogFont2FontStr(&m_lfColHdr);
    reg.Write(RegWindowsFontColHdr, fontstr);

}
void
CConfigDisplay::ReadReg(RegistryKey & reg) {
    AutoLog alog("CCD::ReadReg");

    m_vBkPanel = reg.Read(RegWindowsColorBkPanel, m_vBkPanel);
    m_vBkNormal = reg.Read(RegWindowsColorBkNormal, m_vBkNormal);
    m_vBkHigh = reg.Read(RegWindowsColorBkHigh, m_vBkHigh);
    m_vBkSel = reg.Read(RegWindowsColorBkSel, m_vBkSel);
    m_vTxPanel = reg.Read(RegWindowsColorTxPanel, m_vTxPanel);
    m_vTxNormal = reg.Read(RegWindowsColorTxNormal, m_vTxNormal);
    m_vTxHigh = reg.Read(RegWindowsColorTxHigh, m_vTxHigh);
    m_vTxSel = reg.Read(RegWindowsColorTxSel, m_vTxSel);
    m_vBkColHdr = reg.Read(RegWindowsColorBkColHdr, m_vBkColHdr);
    m_vTxColHdr = reg.Read(RegWindowsColorTxColHdr, m_vTxColHdr);

    MBCONFIG_READ_COLOR_3D(reg,MB3DCOLHDRCOLOR,
                           m_vcrColHdrInUL,m_vcrColHdrInLR,m_vcrColHdrOutUL,m_vcrColHdrOutLR);

    MBCONFIG_READ_COLOR_3D(reg,MB3DDATACOLOR,
                           m_vcrDataInUL,m_vcrDataInLR,m_vcrDataOutUL,m_vcrDataOutLR);

    MBCONFIG_READ_COLOR_3D(reg,MB3DSTATUSCOLOR,
                           m_vcrStatusInUL,m_vcrStatusInLR,m_vcrStatusOutUL,m_vcrStatusOutLR);

    m_3dData = reg.Read(MB3DDATA,0);
    m_3dColHdr = reg.Read(MB3DCOLHDRS,0);
    m_3dStatus = reg.Read(MB3DSTATUS,0);

    if (IsWindow(m_3dDataCheck.m_hWnd)) {
        m_3dColHdrsCheck.SetCheck(m_3dColHdr);
        m_3dDataCheck.SetCheck(m_3dData);
        m_3dStatusCheck.SetCheck(m_3dStatus);
    }

    v2m();

    m_vBorderWidth = reg.Read(RegWindowsBorderWidth, m_vBorderWidth);
    m_vBorderHorz = reg.Read(RegWindowsBorderHorz, m_vBorderHorz);
    m_vBorderVert = reg.Read(RegWindowsBorderVert, m_vBorderVert);

    int sel;
    if (IsWindow(m_BorderWidth.m_hWnd)) {
        sel = m_BorderWidth.SelectString(-1, numToString(m_vBorderWidth));
        m_BorderWidth.SetCurSel(sel);
    }

    AutoBuf buf(1000);

    reg.Read(RegWindowsFontTitles, buf.p, 999, "");
    if (MBUtil::ConfigFontValidate(buf.p) && strlen(buf.p) > MBCCFONTFACEPOS) {
        MBUtil::FontStr2LogFont(buf.p, &m_lfTitles);
    }

    reg.Read(RegWindowsFontPanel, buf.p, 999, "");
    if (MBUtil::ConfigFontValidate(buf.p) && strlen(buf.p) > MBCCFONTFACEPOS) {
        MBUtil::FontStr2LogFont(buf.p, &m_lfPanel);
    }

    reg.Read(RegWindowsFontColHdr, buf.p, 999, "");
    if (MBUtil::ConfigFontValidate(buf.p) && strlen(buf.p) > MBCCFONTFACEPOS) {
        MBUtil::FontStr2LogFont(buf.p, &m_lfColHdr);
    }

    EnableDisable();

}
Exemple #29
0
 /**
  * Has this object failed to open the Windows Registry?
  */
 bool Error() const {
   return drivers_active.error();
 }
Exemple #30
0
int	main(int argc, char* argv[])
	{
	//open registry	and	delete all values set by FaultIntercepter (Initilize)
	RegistryKey	*LMachine =	RegistryKey::OpenRemoteBaseKey(RegistryHive::LocalMachine, System::Environment::MachineName);			 
	RegistryKey	*SKey =	LMachine->OpenSubKey("SOFTWARE", true);
	RegistryKey	*HKey =	 SKey->OpenSubKey("HolodeckEE",	true);
	try
		{
		HKey->DeleteSubKey("Outcome");
		HKey->DeleteSubKey("FaultIntercepterReady");
		HKey->DeleteSubKey("FaultReady");
		}catch(System::ArgumentException *ArgumentError){}

	String *path = System::Environment::CurrentDirectory;
	int	index =	path->IndexOf("Debug");

	if (index != -1)
		{
		path = path->Substring(0, index-1);
		}

	path = String::Concat(path,"\\Logs\\");
	Console::WriteLine("Logs in	{0}",path);

	//Begin	a streamwriter to output whether a fault has passed	or failed. 
	FileStream *DefaultFileStreamer;
	String *FaultFileLogName = String::Concat(path,	"DefaultLog.Log");
	DefaultFileStreamer	= new FileStream(FaultFileLogName, FileMode::OpenOrCreate, FileAccess::Write  );
	StreamWriter * DefaultWriter = new StreamWriter(DefaultFileStreamer);

	TestFaults *FaultTester	= new TestFaults();

	//load the functions and faults	xml	files to memory
	FaultTester->LoadFaultsXmlFile();
	FaultTester->LoadFunctionsXmlFile();

	//if no	arguments were entered then	notify user	and	exit
	if (argc ==	1)
		{
		Console::WriteLine("Please enter fault names as arguments!");
		Sleep(8000);
		return 0;
		}

	//initilize	detailed log files to record the return	values and errorcodes for each function
	//in a fault.
	String *DetailLogFile =	String::Concat(path,"LastRun-DetailLog.Log");
	FileStream *DetailLogStreamer;
	DetailLogStreamer =	new	FileStream(DetailLogFile, FileMode::OpenOrCreate , FileAccess::Write  );
	StreamWriter * DetailLogWriter = new StreamWriter(DetailLogStreamer);

	bool FaultOutcome =	false;

	for(int	arg=1;arg<argc;arg++)
		{
		//if just one fault	iss	being run then open	a log with the fault name
		if (argc == 2)
			{
			String *FaultFileLogName = String::Concat(path,argv[arg],".Log");
			FileStream *FileStreamer;
			FileStreamer = new FileStream(FaultFileLogName,	FileMode::OpenOrCreate,	FileAccess::Write );
			StreamWriter * Writer =	new	StreamWriter(FileStreamer);
			Console::WriteLine("Currently running {0} fault...", Convert::ToString(argv[arg]));
			FaultOutcome = FaultTester->TestFault(argv[arg],Writer,DetailLogWriter);
			Writer->Close();
			}

		//if more than one argument	then load the default log to store all the faults that are to be run
		if(argc > 2)
			{
			FaultOutcome = FaultTester->TestFault(argv[arg],DefaultWriter,DetailLogWriter);
			}

		RegistryKey	*PassFail =	HKey->CreateSubKey("Outcome");

		if(FaultOutcome	== true)
			{
			PassFail->SetValue("Outcome",static_cast<String	*>("PASS"));
			}
		else 
			{
			PassFail->SetValue("Outcome",static_cast<String	*>("FAIL"));
			}
		FaultOutcome = false;
		}
	//close	all	open writers
	DefaultWriter->Close();
	DetailLogWriter->Close();
	Console::ReadLine();
	return 0;
	}