I translated your whole functions. I hope I did not forget/missed anything.
; ===============================================================================================================================
MsgBox % "GetEnvironmentVariable:`n" GetEnvironmentVariable()
GetEnvironmentVariable(Name := "USERPROFILE") ; http://msdn.com/library/ms683188(vs.85,en-us)
{
size := DllCall("GetEnvironmentVariable", "Str", Name, "Ptr", 0, "UInt", 0)
VarSetCapacity(buf, size * (A_IsUnicode ? 2 : 1), 0)
if !(DllCall("GetEnvironmentVariable", "Str", Name, "Str", buf, "UInt", size))
return "*" A_LastError
return buf
}
; ===============================================================================================================================
MsgBox % "GetUserNameEx:`n" GetUserNameEx()
GetUserNameEx(EX_NAME_FORMAT := 2) ; http://msdn.com/library/ms724435(vs.85,en-us)
{
DllCall("secur32.dll\GetUserNameEx", "UInt", EX_NAME_FORMAT, "Ptr", 0, "UInt*", size)
VarSetCapacity(buf, size * (A_IsUnicode ? 2 : 1), 0)
if !(DllCall("secur32.dll\GetUserNameEx", "UInt", EX_NAME_FORMAT, "Str", buf, "UInt*", size))
return "*" A_LastError
return buf
}
; ===============================================================================================================================
MsgBox % "GetDefaultUserProfileDirectory:`n" GetDefaultUserProfileDirectory()
GetDefaultUserProfileDirectory() ; http://msdn.com/library/bb762277(vs.85,en-us)
{
DllCall("userenv.dll\GetDefaultUserProfileDirectory", "Ptr", 0, "UInt*", size)
VarSetCapacity(buf, size * (A_IsUnicode ? 2 : 1), 0)
if !(DllCall("userenv.dll\GetDefaultUserProfileDirectory", "Str", buf, "UInt*", size))
return "*" A_LastError
return buf
}
; ===============================================================================================================================
MsgBox % "GetProfilesDirectory:`n" GetProfilesDirectory()
GetProfilesDirectory() ; http://msdn.com/library/bb762278(vs.85,en-us)
{
DllCall("userenv.dll\GetProfilesDirectory", "Ptr", 0, "UInt*", size)
VarSetCapacity(buf, size * (A_IsUnicode ? 2 : 1), 0)
if !(DllCall("userenv.dll\GetProfilesDirectory", "Str", buf, "UInt*", size))
return "*" A_LastError
return buf
}
; ===============================================================================================================================
MsgBox % "GetAllUsersProfileDirectory:`n" GetAllUsersProfileDirectory()
GetAllUsersProfileDirectory() ; http://msdn.com/library/bb762276(vs.85,en-us)
{
DllCall("userenv.dll\GetAllUsersProfileDirectory", "Ptr", 0, "UInt*", size)
VarSetCapacity(buf, size * (A_IsUnicode ? 2 : 1), 0)
if !(DllCall("userenv.dll\GetAllUsersProfileDirectory", "Str", buf, "UInt*", size))
return "*" A_LastError
return buf
}
; ===============================================================================================================================
edit