drive number from drive letter

getting drive number from known drive letter

Page 1 of 1

7 Replies - 7296 Views - Last Post: 15 September 2007 - 03:13 AM Rate Topic: -----

#1 linuxbox  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-January 07

drive number from drive letter

Post icon  Posted 26 January 2007 - 01:58 PM

hello, what i'm needing to figure out is how to determine the actual drive number like 0, 1, 2 etc etc if i know the drive letter like c, d, or e. is this possible? i have code to get the drive serial knowing the drive number but first i need to have my application figure out which drive number it's installed on!!
thanks!
Is This A Good Question/Topic? 0
  • +

Replies To: drive number from drive letter

#2 m2s87  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: drive number from drive letter

Posted 26 January 2007 - 02:33 PM

View Postlinuxbox, on 26 Jan, 2007 - 01:58 PM, said:

hello, what i'm needing to figure out is how to determine the actual drive number like 0, 1, 2 etc etc if i know the drive letter like c, d, or e. is this possible? i have code to get the drive serial knowing the drive number but first i need to have my application figure out which drive number it's installed on!!
thanks!

And my I ask why does your program need to know that? And might you add what basic are you using.
Was This Post Helpful? 0
  • +
  • -

#3 m2s87  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: drive number from drive letter

Posted 26 January 2007 - 02:46 PM

In VB.net you can use:
		Dim i As Integer = 1
		Dim ImOnDrive As String = "C:\"

		For Each x As System.IO.DriveInfo In My.Computer.FileSystem.Drives
			If ImOnDrive = x.ToString Then MsgBox("I'm on drive: " & i) : Exit For Else i += 1
		Next x


Hope it helped :D
Was This Post Helpful? 0
  • +
  • -

#4 linuxbox  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-January 07

Re: drive number from drive letter

Posted 26 January 2007 - 03:00 PM

View Postm2s87, on 26 Jan, 2007 - 02:33 PM, said:

View Postlinuxbox, on 26 Jan, 2007 - 01:58 PM, said:

hello, what i'm needing to figure out is how to determine the actual drive number like 0, 1, 2 etc etc if i know the drive letter like c, d, or e. is this possible? i have code to get the drive serial knowing the drive number but first i need to have my application figure out which drive number it's installed on!!
thanks!

And my I ask why does your program need to know that? And might you add what basic are you using.

okay, visual basic 6..
the reason is due to the fact i'm letting a local office use a database program for free but i want to limit it to the hard drive it's currently installed on. if i can determine the disk number from the drive letter it's installed on, then i can get the real physical drive serial number, encode it in registry...decode it at runtime and make sure they don't spread it across their network...that's why......
Was This Post Helpful? 0
  • +
  • -

#5 linuxbox  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-January 07

Re: drive number from drive letter

Posted 26 January 2007 - 03:06 PM

m2s87:
have anything like that which would work for
vb6?
Was This Post Helpful? 0
  • +
  • -

#6 m2s87  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: drive number from drive letter

Posted 26 January 2007 - 03:32 PM

View Postlinuxbox, on 26 Jan, 2007 - 03:06 PM, said:

m2s87:
have anything like that which would work for
vb6?

You can use this snippet, it does exactly what you want.

Hope it helped :D
Was This Post Helpful? 0
  • +
  • -

#7 linuxbox  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-January 07

Re: drive number from drive letter

Posted 26 January 2007 - 03:38 PM

View Postm2s87, on 26 Jan, 2007 - 03:32 PM, said:

View Postlinuxbox, on 26 Jan, 2007 - 03:06 PM, said:

m2s87:
have anything like that which would work for
vb6?

You can use this snippet, it does exactly what you want.

Hope it helped :D


hehe...ACTUALLY it won't because that's the volumeserial. i'm against that!! : ) too easily modified in windows. my code gets the actual physical serial number of the drive as presented on the label on the outside of the drive! but i have to tell my code the drive number (0, 1, 2 etc etc) so it can retrieve the serial!!!
Was This Post Helpful? 0
  • +
  • -

#8 Mandela7044  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-September 07

Re: drive number from drive letter

Posted 15 September 2007 - 03:13 AM

any progress in resolving the drive number ("Drive 0", "Drive 1" or "Datenträger 0", "Datenträger 1") by an driveletter like "C:" "D:"?

i also would neet a solution (VB 6) . thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1