IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB 6 et antérieur Discussion :

Variables d'environnement en VB6


Sujet :

VB 6 et antérieur

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Candidat au Club
    Inscrit en
    Janvier 2006
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Janvier 2006
    Messages : 2
    Par défaut Variables d'environnement en VB6
    Bonjour,
    Quelqu'un saurait-il s'il est possible de définir ou modifier une variable d'environnement en VB6
    Merci d'avance

  2. #2
    Membre Expert
    Avatar de zazaraignée
    Profil pro
    Étudiant
    Inscrit en
    Février 2004
    Messages
    3 174
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2004
    Messages : 3 174
    Par défaut
    salut

    Citation Envoyé par CD MSDN
    Environ Function


    Returns the String associated with an operating system environment variable.

    Syntax

    Environ({envstring | number})

    The Environ function syntax has thesenamed arguments:

    Part Description
    envstring Optional.String expression containing the name of an environment variable.
    number Optional.Numeric expression corresponding to the numeric order of the environment string in the environment-string table. The numberargument can be any numeric expression, but is rounded to a whole number before it is evaluated.


    Remarks

    If envstring can't be found in the environment-string table, a zero-length string ("") is returned. Otherwise, Environ returns the text assigned to the specified envstring; that is, the text following the equal sign (=) in the environment-string table for that environment variable.

    If you specify number, the string occupying that numeric position in the environment-string table is returned. In this case, Environ returns all of the text, including envstring. If there is no environment string in the specified position, Environ returns a zero-length string.

  3. #3
    Membre chevronné
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    290
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2005
    Messages : 290
    Par défaut
    Bonjour,
    Un exemple de MSDN.
    Cet exemple utilise la fonction Environ pour fournir le numéro d'entrée et la longueur de l'instruction PATH de la table des chaînes d'environnement.
    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
     
    Private Sub Command1_Click()
    Dim EnvString, Indx, Msg, PathLen   ' Déclare les variables.
    Indx = 1   ' Initialise l'index à 1.
    Do
       EnvString = Environ(Indx)   ' Extrait la variable
                                  ' d'environnement.
       If Left(EnvString, 5) = "PATH=" Then   ' Vérifie l'entrée PATH.
          PathLen = Len(Environ("PATH"))   ' Extrait la longueur.
          Msg = "Entrée PATH = " & Indx & " et longueur = " & PathLen
          Exit Do
       Else
          Indx = Indx + 1   ' Pas d'entrée PATH,
       End If   ' donc incrémente.
    Loop Until EnvString = ""
    If PathLen > 0 Then
       MsgBox Msg   ' Affiche le message.
    Else
       MsgBox " Il n'existe pas de variable d'environnement PATH."
    End If
    End Sub
    jpleroisse

  4. #4
    Candidat au Club
    Inscrit en
    Janvier 2006
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Janvier 2006
    Messages : 2
    Par défaut
    La fonction 'Environ' me permet seulement de lire une variable d'environnement déja définie. Je voulais savoir s'il était possible soit d'en définir une avec du code VB sinon d'en modifier une existante toujours avec du code VB (un peu comme la fonction C setenv).

Discussions similaires

  1. [langage] Création de variable d'environnements
    Par Smaugg dans le forum Langage
    Réponses: 20
    Dernier message: 26/04/2004, 09h32
  2. [BES] Création d'une variable d'environnement
    Par NGI80 dans le forum Autres
    Réponses: 2
    Dernier message: 17/10/2002, 07h31
  3. nom de fichier et variables d'environnement
    Par joebarthib dans le forum Langage
    Réponses: 2
    Dernier message: 18/07/2002, 15h21
  4. Réponses: 4
    Dernier message: 18/07/2002, 13h32

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo