🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #17542

Re: Get/SetEnvironmentVariable

#17542
From: Remy Lebeau (TeamB)
Date: Fri, 14 Mar 2003 04:59
39 lines
2187 bytes
"JD" <nospam@nospam.com> wrote in message
news:3e715b74$1@newsgroups.borland.com...

> I'm trying to track a bug and need confirmation that
> I'm using these API's correctly please:

Sorry, you're not.

>   GetEnvironmentVariable( "PATH", oldPath, MAXPATH );

You can't pass an AnsiString as a parameter directly.  The function expects
an actual buffer instead.  You can do one of the following instead:

    char buffer[MAX_PATH+1] = {0};
    GetEnvironmentVariable( "PATH", buffer, MAX_PATH );
    oldPath = buffer;

Or:

    AnsiString oldPath = AnsiString::StringOfChar(' ', MAX_PATH);
    GetEnvironmentVariable( "PATH", oldPath.c_str(), MAXPATH );

>   SetEnvironmentVariable( "PATH", newPath, newPath.Length() );

Same here.  You can't pass an AnsiString directly, you need an actual
buffer.  In this case, you can pass in the return value of the c_str()
method.

    SetEnvironmentVariable( "PATH", newPath.c_str(), newPath.Length() );

>   SetEnvironmentVariable( "PATH", oldPath, oldPath.Length() );

Same here as well:

    SetEnvironmentVariable( "PATH", oldPath.c_str(), oldPath.Length() );


Gambit
Technical Details
Message-ID: <3e715f9a$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!38.144.126.75.MISMATCH!feed1.newsreader.com!newsreader.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newspeer1.nwr.nac.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3e715b74$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,e15f2a7df7618bf3
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-03-13 20:52:58 PST
From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3e715b74$1@newsgroups.borland.com>
Subject: Re: Get/SetEnvironmentVariable
Date: Thu, 13 Mar 2003 20:59:52 -0800
Lines: 41
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 207.175.226.26
Message-ID: <3e715f9a$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1047617434 207.175.226.26 (13 Mar 2003 20:50:34 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!38.144.126.75.MISMATCH!feed1.newsreader.com!newsreader.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newspeer1.nwr.nac.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail