Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - caratteristiche del BIOS
Forum - C# / VB.NET - caratteristiche del BIOS

Avatar
maximilian (Normal User)
Newbie


Messaggi: 9
Iscritto: 30/10/2007

Segnala al moderatore
Postato alle 14:41
Sabato, 26/01/2008
Questo topic è stato chiuso dal moderatore

Salve, io cercavo aiuto per realizzare un programma in visual basic 2005 che mi permettesse di visualizzare le caratteristiche del BIOS.
Avevo postato questa discussione in altra sezione (quella di visual basic) e mi hanno detto che questa è quella giusta.

Mi hanno postato questo codice:

Option Explicit

Private Namespace As SWbemServices
Private Sub CaratteristicheBios()
On Error Resume Next

Dim SelectedItem As String
Dim Value As Variant
Dim Bios As SWbemObject
Dim tmpInt As Integer

'Clear current
List2.Clear

Me.MousePointer = vbHourglass

SelectedItem = List1.List(List1.ListIndex)
Set Bios = Namespace.Get(SelectedItem)

'Recupera le informazioni sul Bios.
With List2
' Value = Bios.BuildNumber
' .AddItem "Numero di build: " & CStr(Value)

Value = Bios.Caption
.AddItem "Nome: " & CStr(Value)

Value = Bios.CodeSet
.AddItem "Code Set: " & CStr(Value)

Value = Bios.CurrentLanguage
.AddItem "Linguaggio corrente: " & CStr(Value)

Value = Bios.Description
.AddItem "Descrizione: " & CStr(Value)

Value = Bios.IdentificationCode
.AddItem "Codice identificativo: " & CStr(Value)

' Value = Bios.InstallableLanguages
' .AddItem "Linguaggi installabili: " & CStr(Value)

Value = Bios.InstallDate
.AddItem "Data di installazione: " & CStr(Value)

Value = Bios.LanguageEdition
.AddItem "Linguaggio dell'edizione: " & CStr(Value)

Value = Bios.Manufacturer
.AddItem "Produttore: " & CStr(Value)

Value = Bios.Name
.AddItem "Nome: " & CStr(Value)

' Value = Bios.OtherTargetOS
' .AddItem "Altri SO: " & CStr(Value)

Value = Bios.PrimaryBIOS
.AddItem "BIOS primario: " & CStr(Value)

Value = Bios.ReleaseDate
.AddItem "Data ultimo aggiornamento: " & CStr(Value)

Value = Bios.SerialNumber
.AddItem "Numero di serie: " & CStr(Value)

Value = Bios.SMBIOSBIOSVersion
.AddItem "Versione BIOS: " & CStr(Value)

' Value = Bios.SMBIOSMajorVersion
' .AddItem "SMBIOS Major Version: " & CStr(Value)
'
' Value = Bios.SMBIOSMinorVersion
' .AddItem "SMBIOS Minor Version: " & CStr(Value)
'
' Value = Bios.SMBIOSPresent
' .AddItem "SMBIOS Presente: "& CStr(Value)

Value = Bios.SoftwareElementID
.AddItem "Software Element ID: " & CStr(Value)

' Value = Bios.SoftwareElementState
' .AddItem Left("Software Element State" & Space(35), 35)
' Select Case Value
' Case 1: .List(20) = .List(20) & "Deployable"
' Case 2: .List(20) = .List(20) & "Installable"
' Case 3: .List(20) = .List(20) & "Executable"
' Case 4: .List(20) = .List(20) & "Running"
' End Select

Value = Bios.Status
.AddItem "Stato: " & CStr(Value)

' Value = Bios.TargetOperatingSystem
' .AddItem "Sistema operativo: " & CStr(Value)

Value = Bios.Version
.AddItem "Versione: " & CStr(Value)
End With

'Recupera le caratteristiche del Bios.
With List3
Value = Bios.BiosCharacteristics
For tmpInt = 0 To 49
Select Case Value(tmpInt)
Case 0: .AddItem "Riservato"
Case 1: .AddItem "Riservato"
Case 2: .AddItem "Sconosciuto"
Case 3: .AddItem "Caratteristiche del BIOS non supportate"
Case 4: .AddItem "ISA supportato"
Case 5: .AddItem "MCA supportato"
Case 6: .AddItem "EISA supportato"
Case 7: .AddItem "PCI supportato"
Case 8: .AddItem "PC Card (PCMCIA) supportato"
Case 9: .AddItem "Plug and Play supportato"
Case 10: .AddItem "APM supportato"
Case 11: .AddItem "BIOS aggiornabile"
Case 12: .AddItem "BIOS shadowing consentito"
Case 13: .AddItem "VL-VESA supportato"
Case 14: .AddItem "Supporto ESCD disponibile"
Case 15: .AddItem "Boot da CD supportato"
Case 16: .AddItem "Avvio selettivo supportato"
Case 17: .AddItem "BIOS ROM is socketed"
Case 18: .AddItem "Boot da PC Card (PCMCIA) supportato"
Case 19: .AddItem "Specifiche EDD (Enhanced Disk Drive) supportate"
Case 20: .AddItem "Int 13h - Japanese Floppy for NEC 9800 1.2mb (3.5, 1k Bytes/Sector, 360 RPM) supportato"
Case 21: .AddItem "Int 13h - Japanese Floppy for Toshiba 1.2mb (3.5, 360 RPM) supportato"
Case 22: .AddItem "Int 13h - 5.25 / 360 KB Floppy Services supportati"
Case 23: .AddItem "Int 13h - 5.25 /1.2MB Floppy Services supportati"
Case 24: .AddItem "Int 13h - 3.5 / 720 KB Floppy Services supportati"
Case 25: .AddItem "Int 13h - 3.5 / 2.88 MB Floppy Services supportati"
Case 26: .AddItem "Int 5h, Print Screen Service supportato"
Case 27: .AddItem "Int 9h, 8042 Keyboard services supportato"
Case 28: .AddItem "Int 14h, Serial Services supportato"
Case 29: .AddItem "Int 17h, printer services supportato"
Case 30: .AddItem "Int 10h, CGA/Mono Video Services supportati"
Case 31: .AddItem "NEC PC-98"
Case 32: .AddItem "ACPI supportato"
Case 33: .AddItem "USB supportato"
Case 34: .AddItem "AGP supportato"
Case 35: .AddItem "Boot da I2O supportato"
Case 36: .AddItem "Boot da LS-120 supportato"
Case 37: .AddItem "Boot da ATAPI ZIP Drive supportato"
Case 38: .AddItem "Boot da Firewire supportato"
Case 39: .AddItem "Smart Battery supportata"
Case Else: Exit For
End Select
Next tmpInt
End With

Set Bios = Nothing
Me.MousePointer = vbNormal

End Sub

Private Sub ElencoBios()
'On Error Resume Next

Dim Bios As SWbemObject
Dim BiosSet As SWbemObjectSet

List1.Clear
Me.MousePointer = vbHourglass

Set BiosSet = Namespace.InstancesOf("Win32_BIOS")

For Each Bios In BiosSet
List1.AddItem Bios.Path_.RelPath
Next

Set Bios = Nothing
Set BiosSet = Nothing
Me.MousePointer = vbNormal

End Sub
Private Sub Form_Load()
Set Namespace = GetObject("winmgmts:")
ElencoBios
End Sub

Private Sub List1_Click()
List1.ToolTipText = List1.Text
'Visualizza la caratteristiche del BIOS selezionato.
CaratteristicheBios
End Sub


Io ho creato un form con all'interno una listbox di nome List2 per visualizzare i risultati, però mi da i seguenti 2 errori:

Error 1 Specifiers and attributes are not valid on 'Namespace' statements. C:\Documents and Settings\massimiliano1\Impostazioni locali\Dati applicazioni\Temporary Projects\WindowsApplication1\Form1.vb 3 1 WindowsApplication1


Error 2 'Namespace' statement must end with a matching 'End Namespace'. C:\Documents and Settings\massimiliano1\Impostazioni locali\Dati applicazioni\Temporary Projects\WindowsApplication1\Form1.vb 3 9 WindowsApplication1

Qualcuno mi può aiutare? GRAZIE 1000!!!
:k::k::k::k::k:

PM
Avatar
giovannibart91 (Member)
Pro


Messaggi: 64
Iscritto: 30/05/2008

Segnala al moderatore
Postato alle 15:21
Domenica, 27/01/2008
Ho semplicemente tolto il namespace, quasi inutile, e cambiato un pò di cosettine (es. List1.Clear() -> List1.Clear...)

Però a me non funziona perchè non mi riconosce il tipo "SWbemObject"... dovrebbe essere una libreria a parte che hai tu? :-?

P.S: strano che ti abbiano spostato in questa sezione... qui si parla di .NET ma il tuo codice è VB6!... :-|

vabbè... e buona fortuna per il tuo programma... dalla difficoltà che hai incontrato è evidente che sei ai primi approcci col vb6 e con la programmazione in generale; un consiglio: se vuoi imparare più velocemente e in modo mooolto più fluido passa al VB.NET... è un linguaggio più alto del vb6 (non arriva facilmente a certe parti di memoria e non agisce a livello molto basso), ma è fatto apposta per chi vuole essere aiutato a imparare... ;)

credo non aver frainteso il tuo problema.., magari sei espertissimo nella programmazione (e io farei una grossolana gaffe :D :D) ma per il resto spero di averti aiutato. Ciaaaooo!!! 8-)

PM
Avatar
Il Totem (Admin)
Guru^2


Messaggi: 3635
Iscritto: 24/01/2006

Segnala al moderatore
Postato alle 16:47
Lunedì, 28/01/2008
Namespace non può essere tolto perchè è il nome della variabile: in questo caso è un nome equivoco poichè genera confusione con la keyword Namespace propria dal vb.net. Per risolvere basta metterlo tra parentesi quadre, risolvendo entrambi i tuoi errori.

Ad ogni modo il codice che ti hanno postato (e per cui tu non hai usato il tag Code, come ripeto continuamente) è per vb6 e questo è abbastanza ovvio dato che la sezione in cui avevi postato era quella sul Visual Basic classico XD. Ora dovresti apportare alcune modifiche. Infatti tu hai specificato all'inizio che vuoi un programma in vb2005. Quindi, giovannibart91, hai frainteso, poiché lui sta effettivamente cercando un codice in .net.
Dato che gli unici errori riscontrati sono quei due, forse alcuni statements sono ancora accettati anche se obsoleti, ma se non ricordo male, visual studio (e anche la versione express) offre un tool per convertire automaticamente da VB6: nel menù Tools (Strumenti), seleziona "Upgrade Visual Basic 6 Code..." e inserisci il codice nella textbox, quindi clicca Upgrade per ottenere il nuovo risultato.

PM
Avatar
giovannibart91 (Member)
Pro


Messaggi: 64
Iscritto: 30/05/2008

Segnala al moderatore
Postato alle 16:57
Lunedì, 28/01/2008
Ah, ok, scusa...avevo capito male... ^^"

Comunque sì, come ha detto Totem c'è un tool apposta proprio lì, se poi non te lo aggiorna proprio perfettamente te lo modifichi come ti serve...

PM