rui_fernandes Posted April 29, 2008 Report Share Posted April 29, 2008 boa tarde, andei a pesquisar no google mas nao encontrei mesmo nada fogo... o que eu quero saber era qual o numero de serie do meu disco rigido... e depois mais informacoes, mas o prioridade neste caso é o nº de serie, é possivel ??? Rui Fernandes. Rui Fernandes Link to comment Share on other sites More sharing options...
pedrotuga Posted April 29, 2008 Report Share Posted April 29, 2008 mmmm.... isto estar na secção de vb.net foi engano ou queres fazer isso a partir de VB.NET? Não me parece que seja possivel ober o número de série de um disco rígido que não seja ler o que está escrito nos autocolantes. Link to comment Share on other sites More sharing options...
rui_fernandes Posted April 29, 2008 Author Report Share Posted April 29, 2008 queria saber atravez de vb.net... nº de serie, ou um ID ou coisa do genero... se for diferente de disco para disco... Rui Fernandes Link to comment Share on other sites More sharing options...
jpaulino Posted April 29, 2008 Report Share Posted April 29, 2008 Experimenta este exemplo: http://addressof.com/articles/driveinfo.zip É em vb.net 2003 mas podes converter e usar sem problemas. Link to comment Share on other sites More sharing options...
rui_fernandes Posted April 29, 2008 Author Report Share Posted April 29, 2008 mas isso esta em console application certo ?? mas keria isso numa windows application, da para fazer na mesma ??? é que nao estou bem a ver a diferenca... o codigo é meio manhoso...lol... Rui Fernandes Link to comment Share on other sites More sharing options...
jpaulino Posted April 29, 2008 Report Share Posted April 29, 2008 Ok, toma lá a "papinha" já pronta 👍 Imports System.Management Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim drives As New ArrayList Dim query As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive") For Each wmiDrive As ManagementObject In query.Get() Dim info As New DriveInfo info.Model = wmiDrive("Model").ToString() info.Type = wmiDrive("InterfaceType").ToString() drives.Add(info) Next query = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") Dim i As Integer = 0 For Each wmiDrive As ManagementObject In query.Get() ' Get the hard drive from collection using index. Dim info As DriveInfo = CType(drives(i), DriveInfo) ' Get the hardware serial number. If wmiDrive("SerialNumber") Is Nothing Then info.SerialNumber = "None" Else info.SerialNumber = wmiDrive("SerialNumber").ToString() End If i += 1 Next ' Mostra a informação do disco For Each info As DriveInfo In drives Dim sBuilder As New System.Text.StringBuilder sBuilder.AppendLine("Model:" + info.Model) sBuilder.AppendLine("Type:" + info.Type) sBuilder.AppendLine("Serial No.:" + info.SerialNumber) MessageBox.Show(sBuilder.ToString) Next End Sub End Class Class DriveInfo Private _model As String Private _type As String Private _serialNumber As String Public Property Model() As String Get Return _model End Get Set(ByVal Value As String) _model = Value End Set End Property Public Property Type() As String Get Return _type End Get Set(ByVal Value As String) _type = Value End Set End Property Public Property SerialNumber() As String Get Return _serialNumber End Get Set(ByVal Value As String) _serialNumber = Value End Set End Property End Class Link to comment Share on other sites More sharing options...
rui_fernandes Posted April 29, 2008 Author Report Share Posted April 29, 2008 lol ja tinha feito isso, mas da um erro... copiei o codigo e tambem da... Type 'ManagementObjectSearcher' is not defined. Type 'ManagementObject' is not defined. Rui Fernandes Link to comment Share on other sites More sharing options...
rui_fernandes Posted April 29, 2008 Author Report Share Posted April 29, 2008 ja resolvi. Proriedades>references> e adicionei system.management obrigado. Rui Fernandes Link to comment Share on other sites More sharing options...
Ivo Pereira Posted May 4, 2008 Report Share Posted May 4, 2008 aparece-me isto: O índice estava fora do intervalo. Tem de ser não negativo e inferior ao tamanho da colecção. Nome do parâmetro: index ? Link to comment Share on other sites More sharing options...
jpaulino Posted May 4, 2008 Report Share Posted May 4, 2008 aparece-me isto: ? Onde ? Link to comment Share on other sites More sharing options...
Ivo Pereira Posted May 4, 2008 Report Share Posted May 4, 2008 no visual basic, quando vou tentar fazer o debugging... Link to comment Share on other sites More sharing options...
jpaulino Posted May 4, 2008 Report Share Posted May 4, 2008 no visual basic, quando vou tentar fazer o debugging... Até aí entendi. Mas em que linha/instrução ? Link to comment Share on other sites More sharing options...
Ivo Pereira Posted May 4, 2008 Report Share Posted May 4, 2008 Dim info As DriveInfo = CType(drives(i), DriveInfo) aqui Link to comment Share on other sites More sharing options...
jpaulino Posted May 4, 2008 Report Share Posted May 4, 2008 Mas chega a mostrar alguma drive ? É que comigo e a quem já mostrei este código funciona bem! Link to comment Share on other sites More sharing options...
rui_fernandes Posted May 5, 2008 Author Report Share Posted May 5, 2008 ya funciona... Rui Fernandes Link to comment Share on other sites More sharing options...
Ivo Pereira Posted May 5, 2008 Report Share Posted May 5, 2008 Mas chega a mostrar alguma drive ? É que comigo e a quem já mostrei este código funciona bem! Nada... chega àquela parte do código no Debug e pára, aparecendo o erro que especifiquei acima... Link to comment Share on other sites More sharing options...
jpaulino Posted May 5, 2008 Report Share Posted May 5, 2008 Que discos tens no pc ? Experimenta alterar para 1. Link to comment Share on other sites More sharing options...
rui_fernandes Posted May 7, 2008 Author Report Share Posted May 7, 2008 nao estas a utilizar VISTA DJ_BloodHunter ??? é que testei agora no vista, e da esse erro... :dontgetit: Rui Fernandes Link to comment Share on other sites More sharing options...
rui_fernandes Posted May 7, 2008 Author Report Share Posted May 7, 2008 testei meter 1 no index como disse o jpaulino e nao deu na mesma... OMG, solucoes??? sff ? Rui Fernandes Link to comment Share on other sites More sharing options...
rui_fernandes Posted May 7, 2008 Author Report Share Posted May 7, 2008 sera por ser SATA o disco ?? Rui Fernandes Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now