Message-Id: <3.0.16.19971008213513.37a73144@hem1.passagen.se> Date: Wed, 08 Oct 1997 21:35:17 -0400 To: zager AT post DOT comstar DOT ru From: Peter Palotas Subject: Re: Logical disks list. Cc: djgpp AT delorie DOT com Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Precedence: bulk At 20.11 1997-10-08 +0300, you wrote: >Hi, >Just one small question :) >How can I get the list of disks letters wich is in FAT (including A: B:) >or mapped to some network shares ? >Thanks. Well, I have made a program for this. I don't know if this is the best solution or even if it works everywhere, but it works for me anyway, although it is somewhat complicated. If anyone knows of easier ways to do this, please let me know. (I wrote this a long time ago, and I really think there must be an easier way) Source code follows: File: DOSMEM.H --------------------------------------------------------------------------- #include #include #include class DOSMem { private: _go32_dpmi_seginfo _mem_info; public: DOSMem(unsigned short size) { _mem_info.size = (size + 15) / 16; _go32_dpmi_allocate_dos_memory(&_mem_info); } ~DOSMem(void) { _go32_dpmi_free_dos_memory(&_mem_info); } bool memset(int offset, unsigned char ch, unsigned int num) { for (unsigned int i = offset; i < (unsigned int)(offset + num) && i < (unsigned int)_mem_info.size; i++) dosmemput(&ch, 1, _mem_info.rm_segment * 16 + _mem_info.rm_offset + i); return true; } bool memcpy(int offset, void *buffer, int num) { dosmemput(buffer, num, _mem_info.rm_segment * 16 + _mem_info.rm_offset + offset); return true; } int segment(void) { return _mem_info.rm_segment; } int offset(void) { return _mem_info.rm_offset; } int size(void) { return _mem_info.size; } }; File: DISKLIST.CC -------------------------------------------------------------------------- #include #include #include #include "dosmem.h" int main(void) { unsigned int number_of_available_drives = setdisk(getdisk()); /* setdisk() returns the maximum number of possible drives on the system. Pass getdisk() to avoid switching the drive. */ printf("Available Logical Drives: %i\n", number_of_available_drives); unsigned int number_of_diskdrives = ((_bios_equiplist() & 192) >> 6) + 1; /* bits 6-7 in the bios equipment word equals the number of installed diskdrives - 1. (i.e. 00 = 1, 01 = 2, 10 = 3, 11 = 4). */ printf("\nNumber of diskdrives on system: %i\n", number_of_diskdrives); DOSMem FCB(37); DOSMem Drive(16); __dpmi_regs regs; for (unsigned int i = 0; i < number_of_available_drives; i++) { char drv[] = "A:\\"; drv[0] = i + 'A'; Drive.memcpy(0, drv, 4); regs.x.ds = Drive.segment(); regs.x.si = Drive.offset(); regs.x.es = FCB.segment(); regs.x.di = FCB.offset(); regs.x.ax = 0x2900; __dpmi_int(0x21, ®s); /* Drive B is sometimes reported as a valid drive, although it isn't. Therefore compare it with the number of diskdrives installed according to bios. */ if (drv[0] != 'B' || number_of_diskdrives > 1) if (regs.h.al != 0xFF) printf("Drive %s exists!\n", drv); } }; -- Peter Palotas alias Blizzar -- blizzar AT hem1 DOT passagen DOT se -- ***************************************************** * A brief description of DJGPP: * * NEVER BEFORE HAS SO FEW DONE SO MUCH FOR SO MANY! * *****************************************************