Forum > Unix
list Windows drive Letters (compile on Linux)
bjlockie1:
--- Quote from: Leledumbo on November 19, 2020, 10:45:58 pm ---Guess you have to ifdef since drive letters is a Windows only concept. Windows API has GetLogicalDrives function that you can call, it will return a single LongWord / DWord value whose bits indicate whether the corresponding drive letter is assigned or not, i.e. bit 0 = drive A, bit 1 = drive B and so on.
--- End quote ---
Thanks.
I have it compiling but it can't ChDir to drive D:\
C:\ and Z:\ work fine.
I'm going to post in the Windows forum.
I could wrap it in a try but I don't think drive D: should be listed.
lucamar:
--- Quote from: bjlockie1 on November 20, 2020, 10:15:44 pm ---I have it compiling but it can't ChDir to drive D:\
C:\ and Z:\ work fine.
--- End quote ---
That might be normal if drive D: is a CD-ROM but there is no CD in it, or a card-reader without card (or an unmounted card), or similar.
winni:
--- Quote from: lucamar on November 21, 2020, 12:33:23 am ---
--- Quote from: bjlockie1 on November 20, 2020, 10:15:44 pm ---I have it compiling but it can't ChDir to drive D:\
C:\ and Z:\ work fine.
--- End quote ---
That might be normal if drive D: is a CD-ROM but there is no CD in it, or a card-reader without card (or an unmounted card), or similar.
--- End quote ---
Or D: is a Linux partition
Or D: is a not formatted partition
Or on D: the filesystem is broken - Windows gives up very quick
Or D: is an external drive and you pulled the plug
Or or or ...
Winni
lucamar:
--- Quote from: winni on November 21, 2020, 12:39:25 am ---Or D: is a Linux partition
Or D: is a not formatted partition
...
Or D: is an external drive and you pulled the plug
--- End quote ---
In none of those cases (except maybe the "broken FS" one) do my Windows machines ever bother to assign a letter.
The general case I was thinking about is a removable-media drive which gets a letter assigned but fails if no media is loaded, like a CD/DVD drive or a card-reader; in that case and unless you have auto-run set on Windows frequently doesn't bother to ascertain whether there is any media at all until you try to access it (which caused me endless headaches with a 7-slot flash card reader: one never knew which letter Window assigned to each slot so I had to try all 7 until one deigned to respond %)).
But I left Windows (except punctually 2K, XP, 7 and 10) on Vista times so I might be missing something :-[
winni:
--- Quote from: lucamar on November 21, 2020, 12:57:42 am ---
In none of those cases (except maybe the "broken FS" one) do my Windows machines ever bother to assign a letter.
--- End quote ---
Hey,hey, hey - you lucky boy!
* Win7 asked me often, if it should format my Linux Partition !!! Somewhere in the Win-Jungle I disabled the partition.
Too long ago, don't know, where it was exactly.
* If you just pull the plug of an external drive and you don't inform the OS to "eject" it, you got a valid drive letter - until you try the first time to read or write from/to that drive.
* If a network drive (Samba) does not react, but it was alive at boot times, Win is really insistent. It retries in an endless loop to reconnect. It shows a drive letter and the hourglass but not the directory. Until the end of all days. Or a reboot.
And so on.
Winni
Navigation
[0] Message Index
[#] Next page
[*] Previous page