"George Huber" <kh*****@optonline.net> wrote in
news:EI*********************@news4.srv.hcvlny.cv.n et:
"Steve Adams" <st******@baydelna.com> wrote in message
news:67*************************@posting.google.co m... Is there any way to access system variables from C under Windows
2000? I'd like to use the system variable %SystemRoot% in the
remove(file) call:
remove("%SystemRoot%\\System32\\drivers\\my_driver ");
Try using:
DWORD GetEnvironmentVariable(
LPCTSTR lpName, // environment variable name
LPTSTR lpBuffer, // buffer for variable value
DWORD nSize // size of buffer
);
That is a platform specific API and has no place in comp.lang.c.
So to get the %SystemRoot% variable, the following code should work.
char szPath[MAX_PATH]; // MAX_PATH is defined
in a windows header, 255 bytes.
DWORD dwRet;
dwRet = GetEnvironmentVariable("SystemRoot", szPath, MAX_PATH);
if(dwRet == 0)
{
cout << "Variable SystemRoot not defined" << endl;
}
and that is C++ which has no place here either. Also, please avoid top
posting.
As for the OP's question, AFAIK the mixed case environment variables in
windows are a little special, and you'd be best served asking this
question in one of the comp.os.ms-windows.programmer.* groups where
people who know about this stuff can answer your question.
Sinan.
--
A. Sinan Unur
as**@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uc*@ftc.gov