Récupérer la variable SystemDrive

Résolu
cs_Metaldark Messages postés 31 Date d'inscription vendredi 22 août 2003 Statut Membre Dernière intervention 26 juillet 2007 - 10 déc. 2004 à 20:27
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 - 18 déc. 2004 à 22:56
Salut ! ;)
Pouvez vous me dire comment récupérer la variable SystemDrive ?

Merci d'avance !

MeTaLdArK SpiRiT 8-)
[Site]

3 réponses

Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
18 déc. 2004 à 22:56
encore plus simple:

MsgBox Environ$("SystemDrive")

Daniel
3
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
10 déc. 2004 à 20:53
tu la trouveras dans l'Environment.

Option Explicit

Private Declare Function GetEnvironmentStrings Lib "kernel32" Alias "GetEnvironmentStringsA" () As Long
Private Declare Function FreeEnvironmentStrings Lib "kernel32" Alias "FreeEnvironmentStringsA" (ByVal lpsz As String) As Long
Private Declare Function Lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)

Private Sub Command1_Click()
    Dim LngRet  As Long
    Dim StrDest As String
    Dim LLen    As Long
    
    LngRet = GetEnvironmentStrings
    Do
        LLen = Lstrlen(LngRet)
        If LLen = 0 Then Exit Do
        StrDest = Space$(LLen)
        CopyMemory ByVal StrDest, ByVal LngRet, LLen
        MsgBox StrDest
        LngRet = LngRet + Lstrlen(LngRet) + 1
        Loop
    FreeEnvironmentStrings LngRet

End Sub


Daniel
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
10 déc. 2004 à 22:14
Prendre les 3 premiers caracteres sortis par GetSystemDirectory() serait surement + rapide.

ciao...
BruNews, MVP VC++
0
Rejoignez-nous