Windows Presentation Foundation (WPF) applications can leverage GPU acceleration in Citrix Virtual Apps and Desktops (CVAD) environments running Windows Multi-session OS. By enabling WPF rendering on the server’s GPU, this reduces CPU load and improves graphics performance for WPF applications.
This article provides a PowerShell script to configure the necessary registry settings and register specific WPF applications for GPU-based rendering in Citrix HDX environments.
Use this script if:
regedit.Important: Do not run this script on a Single-session OS (Windows 10/11 VDI) as it may cause connection issues or other unexpected behaviour.
The following registry values will be configured under:HKLM\Software\Citrix\CtxHook\AppInit_DLLs\Graphics Helper
| Registry Value | Type | Expected Value |
|---|---|---|
| AdapterHandle | REG_DWORD | 0x00000001 |
| DevicePath | REG_DWORD | 0x00000001 |
| Flag | REG_DWORD | 0x00000412 |
| WPF | REG_DWORD | 0x00000001 |
For each WPF application, a sub-key must be created with the executable name:HKLM\Software\Citrix\CtxHook\AppInit_DLLs\Graphics Helper\mywpfapp.exe
When executed, the script:
For the changes to take effect, restart the VDA after running the script.
# Define the registry paths$graphicsHelperPath = "HKLM:\SOFTWARE\Citrix\CtxHook\AppInit_DLLs\Graphics Helper"$requiredSettings = @{ "AdapterHandle" = 0x00000001 "DevicePath" = 0x00000001 "Flag" = 0x00000412 "WPF" = 0x00000001}
# Function to check if the system is a VDA and Multi-session OSfunction Test-VdaMultiSession { $vdaKey = "HKLM:\SOFTWARE\Citrix\VirtualDesktopAgent" $multiSessionKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\TSAppCompat" if (Test-Path $vdaKey) { $isMultiSession = (Get-ItemProperty -Path $multiSessionKey -Name "TSAppCompat" -ErrorAction SilentlyContinue).TSAppCompat if ($isMultiSession -eq 1) { return $true } } return $false}
if (-not (Test-VdaMultiSession)) { Write-Host "This script should only be run on a Multi-session VDA. Exiting..." -ForegroundColor Red exit}
# Ensure the Graphics Helper registry key existsif (!(Test-Path $graphicsHelperPath)) { New-Item -Path $graphicsHelperPath -Force | Out-Null Write-Host "Created Graphics Helper registry key." -ForegroundColor Green}
# Check and set required registry valuesforeach ($key in $requiredSettings.Keys) { $existingValue = (Get-ItemProperty -Path $graphicsHelperPath -Name $key -ErrorAction SilentlyContinue).$key if ($existingValue -ne $requiredSettings[$key]) { Set-ItemProperty -Path $graphicsHelperPath -Name $key -Value $requiredSettings[$key] -Type DWord Write-Host "Set $key to $($requiredSettings[$key])" -ForegroundColor Green } else { Write-Host "$key is already set correctly." -ForegroundColor Yellow }}
# Prompt the user for the application path or name$appInput = Read-Host "Enter the application path or name (e.g., C:\\Path\\To\\App.exe or App.exe)"
# Extract only the executable name$appName = [System.IO.Path]::GetFileName($appInput)
# Ensure the application name has .exe extensionif (![System.IO.Path]::HasExtension($appName) -or [System.IO.Path]::GetExtension($appName) -ne ".exe") { $appName = "$appName.exe"}
if (-not $appName -or $appName -eq "") { Write-Host "Invalid input. Please enter a valid application name." -ForegroundColor Red exit}
# Ensure the sub-key for the application exists$appRegistryPath = "$graphicsHelperPath\\$appName"if (!(Test-Path $appRegistryPath)) { New-Item -Path $appRegistryPath -Force | Out-Null Write-Host "Created registry key for $appName under Graphics Helper." -ForegroundColor Green} else { Write-Host "$appName is already registered under Graphics Helper." -ForegroundColor Yellow}
Write-Host "Reboot the server for the settings to take effect." -ForegroundColor Cyan
For more information, refer to the official Citrix documentation: Windows Presentation Foundation (WPF) Rendering in HDX