Below you'll find the source for the Visual Basic 6 function EnvironGetKey.
Attribute VB_Name = "modEnvironGetKey"
' This function is downloaded from:
' http://www.stefanthoolen.nl/archive/vb6-functions/
'
' You may freely distribute this file but please leave all comments, including this one, in it.
'
' @Author Stefan Thoolen <mail@stefanthoolen.nl>
Option Explicit
''
' Gets the value of an environment key
' @param String keyname The environment keyname
' @return String The value
' @author Stefan Thoolen <mail@stefanthoolen.nl>
Public Function EnvironGetKey(ByVal keyname As String) As String
If Left(keyname, 1) = "%" And Right(keyname, 1) = "%" Then keyname = Mid(keyname, 2, Len(keyname) - 2)
Dim i As Integer, equalpos As Integer
i = 1
Do While Environ(i) <> ""
equalpos = InStr(Environ(i), "=")
If equalpos > 0 Then
If LCase(Left(Environ(i), equalpos - 1)) = LCase(keyname) Then
EnvironGetKey = Right(Environ(i), Len(Environ(i)) - equalpos)
Exit Function
End If
End If
i = i + 1
Loop
End Function