import os
import subprocess
import winreg

def check_winfsp_installation():
    """Verifica si WinFSP está instalado correctamente."""
    try:
        key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\WOW6432Node\WinFsp")
        version = winreg.QueryValueEx(key, "Version")[0]
        install_dir = winreg.QueryValueEx(key, "InstallDir")[0]
        print(f"✓ WinFSP instalado: Versión {version}")
        print(f"✓ Directorio de instalación: {install_dir}")
        return True
    except FileNotFoundError:
        print("❌ WinFSP no está instalado.")
        return False
    except Exception as e:
        print(f"❌ Error al verificar instalación de WinFSP: {e}")
        return False

def restart_winfsp_service():
    """Reinicia el servicio WinFSP Launcher."""
    try:
        subprocess.run(["net", "stop", "WinFsp.Launcher"], check=True)
        subprocess.run(["net", "start", "WinFsp.Launcher"], check=True)
        print("✅ Servicio WinFSP reiniciado correctamente.")
        return True
    except Exception as e:
        print(f"❌ Error al reiniciar el servicio WinFSP: {e}")
        return False
