Exemple #1
0
BOOL CIni::CopyKey(LPCTSTR lpSrcSection, LPCTSTR lpSrcKey, LPCTSTR lpDestSection, LPCTSTR lpDestKey, BOOL bFailIfExist) const
{
	if (lpSrcSection == NULL || lpSrcKey == NULL || lpDestKey == NULL)
		return FALSE;

	if (_tcsicmp(lpSrcSection, lpDestSection) == 0
		&& _tcsicmp(lpSrcKey, lpDestKey) == 0)
		return FALSE;

	if (!IsKeyExist(lpSrcSection, lpSrcKey))
		return FALSE;

	if (bFailIfExist && IsKeyExist(lpDestSection, lpDestKey))
		return FALSE;
	
	LPTSTR psz = __GetStringDynamic(lpSrcSection, lpSrcKey);
	const BOOL RES = WriteString(lpDestSection, lpDestKey, psz);
	delete [] psz;
	return RES;
}
Exemple #2
0
	//***************************************************************************************************
	// Deletes a subkey and all its descendants. This function removes the key and all the key's values from the registry.
	bool DeleteKey( HKEY hKey, LPCTSTR lpcsPath )
	{
		if ( IsKeyExist( hKey, lpcsPath, NULL ) )
		{
			// Deletes a subkey and all its descendants. SHDeleteKey removes the key and all the key's values from the registry.
			if ( ERROR_SUCCESS != ::SHDeleteKey( hKey, lpcsPath ) )
			{
				DWORD dwLastError = GetLastError();
				return false;
			}
		}
		return true;
	}
Exemple #3
0
bool WizardApp::SetInt( const wchar_t* lpSection, const wchar_t* lpKey, int value )
{
	bool changed = true;

	if (IsKeyExist(lpSection, lpKey))
	{
		if (GetInt(lpSection, lpKey) == value)
		{
			changed = false;
		}
	}

	if (changed)
	{
		wchar_t szValue[32];
		_itow(value, szValue, 10);

		::WritePrivateProfileString(lpSection, lpKey, szValue, m_strConfig.c_str());
		GetEvent()->FireConfigChange(lpSection, lpKey, value);
	}

	return true;
}