Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > access to system variables from C under W2K

Reply
Thread Tools

access to system variables from C under W2K

 
 
Steve Adams
Guest
Posts: n/a
 
      07-11-2003
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 ");

Thanks for any ideas.

Steve
 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      07-12-2003
"George Huber" <(E-Mail Removed)> wrote in
news:EIHPa.21216$(E-Mail Removed) et:

> "Steve Adams" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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
http://www.velocityreviews.com/forums/(E-Mail Removed)
Remove dashes for address
Spam bait: (E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wireless LAN under W2k? Mtty Wireless Networking 10 11-28-2005 04:21 AM
Running Python scripts under W2K with I/O redirection sub1ime_uk@yahoo.com Python 1 06-25-2005 06:26 AM
W2K Prof. to W2K Prof. File & Printer Sharing Not Working =?Utf-8?B?Qm9i?= Wireless Networking 14 12-17-2004 06:20 PM
Setup problem under W2K Urs Vogel ASP .Net 0 06-03-2004 02:40 PM
COM deadlocks under W2k but under NT 4.0 Steve ASP General 0 07-24-2003 02:13 PM



Advertisments