Shell Functions


SHGetLocalizedName Function

Retrieves the localized name of a file in a Shell folder.

Syntax

HRESULT SHGetLocalizedName(      
    LPCWSTR pszPath,     LPWSTR pszResModule,     UINT cch,     int *pidsRes );

Parameters

pszPath
[in] A pointer to a string that specifies the fully qualified path of the file.
pszResModule
[out] When this function returns, contains a pointer to a string resource that specifies the localized version of the file name.
cch
[out] When this function returns, contains the size of the string, in WCHARs, at pszResModule.
pidsRes
[out] When this function returns, contains a pointer to the ID of the localized file name in the resource file.

Return Value

Returns S_OK if successful, or an error value otherwise.

Function Information

Minimum DLL Versionshell32.dll
Custom ImplementationNo
Headershellapi.h
Import libraryNone
Minimum operating systems Windows Vista
Tags : misleading


Community Content

Thomas Lee
Visual Basic 9 Declaration
<DllImport("shell32.dll", CallingConvention:=CallingConvention.Winapi, CharSet:=CharSet.Unicode, EntryPoint:="SHGetLocalizedName", ExactSpelling:=True)> _
Public Function SHGetLocalizedName(ByVal pszPath As String, ByVal pszResModule As StringBuilder, ByRef cch%, <Out()> ByRef pidsRes As Integer) As Integer
End Function




Note: This function usually does NOT work. It does not work for path with trailing \. It does not work for relocated folders (such as D:\Users or D:\Users\Dzonny\Pictures) even when Windows Explorer shows folder names correctly. It works for relocated files. It returns only last component of path.
The pszResModule argument does NOT contain localied version of name. It contains path (with environment variables not expanded) which contains resource which contains the actual localied version of name.


See:

http://blogs.msdn.com/michkap/archive/2007/01/18/1487464.aspx#1736328 for details


Page view tracker