TOPIC: Getting The Desktop folder
Getting The Desktop folder 2 Years, 4 Months ago
I've tested this on Vista and XP and it works. However I know there is a way to do this without an environment variable.

SHGetFolderLocation however this returns a structure. Is there a nice way round the struct problem?

GetDesktopPath = function ()
if (0 is n = GetDesktopPathApi("USERPROFILE", buf = Buffer(255),255))
return false
return buf.Substr(0, n) $ "\Desktop"

GetDesktopPathApi = dll long Kernel32:GetEnvironmentVariable(
string lpName, // environment variable name
buffer lpBuffer, // buffer for variable value
long nSize // size of buffer
Re:Getting The Desktop folder 2 Years, 4 Months ago
Yeah, they don't make it easy to call some of those API's.

SHGetFolderLocation takes a pointer to a PIDL.

I think you should be able to define the argument as LONG* ppidl

After calling the function, ppidl.x will be the result PIDL (or NULL).

You should be able to pass this to SHGetPathFromIDList. (already in stdlib)

But I haven't tried to do it so there may be issues I'm not thinking of.