Hello all,

Q: How can I het localized name of any specific folder.
(Mainly want this for WinVista, aulthough I want it to work for
lower version as well)

eg:
char* getLocalizedName(char* UserPath){
char *LocalizedName;
.....
.....
.....
return LocalizedName;
}

Examples of input Char *, can be any from following
c:\
c:\Programe Files
c:\MyFolder
c:\MyFolder\MyFolder1\MyFolder2\MyFolder3\MyFolder4\MyFolder5

Till now I have done RnD with IShellFolder Methods,
result of various RnD with the help of Groups-MSDN-blogs-
HelpLinks.....
Is that I need to start with *SHGetDesktopFolder*
& then I can reach to Special Folders defined with CSIDL via
*SHGetSpecialFolderLocation*
Then use *GetDisplayNameOf* function to get the localized name

My issue is I need to check specific path provided by user, does this
path has any localized name?
If Yes, return the Localized name
In No, return the same folder name back

If any one can provide any guidence on how can I work arround this
*Special Special Path provided by user*

Any clue will be helpful....

Looking forward to great help from all there....
Thanks in advance...

Bipin Mistry

Re: Getting localized name folder by Alex

Alex
Sat Jul 19 02:10:04 CDT 2008

"Bipin Mistry" wrote:
> My issue is I need to check specific path provided by user, does
> this path has any localized name?
> If Yes, return the Localized name
> In No, return the same folder name back

You can inistialize a lookup table with `SHGetSpecialFolderPath'
calls that go for every possible CSIDL. Then just compare specific
path provided by user against these strings. Of course, you will
need to update this lookup table for every new release of PSDK.

Alex



Re: Getting localized name folder by Bipin

Bipin
Mon Jul 21 19:31:28 CDT 2008

Alex

Thanks for the details, but what you have explained is bit complicated
to work on... so I have taken following way as received in other group
post by me.

Use SHGetDesktopFolder() then ::ParseDisplayName() to get the
LPITEMIDLIST from the path then ::GetDisplayNameOf() &
SIGDN_NORMALDISPLAY
(+ SHGetLocalizedName() on Vista)

I am posting this here so as if any one needs to have batter off then
one can have some options.

Thanks
Bipin Mistry


On 7=A4=EB19=A4=E9, =A4=C8=AB=E14:10, "Alex Blekhman" <tkfx.REM...@yahoo.co=
m> wrote:
> "Bipin Mistry" wrote:
> > My issue is I need to check specific path provided by user, does
> > this path has any localized name?
> > If Yes, return the Localized name
> > In No, return the same folder name back
>
> You can inistialize a lookup table with `SHGetSpecialFolderPath'
> calls that go for every possible CSIDL. Then just compare specific
> path provided by user against these strings. Of course, you will
> need to update this lookup table for every new release of PSDK.
>
> Alex


Re: Getting localized name folder by Bipin

Bipin
Thu Jul 24 20:12:43 CDT 2008

As said earlier, adding code for others reference.
This is working code so if any one have any queries if it dosent work
for you... get back to this thread so as i can revert back.

int GetLocalizedName(char *pFolderPath, char *pFolderName, char
*pDisplayName)
{
LPMALLOC pMalloc;
LPITEMIDLIST pidlPrograms;
LPSHELLFOLDER pFolder = NULL;
LPITEMIDLIST pidl;
LPSHELLFOLDER pDesktopFolder;
char szPath[MAX_PATH];
OLECHAR olePath[MAX_PATH];
ULONG chEaten;
ULONG dwAttributes;
HRESULT hr;
STRRET sName;
LPSHELLFOLDER pSubFolder = NULL;
LPITEMIDLIST pidlCopy = NULL;

// Get the shell's allocator.
if (!SUCCEEDED(SHGetMalloc(&pMalloc)))
return 0;

strcpy(szPath, pFolderPath);
strcat(szPath, "\\");
strcat(szPath, pFolderName);

if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder)))
{
MultiByteToWideChar(CP_ACP,
MB_PRECOMPOSED,
szPath,
-1,
olePath,
MAX_PATH);

hr = pDesktopFolder->ParseDisplayName( NULL,
NULL,
(LPOLESTR)olePath,
&chEaten,
&pidl,
&dwAttributes);
if (FAILED(hr))
{
return 0;
// Handle error.
}
}

if (SUCCEEDED(pDesktopFolder->GetDisplayNameOf(
pidl, SHGDN_NORMAL,
&sName))) {

LPSTRRET lpStr = &sName;
LPSTR lpsz;
int cch;

switch (lpStr->uType) {
case STRRET_WSTR:
cch = WideCharToMultiByte(CP_SYMBOL, 0,
lpStr->pOleStr, -1, NULL, 0, NULL, NULL);
lpsz = (LPSTR) pMalloc->Alloc(cch*2);
if (lpsz != NULL) {
WideCharToMultiByte(CP_ACP, 0,
lpStr->pOleStr, -1, lpsz, cch*2, NULL, NULL);
printf("%s\n", lpsz);
}
strcpy(pDisplayName, lpsz);
pMalloc->Free(lpsz);
break;

case STRRET_OFFSET:
strcpy(pDisplayName, ((char *) pidl) + lpStr-
>uOffset);

printf("%s\n", ((char *) pidl) + lpStr->uOffset);
break;

case STRRET_CSTR:
strcpy(pDisplayName, lpStr->cStr);
printf("%s\n", lpStr->cStr);
break;
}
}
pMalloc->Free(pidl);
pMalloc->Release();

return 1;
}



On Jul 22, 9:31 am, Bipin Mistry <bpnmis...@gmail.com> wrote:
> Alex
>
> Thanks for the details, but what you have explained is bit complicated
> to work on... so I have taken following way as received in other group
> post by me.
>
> Use SHGetDesktopFolder() then ::ParseDisplayName() to get the
> LPITEMIDLIST from the path then ::GetDisplayNameOf() &
> SIGDN_NORMALDISPLAY
> (+ SHGetLocalizedName() on Vista)
>
> I am posting this here so as if any one needs to have batter off then
> one can have some options.
>
> Thanks
> Bipin Mistry
>
> On 7月19日, 午後4:10, "Alex Blekhman" <tkfx.REM...@yahoo.com> wrote:
>
>
>
> > "Bipin Mistry" wrote:
> > > My issue is I need to check specific path provided by user, does
> > > this path has any localized name?
> > > If Yes, return the Localized name
> > > In No, return the same folder name back
>
> > You can inistialize a lookup table with `SHGetSpecialFolderPath'
> > calls that go for every possible CSIDL. Then just compare specific
> > path provided by user against these strings. Of course, you will
> > need to update this lookup table for every new release of PSDK.
>
> > Alex- Hide quoted text -
>
> - Show quoted text -