first steps in Managed C++ (& String.Format)(on 2.0)

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

I try to call putenv with a new path of my own like that:
-----------------------------------------
static void InitGnuStep()
{
System::String^ gsroot = ConfigurationManager::AppSettings[L"GNUSTEP_SYSTEM_ROOT"];
System::String^ path = ConfigurationManager::AppSettings[L"PATH"];

path = System::String::Format(L"PATH={1}{0}{2}{0}{3}",
System::IO::Path::PathSeparator,
gsroot,
path,
::System::Environment::GetEnvironmentVariable(L"PATH"));
gsroot = System::String::Format("GNUSTEP_SYSTEM_ROOT=", gsroot);

// these two never get freed, I know!
_wputenv((const wchar_t *)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalUni(gsroot));
_wputenv((const wchar_t *)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalUni(path));
}
-----------------------------------------

Now I have a compiler error on GetEnvironmentVariable() which, supposedly, don't exist in C++ ?!
instead the syntax completion suggest me:

DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR lpBuffer, DWORD nSize);

While it's not a problem in itself, it's a bit annoying as I would like to use the nice lean, 1 operation,
String.Format I'm trying to use...

Beside I'm not sure what a LPCSTR is .....

Any suggestion?
 
static void InitGnuStep()
{
String^ gsroot = ConfigurationManager::AppSettings[L"GNUSTEP_SYSTEM_ROOT"];
String^ path = ConfigurationManager::AppSettings[L"PATH"];
String^ opath = gcnew String(_wgetenv(L"PATH"));

path = String::Format(L"PATH={1}{0}{2}{0}{3}",
System::IO::Path::PathSeparator,
gsroot,
path,
opath);
gsroot = String::Format("GNUSTEP_SYSTEM_ROOT=", gsroot);

// these two never get freed, I know!
_wputenv((const wchar_t *)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalUni(gsroot));
_wputenv((const wchar_t *)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalUni(path));
}


I try to call putenv with a new path of my own like that:
-----------------------------------------
static void InitGnuStep()
{
System::String^ gsroot = ConfigurationManager::AppSettings[L"GNUSTEP_SYSTEM_ROOT"];
System::String^ path = ConfigurationManager::AppSettings[L"PATH"];

path = System::String::Format(L"PATH={1}{0}{2}{0}{3}",
System::IO::Path::PathSeparator,
gsroot,
path,
::System::Environment::GetEnvironmentVariable(L"PATH"));
gsroot = System::String::Format("GNUSTEP_SYSTEM_ROOT=", gsroot);

// these two never get freed, I know!
_wputenv((const wchar_t *)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalUni(gsroot));
_wputenv((const wchar_t *)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalUni(path));
}
-----------------------------------------

Now I have a compiler error on GetEnvironmentVariable() which, supposedly, don't exist in C++ ?!
instead the syntax completion suggest me:

DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR lpBuffer, DWORD nSize);

While it's not a problem in itself, it's a bit annoying as I would like to use the nice lean, 1 operation,
String.Format I'm trying to use...

Beside I'm not sure what a LPCSTR is .....

Any suggestion?
 
Back
Top