🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10119

Re: Logical drives question

#10119
From: Remy Lebeau (TeamB)
Date: Mon, 17 May 2004 02:41
56 lines
2568 bytes
"Martin C" <martincplus@hotmail.com> wrote in message
news:40a81e16@newsgroups.borland.com...

> What I am exactly looking for is to display Drive Names
> as they are displayed in Windows Explorer

You need to use the IShellFolder() interface for that.  Look at the
SHGetDesktopFolder() function and the ParseDisplayName() and
GetDisplayNameOf() methods of IShellFolder.  For example:

    #include <utilcls.h>

    AnsiString __fastcall GetDisplayName(const AnsiString &Path)
    {
        TComInterface<IShellFolder> Desktop;
        ::SHGetDesktopFolder(&Desktop);
        if( Desktop )
        {
            ULONG Unused;
            LPITEMIDLIST pidl = NULL;
            if( SUCCEEDED(Desktop->ParseDisplayName(NULL, NULL,
WideString(Path), &Unused, &pidl, NULL)) )
            {
                STRRET strRet = {0};
                TCHAR buffer[256] = {0};
                if( SUCCEEDED(Desktop->GetDisplayNameOf(pidl, SHGDN_NORMAL,
&strRet)) )
                    ::StrRetToBuf(&strRet, pidl, buffer, 255);
                ::CoTaskMemFree(pidl);
                return buffer;
            }
        }
        return "";
    }

    ListItem->SubItems->Add(GetDisplayName(drive));

Alternatively, look at the SHGetFileInfo() function with the
SHGFI_DISPLAYNAME flag, ie:

    AnsiString __fastcall GetDisplayName(const AnsiString &Path)
    {
        SHFILEINFO shfi = {0};
        ::SHGetFileInfo(Path.c_str(), 0, &shfi, sizeof(shfi),
SHGFI_DISPLAYNAME);
        return shfi.szDisplayName;
    }

Either way, you can then add the display name to your ListView when needed,
ie:

    ListItem->SubItems->Add(GetDisplayName(drive));


Gambit
Technical Details
Message-ID: <40a82784$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40a81e16@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,64d555b3ba996895
X-Google-Attributes: gid10cc67,public
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40a81e16@newsgroups.borland.com>
Subject: Re: Logical drives question
Date: Sun, 16 May 2004 19:41:24 -0700
Lines: 58
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.138.253
Message-ID: <40a82784$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1084761988 67.22.138.253 (16 May 2004 19:46:28 -0700)
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail