The code used in juce file
static GetFinalPathNameByHandleFunc getFinalPathNameByHandle = (GetFinalPathNameByHandleFunc) getUser32Function (“GetFinalPathNameByHandle”);
is always null (even on Windows 7)
but if I replace directly getFinalPathNameByHandle by GetFinalPathNameByHandleW and remove the if, it works just fine.
I tried with GetFinalPathNameByHandleW as the string instead and it wasn’t working
Still indeed, GetFinalPathNameByHandleW is Windows Vista mininmum and juce is already at this level as I was able to just replace the function so it’s pretty safe to just call it directly.
Sorry, I don’t understand the problem. Please can you provide the code you’re testing, along with the expected and actual results of running that code?
Yes, I can repro the issue on my Windows 10 machine.
This was a bit of a head-scratcher, but I learned some new things. Specifically, Windows paths that start with a drive letter and a colon but no path separator (e.g. “C:” or “D:relative\path”) are always interpreted as relative to the “current directory” of the drive (source), which is why GetFinalPathNameByHandle sometimes ends up expanding to the entire working directory.
The reason I didn’t see the problem on my Windows 11 machine is that I have a separate “D:” drive there that I use for development. When I launched the test program on that machine, the “current directory” on the C drive was still set to the root, so the path expanded out to C:\. When I changed the demo snippet to use juce::File file("D:"); then this ended up expanding out to the program’s current working directory on that drive.
I’ve put together a potential fix for this issue, and I’ll update this thread once it’s published.