Apua taas tarvitsen...
Miten saisin laitettua koneella käytettävissä olevat levyasemat listboxiin, myös kiinni kytketyjen muistitikkujen?
Kiitos jo etukäteen.
Jokke
Moro jokke568!
oheisesta (XP) purkka-esimerkistä saat ehkä jotain osviittaa...
'väännetty SharpDevelop 3.1 RC2:lla
Imports System
Imports System.Text
Imports System.Management
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports Scripting ' Interop.Scripting
'(COM-refernssi Microsoft Scripting Runtime)
Namespace FSO_DRIVE
 Public Partial Class MainForm
   Friend Structure DriveStruct
   	Dim name As String
   	Dim infoString As String
   	Dim type As integer
   	Dim typeConst As String
   	Dim typeDescription As String
   	Dim path As String
   	Dim isAvailable As Boolean
   	Dim checked As Boolean
   End Structure
   Private MyDrives() As FSO_DRIVE.MainForm.DriveStruct
    Public Sub New()
       Me.InitializeComponent()
    End Sub
    Sub MainFormLoad(sender As Object, e As EventArgs)
        Dim fso As New Scripting.FileSystemObject
   	ReDim MyDrives(fso.Drives.Count)
   	Dim i As Integer = -1
        For Each MyDrive As Scripting.IDrive In fso.Drive
           i += 1
           With MyDrive
              MyDrives(i).Name = .Path & " asema"
               MyDrives(i).Path = .Path
               MyDrives(i).typeConst = .DriveType.ToString
               MyDrives(i).isAvailable = .IsReady
               If i < 2 And .DriveType.ToString = "Removable" Then
                  MyDrives(i).TypeDescription = "floppy"
               ElseIf i > 1 And .DriveType.ToString = "Removable" Then
                  MyDrives(i).TypeDescription = "other than floppy"
               Else
                  MyDrives(i).TypeDescription = .DriveType.ToString
               End If
            End With
        Next
        fso = Nothing
        Dim searcher As Object = Nothing
        searcher = New ManagementObjectSearcher( _
        "root\CIMV2", _
        "SELECT * FROM Win32_DiskDrive")
        For Each DiskDrive As ManagementObject In searcher.Get()
           Dim mtype As String = _
           DiskDrive("MediaType").Replace(" ","")
           For j As Integer = 0 _
           To MyDrives.GetUpperBound(0)
              If mtype.IndexOf("mediaotherthan") > -1 _
              And MyDrives(j).typeDescription = "other than floppy" _
              And MyDrives(j).checked = False And _
              DiskDrive("Caption").IndexOf("USB") > -1 Then
                 MyDrives(j).checked = True
                 If DiskDrive("Status") = "OK" Then
                   MyDrives(j).isAvailable = True
                 Else
                   MyDrives(j).isAvailable = False
                 End If
                 MyDrives(j).typeDescription = "USBDrive"
              End if
           Next j
        Next DiskDrive
       searcher = New ManagementObjectSearcher( _
       "root\CIMV2", _
       "SELECT * FROM Win32_CDROMDrive")
       For Each CDROMDrive As ManagementObject In searcher.Get()
      	   If CDROMDrive("Caption").IndexOf("USB") > -1 Then
              For j As Integer = 0 To MyDrives.GetUpperBound(0)
                 If MyDrives(j).typeDescription = "CDRom" _
                    And MyDrives(j).Checked = False Then
                       MyDrives(j).checked = True
      		       MyDrives(j).isAvailable = False
      		       MyDrives(j).typeDescription = "USBDrive"
                   Exit For
                 End If
               Next
      	   ElseIf CDROMDrive("Caption").IndexOf("USB") = -1 Then
       	      For j As Integer = 0 To MyDrives.GetUpperBound(0)
      	         If MyDrives(j).typeDescription = "CDRom" _
      		     And MyDrives(j).checked = False Then
      		       MyDrives(j).checked = True
      		       If CDROMDrive("Status") = "OK" Then
      		         MyDrives(j).isAvailable = True
      		       Else
      		         MyDrives(j).isAvailable = False
      		       End If
                    Exit For
                 End If
      	      Next
      	   End If
       Next CDROMDrive
       searcher = Nothing
       For j As Integer = 0 To MyDrives.GetUpperBound(0)
          If MyDrives(j).isAvailable Then
            Me.listbox1.Items.Add( _
            MyDrives(j).Name & " | " & _
            MyDrives(j).typeDescription)
          End If
       Next
    End Sub
 End Class
