Fix desktop file creation when non-standard languages are used
User reported:
It appears they were using hebrew language.
Someone in #powershell
suggested to use this code:
Add-Type -Namespace Shell -Name Native -MemberDefinition @'
[DllImport("Shell32.dll", CharSet = CharSet.Unicode)]
public static extern int SHGetKnownFolderPath(
Guid rfid,
uint dwFlags,
IntPtr hToken,
out string ppszPath);
'@
$desktopId = [Guid]"B4BFCC3A-DB2C-424C-B029-7FE99A87C641"
$path = ""
$res = [Shell.Native]::SHGetKnownFolderPath($desktopId, 0, [IntPtr]::Zero, [ref]$path)
if ($res) {
throw "Failed to get desktop folder: $res"
}
$path