I need to get volume information from the hard disk. What can I do?
I am trying to implement a copy protection scheme for my programs and I need to determine the volume information of the hard disk on wich the program is installed. Is there a way to do it from VB 2005
To get the detailed information on the drives and volumes you can use the system management namespaces and use WMI to get what you need. For some examples of WMI Scripting that you could convert over have a look at the scripting centre on technet. Now I know that the scripts are in VB Script but they are easy to convert.
If you are thinking of this for copy protection, using the above classes will allow you to get more information out of the hardware then what you would using the standard classes.
i think if you get the Product ID - serial number of the installed windows operating system like the following:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(
My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("MICROSOFT").OpenSubKey("WINDOWS").OpenSubKey("CurrentVersion").GetValue("ProductID"))
End Sub
i've built this function for you so you can use it to retrieve the serial number of the hard disk. i think this will be helpful for you and will close the current thread:
this is how you to get Volume Serial Number :
first include the following in the declaration section:
Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As _
String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Integer, ByRef lpVolumeSerialNumber As _
Integer, ByVal lpMaximumComponentLength As Integer, ByVal lpFileSystemFlags As Integer, ByVal lpFileSystemNameBuffer As _
String, ByVal nFileSystemNameSize As Integer) As Integer
and then copy paste the following function:
Public
Function GetVolumeSerialNumber(Optional ByVal strDriveLetter As String = "C:\") As String
Use the GetVolumeSerialNumber function with the exact declaration as mentioned above to retreive the serial number in its original format i.e hexadecimal
Sincerely
mario aoun
I need to get volume information from the hard disk. What can I do?
I need to get volume information from the hard disk. What can I do?
Julian Kuiters
To get the detailed information on the drives and volumes you can use the system management namespaces and use WMI to get what you need. For some examples of WMI Scripting that you could convert over have a look at the scripting centre on technet. Now I know that the scripts are in VB Script but they are easy to convert.
If you are thinking of this for copy protection, using the above classes will allow you to get more information out of the hardware then what you would using the standard classes.
Spontrel
My.Computer.FileSystem.GetDriveInfo
but this might not be enough for your scheme.
Gerald Perry
Hi Amadeus,
i think if you get the Product ID - serial number of the installed windows operating system like the following:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickMsgBox(
My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("MICROSOFT").OpenSubKey("WINDOWS").OpenSubKey("CurrentVersion").GetValue("ProductID")) End Subgood luck
mario
Gavin RTE
Hi again Amadeus,
i've built this function for you so you can use it to retrieve the serial number of the hard disk. i think this will be helpful for you and will close the current thread:
this is how you to get Volume Serial Number :
first include the following in the declaration section:
Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As _
String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Integer, ByRef lpVolumeSerialNumber As _
Integer, ByVal lpMaximumComponentLength As Integer, ByVal lpFileSystemFlags As Integer, ByVal lpFileSystemNameBuffer As _
String, ByVal nFileSystemNameSize As Integer) As Integer
and then copy paste the following function:
Public
Function GetVolumeSerialNumber(Optional ByVal strDriveLetter As String = "C:\") As StringDim strVolName As String = Space(256)
Dim strFSName As String = Space(256)
Dim intLenMaxFile As Integer
Dim intLenVolName As Integer
Dim intLenFSName As Integer
Dim intFileSystemFlags As Integer
strVolName = Space(256)
strFSName = Space(256)
intLenVolName = 256
intLenFSName = 256
Dim ma As Long
Dim lngRetValue As Long
lngRetValue = GetVolumeInformation(strDriveLetter, strVolName, _
intLenVolName, ma, intLenMaxFile, intFileSystemFlags, strFSName, intLenFSName)
GetVolumeSerialNumber = CStr(Hex(ma))
End Function
Use the GetVolumeSerialNumber function with the exact declaration as mentioned above to retreive the serial number in its original format i.e hexadecimal
Sincerely
mario aoun