End NamespaceSuuri kiitos taas Nea
En ole koskaan käyttänyt Namespace:a...
Minne namespace perustetaan...
Jokke
Moikka taas jokke568!
valaistusta Namespace-jutskiin...???
elikä tutki/testaa kommentoimalla pois nimitilat & viitaukset
PääFormi.vb:
'Juurinimitila (Root Namespace):
'NimitilaEsimerkkiProjekti = Projektin nimi
'(VB:n asettama oletus)
Imports System
Imports NimitilaEsimerkkiProjekti.NimitilaEsimerkki
Public Partial Class PääFormi
   Public Sub New()
      Me.InitializeComponent()
   End Sub
   Sub Button1Click(sender As Object, e As EventArgs)
      Static i As Integer
      Dim luokka As Object = Nothing
      Dim a As Object = Nothing
      Dim b As Object = Nothing
      If i > 1 Then
         i = 0
      End If
      Select Case i
         Case 0
            luokka = New nimitila1.Luokka1
            a = "loppu"
            b = "tili"
         Case 1
            luokka = New nimitila2.Luokka1
            a = 10
            b = 20
      End Select
      i += 1
      MsgBox(luokka.Funktio(a, b))
   End Sub
   Sub Button2Click(sender As Object, e As EventArgs)
      Dim frmSivuFormi As _
      New NimitilaEsimerkkiProjekti.SivuFormi
      frmSivuFormi.ShowDialog
      frmSivuFormi.Close
   End Sub
   Sub Button3Click(sender As Object, e As EventArgs)
      Dim frmSivuFormi As _
      New NimitilaEsimerkkiProjekti.SivuFormi2
      frmSivuFormi.ShowDialog
      frmSivuFormi.Close
   End Sub
   Sub Button4Click(sender As Object, e As EventArgs)
      Dim frmSivuFormi As _
      New NimitilaEsimerkkiProjekti.SivuFormi3
      frmSivuFormi.ShowDialog
      frmSivuFormi.Close
   End Sub
End Class
Namespace NimitilaEsimerkki.nimitila1
   Public Class Luokka1
      Public Shared Function Funktio _
      (a As System.String, _
      b As System.String) As System.String
         Return a & b
      End Function
   End Class
End Namespace
Namespace NimitilaEsimerkki.nimitila2
   Public Class Luokka1
      Public Function Funktio _
      (a As Integer, _
      b As Integer) As Integer
         Return a * b
      End Function
   End Class
   Namespace nimitila2_2
      Public Class Luokka1
         Public Function Funktio _
         (a As Object, _
         b As Object) As Object
            If TypeOf(a) IS System.String Then
               Return a & b
               Exit Function
            Else
               Try
                  Return a * b
                  Exit Function
               Catch
               End Try
            End If
            Return Nothing
         End Function
      End Class
   End Namespace
End NamespaceSivuFormi.vb:
Imports NimitilaEsimerkkiProjekti
Public Partial Class SivuFormi
   Public Sub New()
      Me.InitializeComponent()
   End Sub
   Sub Button1Click(sender As Object, e As EventArgs)
      Static i As Integer
      Dim luokka As Object = Nothing
      Dim a As Object = Nothing
      Dim b As Object = Nothing
      If i > 1 Then
         i = 0
      End If
      Select Case i
         Case 0
            luokka = _
            New NimitilaEsimerkki.nimitila1.Luokka1
            a = "appi"
            b = "ukot"
         Case 1
            luokka = _
            New  NimitilaEsimerkki.nimitila2.Luokka1
            a = 100
            b = 200
      End Select
      i += 1
      MsgBox(luokka.Funktio(a, b))
   End Sub
End ClassSivuFormi2.vb
Public Partial Class SivuFormi2
   Public Sub New()
      Me.InitializeComponent()
   End Sub
   Sub Button1Click(sender As Object, e As EventArgs)
      Static i As Integer
      Dim luokka As Object = Nothing
      Dim a As Object = Nothing
      Dim b As Object = Nothing
      If i > 1 Then
         i = 0
      End If
      Select Case i
         Case 0
            luokka = _
            New NimitilaEsimerkkiProjekti. _
            NimitilaEsimerkki.nimitila1.Luokka1
            a = "mini"
            b = "mekot"
         Case 1
            luokka = _
            New NimitilaEsimerkkiProjekti. _
            NimitilaEsimerkki.nimitila2.Luokka1
            a = 1000
            b = 2000
      End Select
      i += 1
      MsgBox(luokka.Funktio(a, b))
   End Sub
End ClassSivuFormi3.vb
Imports ntila1 = _
NimitilaEsimerkkiProjekti. _
NimitilaEsimerkki.nimitila1
Imports ntila2 = _
NimitilaEsimerkkiProjekti. _
NimitilaEsimerkki.nimitila2
Imports ntila3 = _
NimitilaEsimerkkiProjekti. _
NimitilaEsimerkki.nimitila2.nimitila2_2
Public Partial Class SivuFormi3
   Public Sub New()
      Me.InitializeComponent()
   End Sub
   Sub Button1Click(sender As Object, e As EventArgs)
      Static i As Integer
      Dim luokka As Object = Nothing
      Dim a As Object = Nothing
      Dim b As Object = Nothing
      If i > 1 Then
         i = 0
      End If
      Select Case i
         Case 0
            luokka = New ntila1.Luokka1
            a = "alku"
            b = "pääoma"
         Case 1
            luokka = New ntila2.Luokka1
            a = 1000
            b = 2000
      End Select
      i += 1
      MsgBox(luokka.Funktio(a, b))
   End Sub
   Sub Button2Click(sender As Object, e As EventArgs)
      Static i As Integer
      Dim luokka As Object = _
      New ntila3.Luokka1
      Dim a As Object = Nothing
      Dim b As Object = Nothing
      If i > 1 Then
      	i = 0
      End If
      Select Case i
      	Case 0
            a = "luokka"
            b = "retki"
      	Case 1
            a = 10.10
            b = 20.20
      End Select
      i += 1
      MsgBox(luokka.Funktio(a, b))
   End Sub
End ClassHei Nea
Kiitos esimerkistä, rupean nyt syventymään asiaan.
Kiitos!
Jokke
Aihe on jo aika vanha, joten et voi enää vastata siihen.