rui_fernandes Posted April 29, 2008 at 02:26 PM Report Share #182304 Posted April 29, 2008 at 02:26 PM 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 at 02:41 PM Report Share #182312 Posted April 29, 2008 at 02:41 PM 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 at 02:47 PM Author Report Share #182317 Posted April 29, 2008 at 02:47 PM 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 at 03:13 PM Report Share #182326 Posted April 29, 2008 at 03:13 PM 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 at 04:07 PM Author Report Share #182346 Posted April 29, 2008 at 04:07 PM 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 at 04:17 PM Report Share #182347 Posted April 29, 2008 at 04:17 PM 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 at 04:32 PM Author Report Share #182355 Posted April 29, 2008 at 04:32 PM 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 at 04:39 PM Author Report Share #182360 Posted April 29, 2008 at 04:39 PM 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 at 11:12 AM Report Share #183277 Posted May 4, 2008 at 11:12 AM 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 at 11:15 AM Report Share #183278 Posted May 4, 2008 at 11:15 AM aparece-me isto: ? Onde ? Link to comment Share on other sites More sharing options...
Ivo Pereira Posted May 4, 2008 at 11:33 AM Report Share #183281 Posted May 4, 2008 at 11:33 AM no visual basic, quando vou tentar fazer o debugging... Link to comment Share on other sites More sharing options...
jpaulino Posted May 4, 2008 at 12:00 PM Report Share #183282 Posted May 4, 2008 at 12:00 PM 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 at 12:47 PM Report Share #183284 Posted May 4, 2008 at 12:47 PM Dim info As DriveInfo = CType(drives(i), DriveInfo) aqui Link to comment Share on other sites More sharing options...
jpaulino Posted May 4, 2008 at 10:02 PM Report Share #183343 Posted May 4, 2008 at 10:02 PM 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 at 08:53 AM Author Report Share #183381 Posted May 5, 2008 at 08:53 AM ya funciona... Rui Fernandes Link to comment Share on other sites More sharing options...
Ivo Pereira Posted May 5, 2008 at 06:06 PM Report Share #183450 Posted May 5, 2008 at 06:06 PM 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 at 08:30 PM Report Share #183483 Posted May 5, 2008 at 08:30 PM 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 at 02:50 PM Author Report Share #183797 Posted May 7, 2008 at 02:50 PM 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 at 02:53 PM Author Report Share #183800 Posted May 7, 2008 at 02:53 PM 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 at 02:57 PM Author Report Share #183801 Posted May 7, 2008 at 02:57 PM 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