need example of how to get assembly info

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.
 
J

Jon Paal

as it turns out the "ManagementObject" is not available to asp.net 2.0 on a xp machine .....


must use <DllImport("kernel32.dll")>
 
C

CaffieneRush

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top