|
-
Sep 20th, 2002, 11:07 AM
#1
Thread Starter
Addicted Member
CD Rom Drive?
How I can make my program perform certain functions...performing those functions will depend whether the program is running from CD ROM or C Drive... it should perform certain function if it is running from CD-ROM Drive....and it will perfrom other function if it is running from C Drive....
-
Sep 20th, 2002, 11:10 AM
#2
So, what do you want to check...is there a CD in the drive or not?
And, if so, is the CD mine?
-
Sep 20th, 2002, 11:11 AM
#3
Frenzied Member
VB Code:
Dim obj As New FileSystemObject
Dim drv As Drive
Private Sub Command1_Click()
Set drv = obj.GetDrive(Mid(App.Path, 1, 3))
MsgBox drv.DriveType
End Sub
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Sep 20th, 2002, 11:13 AM
#4
Need-a-life Member
Try this:
VB Code:
Option Explicit
Private Declare Function GetVolumeInformation Lib _
"kernel32.dll" Alias "GetVolumeInformationA" (ByVal _
lpRootPathName As String, ByVal lpVolumeNameBuffer As _
String, ByVal nVolumeNameSize As Integer, _
lpVolumeSerialNumber As Long, lpMaximumComponentLength _
As Long, lpFileSystemFlags As Long, ByVal _
lpFileSystemNameBuffer As String, ByVal _
nFileSystemNameSize As Long) As Long
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Const DRIVE_CDROM = 5
Private Const DRIVE_FIXED = 3
Private Const DRIVE_RAMDISK = 6
Private Const DRIVE_REMOTE = 4
Private Const DRIVE_REMOVABLE = 2
Private Sub Form_Load()
MsgBox "A:\" & DriveType("A:\")
MsgBox "C:\" & DriveType("C:\")
MsgBox "D:\" & DriveType("D:\")
MsgBox "E:\" & DriveType("E:\")
MsgBox "F:\" & DriveType("F:\")
MsgBox "G:\" & DriveType("G:\")
End Sub
Public Function DriveType(Drive As String) As String
Dim Tipo As Integer
Tipo = GetDriveType(Drive)
Select Case Tipo
Case DRIVE_CDROM
DriveType = "CD-ROM"
Case DRIVE_FIXED
DriveType = "Fixed"
Case DRIVE_RAMDISK
DriveType = "RAM Disk"
Case DRIVE_REMOTE
DriveType = "Remote Disk"
Case DRIVE_REMOVABLE
DriveType = "Removable"
End Select
End Function
Public Function GetSerialNumber(strDrive As String, DiskLabel As String) As String
Dim SerialNum As Long
Dim Res As Long
Dim Temp1 As String
Dim Temp2 As String
Temp1 = String$(255, Chr$(0))
Temp2 = String$(255, Chr$(0))
Res = GetVolumeInformation(strDrive, Temp1, _
Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2))
GetSerialNumber = Hex$(SerialNum)
GetSerialNumber = String$(8 - Len(GetSerialNumber), "0") + GetSerialNumber
GetSerialNumber = Left$(GetSerialNumber, 4) + "-" + Mid$(GetSerialNumber, 5)
DiskLabel = Trim0(Temp1)
End Function
Public Function Trim0(ByVal e0 As String)
Dim i As Integer
For i = Len(e0) To 1 Step -1
If Mid$(e0, i, 1) <> Chr$(0) Then Exit For
Next i
Trim0 = Left$(e0, i)
End Function
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Sep 20th, 2002, 11:14 AM
#5
Thread Starter
Addicted Member
I wanna check which dirve the progaram is running from? is it running from C Drive or CD-ROM Drive..and accordingly I will build a code to perform certain function... thanks
-
Sep 20th, 2002, 11:14 AM
#6
-= B u g S l a y e r =-
VB Code:
Private Declare Function GetDriveType Lib "kernel32" _
Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Const DRIVE_CDROM = 5
Private Sub Form_Load()
Dim tmpStr As String
tmpStr = Left(App.Path, 3)
If GetDriveType(tmpStr) = DRIVE_CDROM Then
'app is ran from cd...
Else
'app started from other device
End If
End Sub
-
Sep 20th, 2002, 11:16 AM
#7
Need-a-life Member
Originally posted by vb6-lover
I wanna check which dirve the progaram is running from? is it running from C Drive or CD-ROM Drive..and accordingly I will build a code to perform certain function... thanks
Peet gave you the answer...
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Sep 20th, 2002, 11:17 AM
#8
Frenzied Member
Peet, is there a difference (as far as execution and functionality goes) between
Left("abcd",3) and Mid("abcd",1,3)
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Sep 20th, 2002, 11:19 AM
#9
Need-a-life Member
Originally posted by KayJay
Peet, is there a difference (as far as execution and functionality goes) between
Left("abcd",3) and Mid("abcd",1,3)
No
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Sep 20th, 2002, 11:23 AM
#10
Frenzied Member
Thanx
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Sep 20th, 2002, 11:25 AM
#11
-= B u g S l a y e r =-
Originally posted by KayJay
Peet, is there a difference (as far as execution and functionality goes) between
Left("abcd",3) and Mid("abcd",1,3)
No, and from what I can see your answer will do the job just as fine as what i suggested... its just me being very slow... I swear there were no answers to this thread when I started replying ... I'm getting old... *sob*
-
Sep 20th, 2002, 11:29 AM
#12
Frenzied Member
-
Sep 20th, 2002, 11:38 AM
#13
-= B u g S l a y e r =-
Same here.
BTW for the record, I have finalized 3 deals and with no small part on your side. Half (Actually the full of one of the apps) my code for the apps I sold are with advice/sample/snippets/pointers from you, among other senior members on the Board
Old, maybe but useful and effective nevertheless
Thanx a lot
whohoooo!
if it wasn't for the arthritis and my bones being so old and brittle I'd do one of my old famous viking-cheerleader acts on the vbf coffee table! (its over there in the corner..the table...)
-
Sep 20th, 2002, 11:42 AM
#14
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|