Je souhaite créer une variable d'environement user (persistente) avec un
programme VB. J'ai vu que la méthode getEnvironmentVariable permettait de
récupérer la valeur des var. d'env., mais existe-t-il une méthode permettant
de créer ou de modifier des variables ?
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
B.Huck
Bon, j'ai trouvé moi-même la réponse, alors si cela peut servir :
Imports System
Public Class Form1
Protected Shared MyTestVariable = "TESTVAR"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Environment.SetEnvironmentVariable(MyTestVariable, "C:toto", EnvironmentVariableTarget.User)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End Sub End Class
Bon, j'ai trouvé moi-même la réponse, alors si cela peut servir :
Imports System
Public Class Form1
Protected Shared MyTestVariable = "TESTVAR"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Environment.SetEnvironmentVariable(MyTestVariable, "C:toto",
EnvironmentVariableTarget.User)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Bon, j'ai trouvé moi-même la réponse, alors si cela peut servir :
Imports System
Public Class Form1
Protected Shared MyTestVariable = "TESTVAR"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Environment.SetEnvironmentVariable(MyTestVariable, "C:toto", EnvironmentVariableTarget.User)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End Sub End Class
X
Private Declare Function SetEnvironmentVariable Lib "kernel32" Alias _ "SetEnvironmentVariableA" (ByVal lpName As String, _ ByVal lpValue As String) As Long
Private Declare Function GetEnvironmentVariable Lib "kernel32" Alias _ "GetEnvironmentVariableA" (ByVal lpName As String, _ ByVal lpBuffer As String, ByVal nSize As Long) As Long
Dim var_recup As String SetEnvironmentVariable "nom_vriable", "contenu_variable" ' stock GetEnvironmentVariable "nom_vriable", var_recup, taille ' destock SetEnvironmentVariable "nom_variable", "" ' supprime
-- Site logiciels http://irolog.free.fr Mail http://irolog.free.fr/ecrire/index.htm Site perso http://irolog.free.fr/joe/index.htm Principe d'utilisation des news Groups http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm ------------------------------------------------------------------------------------ "B.Huck" a écrit dans le message de news:
Bonjour à tous,
Je souhaite créer une variable d'environement user (persistente) avec un programme VB. J'ai vu que la méthode getEnvironmentVariable permettait de récupérer la valeur des var. d'env., mais existe-t-il une méthode permettant de créer ou de modifier des variables ?
Merci de votre aide.
Private Declare Function SetEnvironmentVariable Lib "kernel32" Alias _
"SetEnvironmentVariableA" (ByVal lpName As String, _
ByVal lpValue As String) As Long
Private Declare Function GetEnvironmentVariable Lib "kernel32" Alias _
"GetEnvironmentVariableA" (ByVal lpName As String, _
ByVal lpBuffer As String, ByVal nSize As Long) As Long
Dim var_recup As String
SetEnvironmentVariable "nom_vriable", "contenu_variable" ' stock
GetEnvironmentVariable "nom_vriable", var_recup, taille ' destock
SetEnvironmentVariable "nom_variable", "" ' supprime
--
Site logiciels
http://irolog.free.fr
Mail
http://irolog.free.fr/ecrire/index.htm
Site perso
http://irolog.free.fr/joe/index.htm
Principe d'utilisation des news Groups
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
------------------------------------------------------------------------------------
"B.Huck" <BHuck@discussions.microsoft.com> a écrit dans le message de news:
A9C215A7-D05F-44CE-A7E4-5D0EE5551EFD@microsoft.com...
Bonjour à tous,
Je souhaite créer une variable d'environement user (persistente) avec un
programme VB. J'ai vu que la méthode getEnvironmentVariable permettait de
récupérer la valeur des var. d'env., mais existe-t-il une méthode
permettant
de créer ou de modifier des variables ?
Private Declare Function SetEnvironmentVariable Lib "kernel32" Alias _ "SetEnvironmentVariableA" (ByVal lpName As String, _ ByVal lpValue As String) As Long
Private Declare Function GetEnvironmentVariable Lib "kernel32" Alias _ "GetEnvironmentVariableA" (ByVal lpName As String, _ ByVal lpBuffer As String, ByVal nSize As Long) As Long
Dim var_recup As String SetEnvironmentVariable "nom_vriable", "contenu_variable" ' stock GetEnvironmentVariable "nom_vriable", var_recup, taille ' destock SetEnvironmentVariable "nom_variable", "" ' supprime
-- Site logiciels http://irolog.free.fr Mail http://irolog.free.fr/ecrire/index.htm Site perso http://irolog.free.fr/joe/index.htm Principe d'utilisation des news Groups http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm ------------------------------------------------------------------------------------ "B.Huck" a écrit dans le message de news:
Bonjour à tous,
Je souhaite créer une variable d'environement user (persistente) avec un programme VB. J'ai vu que la méthode getEnvironmentVariable permettait de récupérer la valeur des var. d'env., mais existe-t-il une méthode permettant de créer ou de modifier des variables ?