Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

API - Drives

Status
Not open for further replies.

AntiLiteratos

Programmer
Jul 30, 2003
19
0
0
AR
Hi:

I would like to know how can I get a list of the available units on my PC (A:, C:, D:). There should be a DLL or an API to call, I guess...

Thanks.

GUille.

-----------------------
Guillermo A. Hang
ghang@interclass.com.ar
 
Try this:
Code:
FOR nIndex = 1 TO 26
   STORE DriveType(CHR(64 + nIndex)) TO nType
   IF nType = 1
      LOOP 
   ELSE
      DO CASE 
         CASE nType = 2
            cType = 'Floppy disk'

         CASE nType = 3
            cType = 'Hard disk'

         CASE nType = 4
            cType = 'Removable/Network'

         CASE nType = 5
            cType = 'CD-ROM'

         CASE nType = 6
            cType = 'RAM disk'
          
      ENDCASE 
   ENDIF 
   ?CHR(64 + nIndex) + ': = ' + cType
NEXT


-Dave S.-
[cheers]
Even more Fox stuff at:
 
Thanks a lot, but that's not what I'm looking for. I've already develop it like that.

I need the same solution without using an algorithm. I need an API or a DLL that automatically gives me the units.

Guillermo.

-----------------------
Guillermo A. Hang
ghang@interclass.com.ar
 
Guillermo,
The VFP DriveType() function (or a similar function that was in earlier versions of FoxTools), is a very thin wrapper on a WinAPI function GetDriveType().

If you want it "automatic", try using a Combobox with a RowSource of 7 - Files. Or ?GETDIR() will also give you a list of available drives.

I think I also posted a WSH example of getting all the drives and their information (but I can't find it right now in the Search). You can get a copy of my wsh_drives.scx / .sct in the zip file at (There are a number of other files in there) It's some code I wrote for our local FoxPro user group back in May 2000.

Rick
 
Guillermo,

If I understand you correctly, you need GetLogicalDrives() or GetLogicalDriveStrings(). Try this:


Declare Long GetLogicalDriveStrings in Kernel32 ;
Long nLen, String @cBuffer
nLen = 256
cBuffer = space(nLen)
nLen = GetLogicalDriveStrings(nLen, @cBuffer)
If (nLen > 0)
cBuffer = left(cBuffer, nLen)
= ALines(aDrive, cBuffer, .T., chr(0))
For x = 1 to ALen(aDrive)
? aDrive[x]
Next
endif


-- AirCon --
 
Just so you know, I'd change the line "= ALines(aDrive, cBuffer, .T., chr(0))"
to = ALines(aDrive, strtran(cBuffer,chr(0),chr(13))) to allow compatibility with previous versions.

 
Hi

Try The following.

LOCAL oFileSystem as Scripting.FileSystemObject
LOCAL odrv as Scripting.Drive
oFileSystem=CREATEOBJECT("Scripting.FileSystemObject")
FOR EACH oDrv IN oFileSystem.Drives
MESSAGEBOX(odrv.DriveLetter+": "+TRANSFORM(odrv.DriveType))
NEXT
 
darrellblackhawk,

I didn't test it on VFP6 or earlier. Thanks for the correction :)

Regards

-- AirCon --
 
Thanx Aircon !!!

"GetLogicalDriveStrings in Kernel32"

That's just what I was looking for...

Bye.

Guille.

-----------------------
Guillermo A. Hang
ghang@interclass.com.ar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top