🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Logical drives question

#10118
From: Martin C
Date: Mon, 17 May 2004 05:04
68 lines
3061 bytes
Hi all,

I am making a search function in my program where I am trying to list all
fixed drives and cd-rom found on my client machine in a TListView so the
client can select which hard drives/ cd-rom to be included in each search
process. So I used   GetLogicalDriveStrings, GetVolumeInformation and
GetDriveType functions although I am not receiving the exact result I was
looking for.

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

Master01(C:)
DVD/CD-RW Drive (D:)

can some one please advise me how I can reach such output result?

Thanks

Here is the code I was using to get all logical drives on my client
machines:


#define FILESYSNAMEBUFSIZE 1024
#define BUFSIZE 1024

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  char buffer[105] = {0};
 char DNamebuffer[BUFSIZE];
 char DNamebuffer2[BUFSIZE];
 DWORD dwSysFlags;
 char FileSysNameBuf[FILESYSNAMEBUFSIZE];

 ListView1->Items->Clear();

 if(GetLogicalDriveStrings(104, buffer))
 {
        for(char *drive = buffer; *drive != 0; drive += 4)
        {
            UINT type = GetDriveType(drive);

               // do something with drive and type as needed

               if(type==DRIVE_FIXED)
               { GetVolumeInformation(drive, DNamebuffer, BUFSIZE, NULL,
NULL, &dwSysFlags, FileSysNameBuf, FILESYSNAMEBUFSIZE);
                 TListItem  *ListItem;
                 ListItem = ListView1->Items->Add();
                 ListItem->Caption = drive;
                 ListItem->SubItems->Add(DNamebuffer);
                 ListItem->SubItems->Add(FileSysNameBuf);
               }
               else if(type==DRIVE_CDROM)
               { GetVolumeInformation(drive, DNamebuffer2, 32, NULL, NULL,
NULL, NULL, 0);
                 TListItem  *ListItem;
                 ListItem = ListView1->Items->Add();
                 ListItem->Caption = drive;
                 ListItem->SubItems->Add(DNamebuffer2);
               }
        }
 }


}
//--------------------------------------------------------------------------
-
Technical Details
Message-ID: <40a81e16@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newspeer1.stngva01.us.to.verio.net!news.verio.net!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!peernews3.colt.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,64d555b3ba996895,start
X-Google-Attributes: gid10cc67,public
From: "Martin C" <martincplus@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Logical drives question
Date: Sun, 16 May 2004 23:04:06 -0600
Lines: 70
Organization: V Safe
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 81.10.4.238
Message-ID: <40a81e16@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1084759574 81.10.4.238 (16 May 2004 19:06:14 -0700)
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newspeer1.stngva01.us.to.verio.net!news.verio.net!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!peernews3.colt.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail