TSE: Issue: Drive type

10 views
Skip to first unread message

knud van eeden

unread,
Nov 12, 2025, 7:20:17 PM11/12/25
to SemWare TSE Pro Text Editor, S.E. Mitchell
Hello,

[<ChatGPT>]:

> If I run this simple SAL program it gives as output an enumeration of the drive letters.
>
> Its drive type output contains also 'floppy'.
>
> The assumed more correct output should be 'removable'.
>
> Which Microsoft Windows API is used to get this output,
> like 'fixed', 'removable', 'DVD', 'CDROM'
> and what are the Window constants defined in it.
>

---
PROC Main()
 string drivestr[_MAXPATH_]
 drivestr = ""
 CreateTempBuffer()
 while NextDiskConnection( drivestr, _INCLUDE_REMOVEABLE_DRIVES_ )
  AddLine( drivestr )
 endwhile
END
---

If I run it here it gives here:

---
C: [fixed]
D: [fixed]  Elements
E: [fixed]  My Passport
F: [floppy]
G: [fixed]  KINGSTON 1 TERABYTE
H: [fixed]  My Passport
I: [floppy]
J: [floppy]
K: [CDROM]
L: [CDROM]  DTL+G3
U: [CDROM]
Z: [fixed]  Elements
---

===

But the correct output should be (I opened Microsoft Windows 'DiskManager'
by right clicking on the start menu and looked at what was used there at each drive)

That showed:

---
C: [fixed]
D: [fixed]  Elements
E: [fixed]  My Passport
F: [removable]
G: [basic]  KINGSTON 1 TERABYTE
H: [fixed]  My Passport
I: [removable]
J: [removable]
K: [CDROM]
L: [DVD]  DTL+G3
U: [CDROM]
Z: [fixed]  Elements
---


Short answer:

The classic Windows API for "drive type" is GetDriveType (Kernel32).

It returns one of these constants (from WinBase.h):

DRIVE_UNKNOWN        = 0
DRIVE_NO_ROOT_DIR    = 1
DRIVE_REMOVABLE      = 2   // floppy, USB sticks, SD readers, etc.
DRIVE_FIXED          = 3   // HDD/SSD
DRIVE_REMOTE         = 4   // network share
DRIVE_CDROM          = 5   // any optical (CD/DVD/BD)
DRIVE_RAMDISK        = 6

Volume label (e.g., "My Passport") is obtained with GetVolumeInformation.

Enumerating letters is typically done with GetLogicalDrives (bitmask) or GetLogicalDriveStrings.

That is enough to produce the strings you want:

map DRIVE_REMOVABLE [removable] (not "[floppy]").

map DRIVE_CDROM [CDROM] (this covers both CD and DVD unless you probe deeper).

Why TSE shows "[floppy]":

Internally, the function behind NextDiskConnection() almost certainly
calls GetDriveType and then labels all DRIVE_REMOVABLE as "floppy" (an
old convention). That is why your F:, I:, J: USB sticks appear as
"[floppy]".

If you also want DVD vs CD (Disk Management can show "DVD"):

GetDriveType would not distinguish them (it only returns DRIVE_CDROM).

You need a deeper query via DeviceIoControl:

IOCTL_CDROM_GET_CONFIGURATION (MMC) feature/profile codes such as:

FEATURE_PROFILE_CD_ROM = 0x0008

FEATURE_PROFILE_CD_R = 0x0009

FEATURE_PROFILE_CD_RW = 0x000A

FEATURE_PROFILE_DVD_ROM = 0x0010

FEATURE_PROFILE_DVD_R = 0x0011

FEATURE_PROFILE_DVD_RAM = 0x0012

FEATURE_PROFILE_DVD_RW = 0x0013 (etc.)

or IOCTL_STORAGE_QUERY_PROPERTY (StorageDeviceProperty) for broader device info.

Minimal C mapping you should use in a helper DLL
UINT type = GetDriveTypeW(L"C:\\"); // root path "X:\\"
switch (type) {
  case DRIVE_REMOVABLE: wprintf(L"[removable]"); break;
  case DRIVE_FIXED:     wprintf(L"[fixed]");     break;
  case DRIVE_REMOTE:    wprintf(L"[remote]");    break;
  case DRIVE_CDROM:     wprintf(L"[CDROM]");     break; // CD or DVD
  case DRIVE_RAMDISK:   wprintf(L"[ramdisk]");   break;
  default:              wprintf(L"[unknown]");   break;
}

What to change in SAL (conceptually)

You can not call GetDriveType directly from SAL, so either:

1) keep using NextDiskConnection() and post-process its text: replace
   "[floppy]" with "[removable]"; or

or

2) add a tiny helper DLL that exposes
   GetDriveTypeW/GetVolumeInformationW and returns the properly
   formatted string ("e: [removable] My Passport").


with friendly greetings
Knud van Eeden

Reply all
Reply to author
Forward
0 new messages