By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,139 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,139 IT Pros & Developers. It's quick & easy.

Getting disk volume

P: n/a
Hi,

I have used CreateObject("Scripting.FileSystemObject") to get the disk volume.
Is there any other way of get the disk volume other than using the FSO.

Thanks

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200801/1

Jan 10 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Benjamins via AccessMonster.com wrote:
I have used CreateObject("Scripting.FileSystemObject") to get the disk volume.
Is there any other way of get the disk volume other than using the FSO.
Yes, Windows provides an API for programming languages to interact with
the operating system.

The disk's volume name? or the disk's serial number?
http://www.freevbcode.com/ShowCode.Asp?ID=44

this next site uses the API declarations from the above link and returns
the serial number:

http://www.vb-helper.com/howto_volume_info.html

I haven't verified either - just did a quick Goggle search.

--
'--------------------------
' John Mishefske
' UtterAccess Editor
' Microsoft MVP 2007, 2008
'--------------------------
Jan 10 '08 #2

P: n/a
See:
http://vbnet.mvps.org/index.html?code/disk/index.html

The site contains lots of API calls that work with VB. You should be able to
grab the one you need.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Benjamins via AccessMonster.com" <u39077@uwewrote in message
news:7dfcc9c1e6545@uwe...
Hi,

I have used CreateObject("Scripting.FileSystemObject") to get the disk
volume.
Is there any other way of get the disk volume other than using the FSO.
Jan 10 '08 #3

P: n/a
"Benjamins via AccessMonster.com" <u39077@uwewrote in message
news:7dfcc9c1e6545@uwe...
Hi,

I have used CreateObject("Scripting.FileSystemObject") to get the disk
volume.
Is there any other way of get the disk volume other than using the FSO.

Thanks

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200801/1
You can retrieve this info from the windows API. Paste the following code
into a new module:

Private Declare Function GetVolumeInformation Lib "Kernel32" _
Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, _
ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, _
lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long) As Long

Public Function DriveSerial(DriveLetter As String) As String
Dim Serial As Long, dummy As String
dummy = String$(255, Chr$(0))
GetVolumeInformation DriveLetter & ":\", _
dummy, 255, Serial, 0, 0, dummy, 255
DriveSerial = CStr(Serial)
End Function

Then call like this:

Debug.Print DriveSerial("C")
Jan 10 '08 #4

P: n/a

Dir$("C:\",vbVolume)

Replace the "C:\" with whatever drive you like.

(Warning: Disk Volumes don't always have names......)
On Thu, 10 Jan 2008 06:31:16 GMT, "Benjamins via AccessMonster.com"
<u39077@uwewrote:
>Hi,

I have used CreateObject("Scripting.FileSystemObject") to get the disk volume.
Is there any other way of get the disk volume other than using the FSO.

Thanks
---
Please Post Any Replies To This Message Back To the Newsgroup.
There are "Lurkers" around who can benefit by our exchange!
Jan 10 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.