Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages
Started by JD
Fri, 14 Mar 2003 04:32
Get/SetEnvironmentVariable
Author: JD
Date: Fri, 14 Mar 2003 04:32
Date: Fri, 14 Mar 2003 04:32
17 lines
1291 bytes
1291 bytes
I'm trying to track a bug and need confirmation that I'm using these API's correctly please: AnsiString oldPath, newPath; GetEnvironmentVariable( "PATH", oldPath, MAXPATH ); newPath = oldPath + ";D:\\Test Folder"; SetEnvironmentVariable( "PATH", newPath, newPath.Length() ); // do my stuff SetEnvironmentVariable( "PATH", oldPath, oldPath.Length() ); TIA ~ JD
Re: Get/SetEnvironmentVariable
Author: Remy Lebeau (TeamB)
Date: Fri, 14 Mar 2003 04:59
Date: Fri, 14 Mar 2003 04:59
39 lines
2187 bytes
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
Re: Get/SetEnvironmentVariable
Author: JD
Date: Fri, 14 Mar 2003 05:07
Date: Fri, 14 Mar 2003 05:07
7 lines
1016 bytes
1016 bytes
"Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> wrote: > Sorry, you're not. Thank you kindly Sir. ~ JD
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads