Skip to content

Instantly share code, notes, and snippets.

@nimdahk
Created April 21, 2012 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nimdahk/2433054 to your computer and use it in GitHub Desktop.
Save nimdahk/2433054 to your computer and use it in GitHub Desktop.
ExpandEnvironmentStrings wrapper for AutoHotkey - expands %var% references when var is part of the environment
ExpandEnvironmentStrings(string){
; Find length of dest string:
nSize := DllCall("ExpandEnvironmentStrings", "Str", string, "Str", NULL, "UInt", 0, "UInt")
,VarSetCapacity(Dest, size := (nSize * (1 << !!A_IsUnicode)) + !A_IsUnicode) ; allocate dest string
,DllCall("ExpandEnvironmentStrings", "Str", string, "Str", Dest, "UInt", size, "UInt") ; fill dest string
return Dest
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment