Bonjour,

Voila j'aimerai récupérer l'espace disque restant et total de disques dur en local et m'envoyer ces informations par mail deux fois par jour(tache planifiées).Le hic que j'ai c'est que j'ai été habitué a coder en visual studio 2003 et en vb6 (pendant mes études donc ca remonte) et donc mes notions de vb sont un peu a revoir car en VB6 il m'aurait fallu de créer une drivelistbox et après j'aurais su me débrouiller, mais là le controle drivelistbox n'esite pas sous visual basic express 2008.

Quelqu'un peut-il m'aider ? au moins pour récuperer les informations de l'ensemble de mes disques dur.

Le but final de se serveur c'est pour assurer une surveillance d'un serveur avec des bases windev

Voici mon code : et je vous met ce qui passe pas en rouge :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Public Class Form1
    Private Declare Function GetDiskFreeSpaceEx _
    Lib "kernel32" Alias "GetDiskFreeSpaceExA" _
    ( _
    ByVal lpDirectoryName As String, _
    ByVal lpFreeBytesAvailableToCaller As Decimal, _
    ByVal lpTotalNumberOfBytes As Decimal, _
    ByVal lpTotalNumberOfFreeBytes As Decimal _
    ) As Long


    Private Sub Form_Load()
        Dim fso As FileSystemObject
        Dim Drv As Drive, DrvName As String
        Dim d As Drive
        Dim dc As Drives
        Dim st As String
        Dim TotalBytes, FreeBytes As Decimal
        Dim Espace_Libre As String
        Dim Espace_Total As String
        Dim Pourcentage_Libre As Long

        fso = CreateObject("Scripting.FileSystemObject")
        dc = fso.Drives

        For Each d In dc

            Drv = fso.GetDrive(Mid(d, 1, 2))

            If Drv.DriveType = Remote Then

                DrvName = Drv.Path & "\"

                st = DrvName & " " & Drv.ShareName

                Pourcentage_Libre = 0
                Espace_Libre = ""
                Espace_Total = ""

                If Drv.IsReady Then

                    GetDiskFreeSpaceEx(CStr(Drv) & "\", 0, TotalBytes, FreeBytes)

                    Pourcentage_Libre = Int(FreeBytes * 10000 / (TotalBytes * 10000) * 100)

                    If FreeBytes * 10000 > 1024 ^ 3 Then
                        Espace_Libre = FormatNumber((FreeBytes * 10000 / 1024 ^ 3), -1) & " Go"
                    Else
                        If FreeBytes * 10000 > 1024 ^ 2 Then
                            Espace_Libre = FormatNumber((FreeBytes * 10000 / 1024 ^ 2), -1) & " Mo"
                        Else
                            If FreeBytes * 10000 > 1024 Then
                                Espace_Libre = FormatNumber((FreeBytes * 10000 / 1024), -1) & " Ko"
                            End If
                        End If
                    End If

                    If TotalBytes * 10000 > 1024 ^ 3 Then
                        Espace_Total = FormatNumber((TotalBytes * 10000 / 1024 ^ 3), -1) & " Go"
                    Else
                        If TotalBytes * 10000 > 1024 ^ 2 Then
                            Espace_Total = FormatNumber((TotalBytes * 10000 / 1024 ^ 2), -1) & " Mo"
                        Else
                            If TotalBytes * 10000 > 1024 Then
                                Espace_Total = FormatNumber((TotalBytes * 10000 / 1024), -1) & " Ko"
                            End If
                        End If
                    End If
                End If

                If Pourcentage_Libre <> 0 Then
                    st = st & " - Libre " & Espace_Libre & " (" & Pourcentage_Libre & "%)"
                    st = st & " - Total " & Espace_Total
                End If

            End If

        Next

        MsgBox(st)

        fso = Nothing

    End Sub

End Class