Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detecting Network Drives
Message
Information générale
Forum:
Visual Basic
Catégorie:
Autre
Divers
Thread ID:
00087939
Message ID:
00087978
Vues:
29
>How can I detect if a drive is a local or network drive ??
>
>Dennis McDermott


Use the GetDriveType API call.

This function returns you whether the disk inspected is a floppy, hard or network or drive. I don't remember the other constant but you can find it in a book (like the one of Dan Appleman) or simply by making a few test.

I have joined an example of code that look for all HD on the PC.

Declare Function GetDriveType _
Lib "kernel32" _
Alias "GetDriveTypeA" _
(ByVal nDrive As String) As Long
Public Const DRIVE_FIXED = 3

Private Function SearchLocalDrives() As String
' Search all hard disks on the PC
Dim strDrive As String * 1
Dim strResult As String

strDrive = "A"
strResult = ""
Do
If GetDriveType(strDrive & ":") = DRIVE_FIXED Then
strResult = strResult & strDrive
End If
strDrive = Chr(Asc(strDrive) + 1)
Loop Until Asc(strDrive) > Asc("Z")
SearchLocalDrives = strResult
End Function
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform