LWJGL Forum

Programming => General Java Game Development => Topic started by: mot on October 25, 2006, 23:04:09

Title: Simple SHGetSpecialFolderPath interface
Post by: mot on October 25, 2006, 23:04:09
All we get in Java is user.home, which usually points to something like
C:\Documents and Settings\user\
while I want this:
C:\Documents and Settings\user\My documents\

In the win32 API, the My documents path or Desktop or other special Windows locations can be retrieved using the SHGetSpecialFolderPath() function. So I created a simple interface to access SHGetSpecialFolderPath in Java. Not thoroughly tested yet and also my first JNI encounter, so don't kick me, alright?

Here it is with full source code and Visual Studio 2003 solution files: http://www.catnapgames.com/download/WinFoldersJava.zip

Contact me here: tomovo@gmail.com


Cheers!
Tom
Title: Re: Simple SHGetSpecialFolderPath interface
Post by: mot on January 12, 2007, 23:50:26
UPDATE: now on Google Code

http://code.google.com/p/winfoldersjava/
Title: Re: Simple SHGetSpecialFolderPath interface
Post by: darkprophet on January 13, 2007, 11:07:34
isn't My Documents simply:

Quote
File f = new File(System.getProperty("user.home") + "\My Documents\");

just replace My Documents with Desktop if you really want the Desktop? Or am I missing something?

DP
Title: Re: Simple SHGetSpecialFolderPath interface
Post by: mot on January 13, 2007, 11:45:36
Yes, indeed you are missing something. This will only work in the English version of Windows XP. Vista has a different folder structure and any Windows in any other language have a different name for the folders. So you absolutely need to call the API function to get the correct location.