none
ShellExplorerAPI.SHGetFileInfo() is displaying "?????" for other language folders. RRS feed

  • Question

  • I use "SHGetFileInfo()" and the structure "SHFILEINFO" to get the name of the folders and drives which present in windows operating system.

    If a localized operating system to change the setting "Current language for non-Unicode programs", these functions return a value "??? ?????????" for Japanese language folders.this is my reference code to get the file name.

       [DllImport("shell32.dll")]
         public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttribs, out SHFILEINFO psfi, uint cbFileInfo, SHGFI uFlags);

    public struct SHFILEINFO
            {
                public IntPtr hIcon;
                public int iIcon;
                public uint dwAttributes;
                [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
                public string szDisplayName;
                [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
                public string szTypeName;
            }

            public string DisplayName
            {
                get { return m_strDisplayName; }
                set { m_strDisplayName = value; }
            }

     For getting file path File path, I'm using below constructor to call every time to get path . but "shInfo.szDisplayName"  is return a value "??? ?????????" instead of Japanese folder name in En-Us Operating system.

      public ShellItem()
       {
                 DisplayName = shInfo.szDisplayName;  /////This is one used to get the file path
               
        }

          Find the below image to show the application folder name with respect to windows explorer.  Please help me on this                                                                                                                                                                                       

    


    Monday, January 14, 2019 6:18 AM

Answers

  • Hi ,

    Is your problem solved? If so, please post "Mark as answer" to the appropriate answer , so that it will help other members to find solution quickly if they faces similar issue.

    Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, January 29, 2019 8:44 AM
    Moderator

All replies

  • Have you tried ‘[DllImport("shell32", CharSet=CharSet.Unicode)]’?

    Monday, January 14, 2019 8:52 AM
  • I have tried that. If I write[DllImport("shell32", CharSet=CharSet.Unicode)]’  on the top of SHGetFileInfo() , the top directory folders like(C,D,E and other shared drives folders names getting junk characters like "â€".

    Thursday, January 17, 2019 5:20 AM
  • Anyone got idea on this? 

    Monday, January 28, 2019 4:33 AM
  • Try the next definitions:

    [DllImport( "shell32", CharSet = CharSet.Unicode )]
    public static extern IntPtr SHGetFileInfoW( string pszPath, uint dwFileAttribs, out SHFILEINFOW psfi, uint cbFileInfo, SHGFI uFlags );
    
    [StructLayout( LayoutKind.Sequential, CharSet = CharSet.Unicode )]
    public struct SHFILEINFOW
    {
        public IntPtr hIcon;
        public int iIcon;
        public uint dwAttributes;
        [MarshalAs( UnmanagedType.ByValTStr, SizeConst = 260 )]
        public string szDisplayName;
        [MarshalAs( UnmanagedType.ByValTStr, SizeConst = 80 )]
        public string szTypeName;
    }
    

    Monday, January 28, 2019 7:49 AM
  • Hi ,

    Is your problem solved? If so, please post "Mark as answer" to the appropriate answer , so that it will help other members to find solution quickly if they faces similar issue.

    Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, January 29, 2019 8:44 AM
    Moderator