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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where do I come from????? 1

Status
Not open for further replies.

jgoodman00

Programmer
Jan 23, 2001
1,510
Hi there,
I have written an app which within it needs to run external apps. I have made these action by using teh Shell command. However, I want my program to run from a CD, & the other programs it relates to will also run from the same CDROM drive. Therefore, does anyone know how I can get my program to 'know' what drive it is running from, because at the moment I have had to make it run from a previously assigned drive letter. If this does not correspond to the drive the program is running from, it simply bombs out.

Thanks in advance
 
'Maybe ???

Detect The Type Of The Drive

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 1 CommandButton (named Command1) and 1 DriveListBox (named Drive1) to your form.
'Choose in the DriveListBox the drive you want to detect, and press the button.
'Insert this code to the module :

Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" _
(ByVal nDrive As String) As Long
Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" _
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

'Insert this code to your form:

Private Sub Command1_Click()
DriveType& = GetDriveType(Drive1.Drive)
Select Case DriveType
Case 1, 3: MsgBox "Hard Disk"
Case 2: MsgBox "Floppy Drive"
Case 4: MsgBox "Remote"
Case 5: MsgBox "CD Rom"
Case 6: MsgBox "RamDisk"
End Select
End Sub

Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX
Source CodeBook for the programmer
 
I am a little late but my suggestion would be...

Using the Path property of the App object, you will be able to determine the drive and full path of the location of the executable.

Now, a simple parsing function, such as left(App.path,1) will return the first character of path... which should be the drive letter.

Note: that if the path is returned as a \\server\path string, it could be a little more dificult.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top