I'd like to retrieve the location of a Windows virtual folder from Java. JNA provides some support but the documentation don't explain how to directly use it.
Asked
Active
Viewed 285 times
0
-
What windows function call would you use to look it up? Translate that into a JNA mapping and extend the appropriate JNA mapping to instantiate your own. – technomage Nov 02 '16 at 12:36
1 Answers
1
Having a look into the JNA source reveals the javadoc of Shell32Util.getKnownFolderPath(Guid.GUID)
Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID.
The local application data directory can be retrieved as
String localAppDataDir = Shell32Util.getKnownFolderPath(
KnownFolders.FOLDERID_LocalAppData);
System.out.println(localAppDataDir);
output will be something like
C:\Users\JohnDoe\AppData\Local
where JohnDoe
is the name of the current user.

SubOptimal
- 22,518
- 3
- 53
- 69