Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2003, 02:04 PM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default DriveType constants

Can anyone tell me how to identify the type of drive a user may select from a drive box? i.e. c: = fixed, d: = removable, e:= cd etc?

The reason being is that dependant on what the user selects from a drive box on one of my forms, i want to know if there is going to be a problem, i.e. trying to write to a CD etc.

cheers

Regards

Russ (Programing on L plates..!)
__________________
Regards

Russ (Programing on L plates..!)
 
Old June 22nd, 2003, 08:23 AM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use the API function GetDriveType

Code:
Public Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long

Public Const DRIVE_UNKNOWN As Long = 1
Public Const DRIVE_REMOVABLE As Long = 2
Public Const DRIVE_FIXED As Long = 3
Public Const DRIVE_REMOTE As Long = 4
Public Const DRIVE_CDROM As Long = 5
Public Const DRIVE_RAMDISK As Long = 6


  Dim sMsg As String

  Select Case GetDriveType("c:")
    Case DRIVE_UNKNOWN
      sMsg = "The drive type cannot be determined"

    Case DRIVE_REMOVABLE
      sMsg = "The disk can be removed from the drive."

    Case DRIVE_FIXED
      sMsg = "The disk cannot be removed from the drive."

    Case DRIVE_REMOTE
      sMsg = "The drive is a remote (network) drive."

    Case DRIVE_CDROM
      sMsg = "The drive is a CD-ROM drive."

    Case DRIVE_RAMDISK
      sMsg = "The drive is a RAM disk."
  End Select


If you want more info, got to http://msdn.microsoft.com/library/de...tdrivetype.asp

Stéphane





Similar Threads
Thread Thread Starter Forum Replies Last Post
declaring constants and pointer constants proslambano BOOK: Ivor Horton's Beginning Visual C++ 2005 3 March 6th, 2007 03:32 PM
Constants in XSL austinf XSLT 2 August 29th, 2006 06:04 AM
Global/Public Constants elansolutionsltd Access 6 May 13th, 2005 12:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.