need example of how to get assembly info

  • Thread starter Thread starter Jon Paal
  • Start date Start date
J

Jon Paal

Trying to get assembly and hard drive info

any working examples in vb available ?

I couldn;t find any examples for assembly info.
I tried this for hd info but no success.


Imports System.Management
....
Public Shared Function Volume(ByVal strDriveLetter As String) As String
If strDriveLetter = "" Or strDriveLetter Is Nothing Then
strDriveLetter = "C"
End If
Dim disk As New ManagementObject("win32_logicaldisk.deviceid=""" + strDriveLetter + ":""")
disk.Get()
Return disk("VolumeSerialNumber").ToString()
End Function 'GetVolumeSerial


error messsage is :

Compiler Error Message: BC30002: Type 'System.Management.ManagementObjectCollection' is not defined.
 
as it turns out the "ManagementObject" is not available to asp.net 2.0 on a xp machine .....


must use <DllImport("kernel32.dll")>
 
I'm running ASP.NET 2.0 on WinXP SP2 and running your function in my
test web page yields a serial number of 4803C726 on my c drive.
But hey, if using unmanaged code works for you...

Imports System.Management

Partial Class SystemManagement
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim lbl As New Label
lbl.Text = Volume(Nothing)
Panel1.Controls.Add(lbl)
End Sub

Public Shared Function Volume(ByVal strDriveLetter As String) As
String
If strDriveLetter = "" Or strDriveLetter Is Nothing Then
strDriveLetter = "C"
End If
Dim disk As New
ManagementObject("win32_logicaldisk.deviceid=""" + strDriveLetter +
":""")
disk.Get()
Return disk("VolumeSerialNumber").ToString()
End Function 'GetVolumeSerial
End Class
 
Back
Top