Listing Windows file types
How can a Java pro开发者_如何学Pythongram get the list of File Types in Windows (those listed in Control Panel/Folder Options/File Types)?
The list of all registered file types is present in the registry under the HKEY_CLASSES_ROOT key. If the key begins with a .
it is a registered file extension.
Take a look at MSDN > File Types for more information about how they are stored in the registry.
You can query the registry using the reg
command. For example, in a Command Prompt type the following command to list out the file extensions.
reg query HKEY_CLASSES_ROOT | find "HKEY_CLASSES_ROOT\."
To execute this from a java program, use a ProcessBuilder.
精彩评论