none
Querying a Volume's 8dot3name Setting

    问题

  • I believe this is the correct forum, though my question is slightly more relevant to non-server Win7 but the solution should be the same (I would hope).

    I am looking for a Windows API or COM interface I can use to query a particular volume for the new disable8dot3name settings. Since Windows 7/2008R2 have added two more values to the NtfsDisable8dot3NameCreation registry value, the default which is now per volume control, it is not enough to just query that reg value. If the value is 2 (per volume control) you need some way in which to query your target volume to find if 8.3 names are disabled there or not. I've muddled around looking through the MSDN at different APIs and some COM interfaces but haven't found anything which seems to be relevant. Though I am not sure exactly where I should be looking...

    My current "solution", as it were, is to create a file on the target volume (with a long name), call GetShortPathName (this will return a path even if shortnames are disabled, so using it is simply not enough), then call CheckNameLegalDOS8Dot3 to test if its valid 8.3. Though CheckNameLegalDOS8Dot3 is primarily for checking files to be written to a FAT file system, I would assume it would be good enough to test 8.3 names on an NTFS one as well. It is quite a bit just to test if 8.3 names are disabled, so I would hope there might be something simpler. Which would only be required to work on Win7/Win2k8R2, since those are the only OS's with the new settings.

    2010年4月13日 21:26

答案

全部回复

  • Run this command and parse the results is the simple answer.

    C:\>fsutil behavior query disable8dot3
    disable8dot3 = 0

    Otherwise use the Registry API's of your choice to read the following key.

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
    "NtfsDisable8dot3NameCreation"=dword:00000001

    0=disabled

    1=enabled

    2010年4月13日 21:53
  • I think you misunderstand what I'm asking. In Windows 2008R2 and Windows 7 two new options were added to NtfsDisable8dot3NameCreation: 2 which is per volume disabling, and 3 which is disabled on all drives except system drive. Setting 2 is the new default, and poses the real problem. If the NtfsDisable8dot3NameCreation is set to 2, it tells me no information about which volumes 8.3 names are disabled on or not. All drives could be disabled, all drives could be enabled (the default as far as I know), or only some drives could be disabled.

    I do know the fsutil command does have this possibility, with 'fsutil 8dot3name query C:' for example. But that is more bothersome because I would need to parse the actual text output of the command, and my current approach is moderately simpler than that (in my opinion). Is there no other API/COM/registry value I can use to essentially get the equivalent of the fsutil command? Which is querying a particular volume for disable8dot3 on Win2k8R2 or Win7.

    Reference of new NtfsDisable8dot3NameCreation:

    http://technet.microsoft.com/en-us/library/cc778996.aspx

    2010年4月14日 5:21
  • My orinigal post still applies.  To properly query this setting you need to use an API or COM object that reads the registry then you need to code your program to read the appropriate settings.

    You can use the WScript.Shell COM object and its registry functions, or you can use the WMI stdRegProv provider, or you can use the registry APIs avaialble from Advapi32.dll, or you can use the .NET registry functions.  Take your pick.

    As far as i know there is no specific API that reads and writes this setting for you, but hey you didn't post to a development forum....you posted to the file services and storage forum.

    2010年4月14日 13:42
  • My orinigal post still applies.  To properly query this setting you need to use an API or COM object that reads the registry then you need to code your program to read the appropriate settings.

    Yes of course I use an API to read the registry setting initially, but doing that does not solve the problem when the setting is 2. If I am dealing with a file say on the C: volume and the registry setting is 2 (after I have queried it), this tells me absolutely nothing as to whether 8.3 names are disabled or not on the C: volume. Querying that registry setting is only the solution if the setting is 0 or 1 (3 is actually a simple enough case to handle as well).

    As far as i know there is no specific API that reads and writes this setting for you, but hey you didn't post to a development forum....you posted to the file services and storage forum.

    Understandable, I wasn't sure if this was the correct place to post either at first. I was recommended to ask here from a MS file system newsgroup. Haven't really posted at any MS forums before, or become familiar with them, but I guess its quite obvious now I need to go find the correct MSDN forum.
    2010年4月14日 15:31
  • From: http://www.scl.com/interoperability/windows-and-unix-interoperability-news/mks-toolkit-support-for-windows-7

    additional information provided by the GetVolumeInformation API such as hard links and whether or not 8.3 file name generation is enabled on a drive (or volume).

    Although in looking at that API its not clear how you determine that setting.

    http://msdn.microsoft.com/en-us/library/aa364993(VS.85).aspx

    Good luck.

     

    2010年4月14日 18:11

  • It’s more of a development issue, it’s suggested to submit a new post in the MSDN forum to get more suggestions. They are the best resource for this kind of problem.

    MSDN Forum
    http://social.msdn.microsoft.com/forums/en-US/categories/

    Thanks.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    2010年4月20日 8:43
    版主