CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2000
    Location
    Germany, Franken
    Posts
    257

    Creating Enviromentvariable

    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


  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Creating Enviromentvariable

    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





  3. #3

    Re: Creating Enviromentvariable

    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/im...ertaplanet.gif'>
    </center>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured