"Per Juul Larsen" <ju**@larsen.dkwrote in message
news:26***************************@news.comxnet.dk ...
Hi
my VB program must always start from a removable disk. In addition, on the
removable media to be images of the type *. jpg *. tips.
If not the two conditions are present, the programme will end with a
message.
How do I write this little control function in Visual Basic
regards pjl
When you start the program, simply check the current app.path drive
type. If it is not removable, terminate.
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" _
(ByVal nDrive As String) As Long
Const DRIVE_REMOVABLE = 2
Const DRIVE_REMOTE = 4
Const DRIVE_RAMDISK = 6
Const DRIVE_FIXED = 3
Const DRIVE_CDROM = 5
'syntax: MyDriveType("a:") or MyDriveType(dir1.path) etc..,
Function MyDriveType(ByVal DR As String) As String
DR = Left$(DR, 2)
x% = GetDriveType(DR)
Select Case x%
Case DRIVE_REMOVABLE
MyDriveType = "REMOVABLE " & DR
Case DRIVE_FIXED
MyDriveType = "FIXED " & DR
Case DRIVE_REMOTE
MyDriveType = "REMOTE " & DR
Case DRIVE_RAMDISK
MyDriveType = "RAMDISK " & DR
Case DRIVE_CDROM
MyDriveType = "CDROM " & DR
Case Else
MyDriveType = "UNKNOWN " & DR
End Select
End Function