Results 1 to 10 of 10

Thread: How to get Volume drive version thru VB.NET?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784

    How to get Volume drive version thru VB.NET?

    How to get Volume drive version thru VB.NET? .. please advise ..
    TIA

    Winanjaya

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Have you tried Environment.GetLogicalDrives()
    VB Code:
    1. Dim drives() As String = Environment.GetLogicalDrives()
    2.         For Each d As String In drives
    3.             MessageBox.Show(d)
    4.         Next

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784
    But I though your codes will return error ..


    Regards
    Winanjaya

  4. #4
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    if you are using vs2002 , change this line ...
    VB Code:
    1. For Each d As String In drives
    to this ...
    VB Code:
    1. Dim d As String
    2. For Each d In drives
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784
    But this is not answer my question, what I want is to get the serial no. for drive volume ? .. please advise

    Thanks

    Winanjaya

  6. #6
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    looks like you want to add a reference to Windows.Management , then do this ...
    VB Code:
    1. Dim objMan As New Management.ManagementClass("Win32_DiskDrive")
    2.         Dim objCol As Management.ManagementObjectCollection = objMan.GetInstances
    3.         Dim objItem As Management.ManagementObject
    4.         For Each objItem In objCol
    5.             Dim pi As Management.PropertyDataCollection = objItem.Properties
    6.             Dim p As Management.PropertyData
    7.             For Each p In pi
    8.                 Console.WriteLine(p.Name & " : " & Convert.ToString(p.Value))
    9.             Next
    10.         Next
    it'll return a mine of info.
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784
    But this will work only on XP machine or 2003 .. I need to run on Win 98 or later machine .. any suggestion?

    TIA

    Winanjaya

  8. #8
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    i built this purposly for you , hope it helps cuz it was a struggle to get right.
    VB Code:
    1. 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
    2.  
    3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    4.         Dim drives As String() = Environment.GetLogicalDrives
    5.         Dim drive As String
    6.         Dim strVolume As New System.Text.StringBuilder(256)
    7.         Dim strFileSys As New System.Text.StringBuilder(256)
    8.         Dim intSerial As Integer
    9.         For Each drive In drives
    10.             GetVolumeInformation(drive, strVolume, 256, intSerial, 0, 0, strFileSys, 256)
    11.             MessageBox.Show(drive & "'s serial number is: " & intSerial & " it's filesystem type is: " & strFileSys.ToString)
    12.         Next
    13.  
    14.     End Sub
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  9. #9
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    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!






  10. #10
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    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 ) , so any help i provide makes me feel like i can do something usefull
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width