Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetEnvironmentVariable

Status
Not open for further replies.

gcarolan

Programmer
Jun 18, 2002
36
0
0
IE
Hello,

I'm trying to get a System Variable so I can add on another string. I am using GetEnvironmentVariable and it works for most of the System Variables but not the one I want. There is a User Variable with the same name but its in Block Capitals while the System Variable isnt, could that cause the problem.

Any help would be appreciated.

Regards
gcarolan
 

The System Variable I needed was alot longer than the others, so I had to increase the space$() for the 2nd Parameter (ByVal lpBuffer As String) and also increase the 3rd parameters (nSize As Long) lenght.
 
gcarolan,

<<
There is a User Variable with the same name but its in Block Capitals while the System Variable isnt, could that cause the problem
>>

It could be the problem, not exactly sure. But the 1st parameter of GetEnvironmentVariable is case insensitive. I think it will return the first variable that it found. So in this case I think you better use GetEnvironmentStrings instead and search the string environment manually from the results

Hope it helps

-- AirCon --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top