How to check programatically that 8.3 short path name is enabled on system?

[亡魂溺海] 提交于 2019-12-22 10:34:00

问题


I know manually we can enable or disable 8.3 short path name support by setting NtfsDisable8dot3NameCreation.

But how to read this system information through code? Actually I have to disable some functionality based on whether the system have 8.3 enabled or not.

Please help

Thanks


回答1:


fsutil provides this functionality:

PS C:\Windows\system32> FSUTIL.EXE 8dot3name query D: 
The volume state is: 0 (8dot3 name creation is enabled). 
The registry state is: 2 (Per volume setting - the default).

Based on the above two settings, 8dot3 name creation is enabled on D:

If you want an API, use GetVolumeInformation, which provides this:

lpMaximumComponentLength [out, optional]

A pointer to a variable that receives the maximum length, in TCHARs, of a file name component that a specified file system supports.

A file name component is the portion of a file name between backslashes. The value that is stored in the variable that *lpMaximumComponentLength points to is used to indicate that a specified file system supports long names. For example, for a FAT file system that supports long names, the function stores the value 255, rather than the previous 8.3 indicator. Long names can also be supported on systems that use the NTFS file system.



来源:https://stackoverflow.com/questions/18479322/how-to-check-programatically-that-8-3-short-path-name-is-enabled-on-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!