January 1, 2005

WinTask - EnvExpand

'
' EnvExpand
'
' Author: Joe Strazzere
'

' This script expands a string containing an environment variable
' (that is, enclosed in %...%).
' It may also be useful when expanding strings stored in the Registry
'
dim ptr1 as unsigned
dim ptr2 as unsigned
EnvString$="%INCLUDE%"
ptr1=allocate(10)
PokeString(ptr1,EnvString$,1)
ptr2=allocate(255)
ret=External("kernel32.dll","ExpandEnvironmentStringsA",ptr1,ptr2,100)
var$=PeekString$(ptr2)
msgbox(EnvString$+" expands to: "+var$)