How to get Volume drive version thru VB.NET? .. please advise ..
TIA
Winanjaya
Printable View
How to get Volume drive version thru VB.NET? .. please advise ..
TIA
Winanjaya
Have you tried Environment.GetLogicalDrives()
VB Code:
Dim drives() As String = Environment.GetLogicalDrives() For Each d As String In drives MessageBox.Show(d) Next
But I though your codes will return error ..
Regards
Winanjaya
if you are using vs2002 , change this line ...
to this ...VB Code:
For Each d As String In drives
VB Code:
Dim d As String For Each d In drives
But this is not answer my question, what I want is to get the serial no. for drive volume ? .. please advise
Thanks
Winanjaya
looks like you want to add a reference to Windows.Management , then do this ...
it'll return a mine of info.VB Code:
Dim objMan As New Management.ManagementClass("Win32_DiskDrive") Dim objCol As Management.ManagementObjectCollection = objMan.GetInstances Dim objItem As Management.ManagementObject For Each objItem In objCol Dim pi As Management.PropertyDataCollection = objItem.Properties Dim p As Management.PropertyData For Each p In pi Console.WriteLine(p.Name & " : " & Convert.ToString(p.Value)) Next Next
But this will work only on XP machine or 2003 .. I need to run on Win 98 or later machine .. any suggestion?
TIA
Winanjaya
i built this purposly for you , hope it helps :rolleyes: cuz it was a struggle to get right.
VB Code:
Private Declare Function GetVolumeInformation Lib "Kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As System.Text.StringBuilder, ByVal nVolumeNameSize As Integer, ByRef lpVolumeSerialNumber As Integer, ByRef lpMaximumComponentLength As Integer, ByRef lpFileSystemFlags As Integer, ByVal lpFileSystemNameBuffer As System.Text.StringBuilder, ByVal nFileSystemNameSize As Integer) As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim drives As String() = Environment.GetLogicalDrives Dim drive As String Dim strVolume As New System.Text.StringBuilder(256) Dim strFileSys As New System.Text.StringBuilder(256) Dim intSerial As Integer For Each drive In drives GetVolumeInformation(drive, strVolume, 256, intSerial, 0, 0, strFileSys, 256) MessageBox.Show(drive & "'s serial number is: " & intSerial & " it's filesystem type is: " & strFileSys.ToString) Next End Sub
I'm gonna set up a fund for dynamic_sysop for all the hard work he does around here!! You are an exceptional coder my friend. Cute kids too, by the way! :)
:wave:
thanks for the compliments thephantom :)
i had to finish work a couple of years ago due to severe health problems, so helping people on these boards / coding is my life ( second obviously to my family :D ) , so any help i provide makes me feel like i can do something usefull:)