|
-
October 8th, 1999, 01:43 PM
#1
ExpandEnvironmentStrings
The call is simple enough but everthing that I have done, and what other people have showed me doesn't seem to work. Everytime I get an empty string from this. What is wrong?
private Declare Function ExpandEnvironmentStrings Lib "kernel32" Alias "ExpandEnvironmentStringsA" (byval lpSrc as string, byval lpDst as string, byval nSize as Long) as Long
private Sub Command1_Click()
Dim sString as string
sString = Space(255)
Call ExpandEnvironmentStrings("Path = %PATH%", byval sString, 255)
sString = Left(sString, InStr(sString, Chr(0)) - 1)
Text1 = sString
End Sub
-
October 11th, 1999, 01:55 AM
#2
Re: ExpandEnvironmentStrings
I tried your code, and yes, it did NOT work.
Why?
- the buffer was too small. In Nt my path was longer than 255 bytes.
- thus, make your buffer bigger.
Better yet, trap the return code from ExpandEn... and pass it to FormatMessage API to get the human-readable explanation of the failure.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|