I am looking for a function in VB6 (or some WinAPI) that might be able to satisfy this requirement: Take an input path string that includes environment variables, and output that path with environment variables resolved.
I could of course write my own parser, but I am wondering if this functionality already exists?
This would be similar to the Spring Framework's "
Worst case you can use the native implementation:
Kernel32.dll exports a function called
My VB6 is rusty but you can call this by doing:
Declare Function ExpandEnvironmentStrings _ Lib "kernel32" Alias "ExpandEnvironmentStringsA" _ (ByVal lpSrc As String, ByVal lpDst As String, _ ByVal nSize As Long) As Long
Then in a function or sub:
Dim result as Long Dim strInput As String, strOutput As String '' Two calls required, one to get expansion buffer length first then do expansion result = ExpandEnvironmentStrings(strInput, strOutput, result) strOutput = Space$(result) result = ExpandEnvironmentStrings(strInput, strOutput, result)
Using the seldom used Environ() Function: http://vbcity.com/forums/t/45987.aspx