(已经解决)敬请各位高手解决vb.net(vs2010)如何使用现成的代码问题。谢谢。
以下代码是打开(vs2010)→新建项目→双击新建按钮:Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class
以下代码是网上的:(问题:如何把以下的代码放入以上的代码中使用?谢谢。)
Imports System.Management
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim disk As ManagementBaseObject , strResult As String
Dim diskClass = New ManagementClass("Win32_LogicalDisk") , disks As ManagementObjectCollection
disks = diskClass.GetInstances()
For Each disk In disks
strResult = ""
strResult += "磁盘名称:" & disk("Name") & vbCrLf
strResult += "磁盘卷标:" & disk("VolumeName") & vbCrLf
MsgBox(strResult)
Next
End Sub
[此贴子已经被作者于2017-6-27 10:25编辑过]