void CSettings::EnableAutostartup(bool enable) {
	CRegistry Reg;
	Reg.SetRootKey( HKEY_CURRENT_USER );
	bool canCreateRegistryKey = enable;

	if ( Reg.SetKey( "Software\\Zenden.ws\\Image Uploader", canCreateRegistryKey ) ) {
		if ( enable ) {
			Reg.WriteBool( "AutoStartup", enable );
		} else {
			Reg.DeleteValue("AutoStartup");
		}
	}

	if ( enable ) {
		HKEY hKey;
		CString StartupCommand = _T("\"") + CmdLine.ModuleName() + _T("\" /tray");
		LONG lRet, lRetOpen;
		lRet = RegOpenKeyEx( HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 
		                      0, KEY_WRITE, &hKey );
		if (!lRet) {
			lRetOpen = RegSetValueEx( hKey, _T("ImageUploader"), NULL, REG_SZ, (BYTE*)(LPCTSTR)StartupCommand,
			                            (StartupCommand.GetLength() + 1) * sizeof(TCHAR));
		}
		RegCloseKey( hKey );
	} else { 
		// deleting from Startup (autorun)
		HKEY hKey;
		LONG lRet;
		lRet = RegOpenKeyEx( HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_WRITE,
									&hKey );
		RegDeleteValue( hKey, _T("ImageUploader") );
	}
}
	bool CSettings::SaveSettings()
	{
		SimpleXml xml;
		mgr_.saveToXmlNode(xml.getRoot("ImageUploader").GetChild("Settings"));
#if !defined(IU_SERVERLISTTOOL) && !defined  (IU_CLI) && !defined(IU_SHELLEXT)
		SaveConvertProfiles(xml.getRoot("ImageUploader").GetChild("Settings").GetChild("Image").GetChild("Profiles"));
		SaveServerProfiles( xml.getRoot("ImageUploader").GetChild("Settings").GetChild("Uploading").GetChild("ServerProfiles") );
#endif
		SaveAccounts(xml.getRoot("ImageUploader").GetChild("Settings").GetChild("ServersParams"));
		//std::cerr << "Saving setting to "<< IuCoreUtils::WstringToUtf8((LPCTSTR)fileName_);
		xml.SaveToFile(fileName_);

#if !defined(IU_SERVERLISTTOOL) && !defined(IU_CLI)
		CRegistry Reg;
		Reg.SetRootKey(HKEY_CURRENT_USER);
		// if(ExplorerContextMenu)
		{
			bool canCreateRegistryKey = ( ExplorerContextMenu );
			if ( Reg.SetKey("Software\\Zenden.ws\\Image Uploader", canCreateRegistryKey ) ) {
				if ( ExplorerContextMenu ) {
					Reg.WriteBool( "ExplorerCascadedMenu", ExplorerCascadedMenu );
					Reg.WriteBool("ExplorerContextMenu", ExplorerContextMenu);
					Reg.WriteBool( "ExplorerVideoContextMenu", ExplorerVideoContextMenu );
					Reg.WriteString( "Language", Language );
				} else {
					Reg.DeleteValue("ExplorerCascadedMenu");
					Reg.DeleteValue("ExplorerContextMenu");
					Reg.DeleteValue("ExplorerVideoContextMenu");
					Reg.DeleteValue("Language");
				}
			}
		}
		/*else
		{
		   //Reg.DeleteKey("Software\\Zenden.ws\\Image Uploader");
		}*/
		EnableAutostartup(AutoStartup);

		if (SendToContextMenu_changed   || ExplorerContextMenu_changed) {
			AutoStartup_changed = false;
			BOOL b;
			if ( IsVista() && IsElevated(&b) != S_OK ) {
				// Start new elevated process 
				ApplyRegistrySettings();
			} else {
				// Process has already admin rights
				ApplyRegSettingsRightNow();
			}
		}

		ExplorerContextMenu_changed = false;
		SendToContextMenu_changed = false;

		if (ShowTrayIcon_changed)
		{
			ShowTrayIcon_changed = false;
			if (ShowTrayIcon)
			{
				if (!IsRunningFloatingWnd())
				{
					CmdLine.AddParam(_T("/tray"));
					floatWnd.CreateTrayIcon();
				}
			}
			else
			{
				HWND TrayWnd = FindWindow(0, _T("ImageUploader_TrayWnd"));
				if (TrayWnd) {
					::SendMessage( TrayWnd, WM_CLOSETRAYWND, 0, 0 );
				}
			}
		}
		else if (ShowTrayIcon)
		{
			HWND TrayWnd = FindWindow(0, _T("ImageUploader_TrayWnd"));
			if (TrayWnd)
				SendMessage(TrayWnd, WM_RELOADSETTINGS,  (floatWnd.m_hWnd) ? 1 : 0, (Settings.Hotkeys_changed) ? 0 : 1);
		}

		Settings.Hotkeys_changed  = false;
#endif
		return true;
	}