Hello.
Speical folders, like Desktop, usually have different display names.
For example, in Japanese Windows, it's displayed as "$B%G%9%/%H%C%W(B". I want
to get the this displayed name of a special folder but I can't find a
suitable method. Environment.Get FolderPath() is to get the path not
the name. There's no way provided the .NET BCL?
I also tried to get it through Win32 API. I looked up the MSDN site
(http://support.microsoft.com/kb/319350), and wrote a code like the
following, but it didn't work. It showed "top" instead of "Desktop" on
my PC (64 bit, Vista, English).
Path =
Environment.Get FolderPath(Envi ronment.Special Folder.DesktopD irectory);
SHFILEINFO shinfo=new SHFILEINFO();
SHGetFileInfo(P ath, 0, ref shinfo, (uint)Marshal.S izeOf(shinfo),
SHGFI_DISPLAYNA ME);
MessageBox.Show (shinfo.szDispl ayName);
///////////////////////////// P/Invoke declarations
[StructLayout(La youtKind.Sequen tial)]
public struct SHFILEINFO
{
public IntPtr hIcon;
public IntPtr iIcon;
public uint dwAttributes;
[MarshalAs(Unman agedType.ByValT Str, SizeConst = 260)]
public string szDisplayName;
[MarshalAs(Unman agedType.ByValT Str, SizeConst = 80)]
public string szTypeName;
};
public const int SHGFI_DISPLAYNA ME = 0x000000200; // get display
name
[DllImport("shel l32.dll")]
public static extern IntPtr SHGetFileInfo(s tring pszPath, uint
dwFileAttribute s, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint
uFlags);
Speical folders, like Desktop, usually have different display names.
For example, in Japanese Windows, it's displayed as "$B%G%9%/%H%C%W(B". I want
to get the this displayed name of a special folder but I can't find a
suitable method. Environment.Get FolderPath() is to get the path not
the name. There's no way provided the .NET BCL?
I also tried to get it through Win32 API. I looked up the MSDN site
(http://support.microsoft.com/kb/319350), and wrote a code like the
following, but it didn't work. It showed "top" instead of "Desktop" on
my PC (64 bit, Vista, English).
Path =
Environment.Get FolderPath(Envi ronment.Special Folder.DesktopD irectory);
SHFILEINFO shinfo=new SHFILEINFO();
SHGetFileInfo(P ath, 0, ref shinfo, (uint)Marshal.S izeOf(shinfo),
SHGFI_DISPLAYNA ME);
MessageBox.Show (shinfo.szDispl ayName);
///////////////////////////// P/Invoke declarations
[StructLayout(La youtKind.Sequen tial)]
public struct SHFILEINFO
{
public IntPtr hIcon;
public IntPtr iIcon;
public uint dwAttributes;
[MarshalAs(Unman agedType.ByValT Str, SizeConst = 260)]
public string szDisplayName;
[MarshalAs(Unman agedType.ByValT Str, SizeConst = 80)]
public string szTypeName;
};
public const int SHGFI_DISPLAYNA ME = 0x000000200; // get display
name
[DllImport("shel l32.dll")]
public static extern IntPtr SHGetFileInfo(s tring pszPath, uint
dwFileAttribute s, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint
uFlags);
Comment