|
-
Dec 21st, 2003, 11:40 PM
#1
Thread Starter
Fanatic Member
How to get Volume drive version thru VB.NET?
How to get Volume drive version thru VB.NET? .. please advise ..
TIA
Winanjaya
-
Dec 22nd, 2003, 12:12 AM
#2
Frenzied Member
Have you tried Environment.GetLogicalDrives()
VB Code:
Dim drives() As String = Environment.GetLogicalDrives()
For Each d As String In drives
MessageBox.Show(d)
Next
-
Dec 22nd, 2003, 01:35 AM
#3
Thread Starter
Fanatic Member
But I though your codes will return error ..
Regards
Winanjaya
-
Dec 22nd, 2003, 03:35 AM
#4
if you are using vs2002 , change this line ...
VB Code:
For Each d As String In drives
to this ...
VB Code:
Dim d As String
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]
-
Dec 22nd, 2003, 03:48 AM
#5
Thread Starter
Fanatic Member
But this is not answer my question, what I want is to get the serial no. for drive volume ? .. please advise
Thanks
Winanjaya
-
Dec 22nd, 2003, 04:24 AM
#6
looks like you want to add a reference to Windows.Management , then do this ...
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
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]
-
Dec 22nd, 2003, 04:32 AM
#7
Thread Starter
Fanatic Member
But this will work only on XP machine or 2003 .. I need to run on Win 98 or later machine .. any suggestion?
TIA
Winanjaya
-
Dec 22nd, 2003, 05:20 AM
#8
i built this purposly for you , hope it helps 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
~
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]
-
Dec 22nd, 2003, 08:57 AM
#9
Frenzied Member
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! 
-
Dec 22nd, 2003, 10:03 AM
#10
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|