You are still using a buffer of a fixed size.
Whoops, didn't think about that one.
StrRChrW is a shlwapi export. Since shlwapi.dll is just mostly a wrapper/helper, and it imports shell32, that would create a circular dependency. I already suggested to use strrchrW here.
Um, ok. I didn't realize there were two different functions. I only was able to find documentation on StrRChrW.
There is indeed a circular dependency (which I wouldn't have noticed), apparently because shell32 needs to export StrRChrW.
Again StrCpyNW is a shlwapi export, and since you just allocated the buffer of correct length memcpy + adding an explicit '\0' terminator look more naturally here (if not kernel32.lstrcpynW).
I'm allowed to use memcpy? Isn't that a native Linux function?
You are still not checking SHCreateDirectoryExW return value.
Nope. If SHCreateDirectoryExW returns ERROR_ALREADY_EXISTS, I need to return HRESULT_FROM_WIN32(ERROR_DIRECTORY) or S_OK, depending on whether it is a file or a directory. And since I'd need to free temppath if and only if I'm returning early, I think that any way I could do that would make the code awkward/confusing.
There is no need to check temppath for NULL before HeapFree call.
Oh. MSDN says there is. Not that I trust MSDN..