Click to See Complete Forum and Search --> : Creating Enviromentvariable


Akademos
August 30th, 2001, 07:05 AM
Hi,
i have the problem to create some enviromentvariable int NT within my prog but i don't know how to do that. Does anyone knows the API-Function or ways how i can do that?

thanks

akademos

DSJ
August 30th, 2001, 08:14 AM
Try This:


option Explicit
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

private Sub Form_Load()
Dim strBuffer as string
strBuffer = Space(20)
SetEnvironmentVariable "Somevar", "Somevalue"
GetEnvironmentVariable "Somevar", strBuffer, 20
MsgBox strBuffer
End Sub

berta
August 30th, 2001, 08:18 AM
try with this code..
I don't test it....



'declaration
public function SetEnvironmentVariable lib "kernel32.dll" (byval lpName as string,byval lpValue as string) as boolean

or

public function SetEnvironmentVariable lib "kernel32.dll" (byval lpName as string,byval lpValue as string) as integer


'sample of call
dim b as boolean 'or integer
b = SetEnvironmentVariable ("Path","mypath")





hi,brt




<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/images/bertaplanet.gif'>
</center>