This topic has not yet been rated - Rate this topic

CheckNameLegalDOS8Dot3 function

Applies to: desktop apps only

Determines whether the specified name can be used to create a file on a FAT file system.

Syntax

BOOL WINAPI CheckNameLegalDOS8Dot3(
  __in       LPCTSTR lpName,
  __out_opt  LPSTR lpOemName,
  __in       DWORD OemNameSize,
  __out_opt  PBOOL pbNameContainsSpaces,
  __out      PBOOL pbNameLegal
);

Parameters

lpName [in]

The file name, in 8.3 format.

lpOemName [out, optional]

A pointer to a buffer that receives the OEM string that corresponds to Name. This parameter can be NULL.

OemNameSize [in]

The size of the lpOemName buffer, in characters. If lpOemName is NULL, this parameter must be 0 (zero).

pbNameContainsSpaces [out, optional]

Indicates whether or not a name contains spaces. This parameter can be NULL. If the name is not a valid 8.3 FAT file system name, this parameter is undefined.

pbNameLegal [out]

If the function succeeds, this parameter indicates whether a file name is a valid 8.3 FAT file name when the current OEM code page is applied to the file name.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.

Remarks

This function can be used to determine whether or not a file name can be passed to a 16-bit Windows-based application or an MS-DOS-based application.

Requirements

Minimum supported client

Windows Vista, Windows XP with SP1

Minimum supported server

Windows Server 2003

Header

WinBase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

Unicode and ANSI names

CheckNameLegalDOS8Dot3W (Unicode) and CheckNameLegalDOS8Dot3A (ANSI)

See also

File Management Functions
GetOEMCP

 

 

Send comments about this topic to Microsoft

Build date: 4/17/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Platform Invoke Code Snippet (CheckNameLegalDOS8Dot3)
/// <summary>
/// Determines whether the specified name can be used to create a file on a FAT file system. (ANSI version)
/// </summary>
/// <param name="lpName">The file name, in 8.3 format.</param>
/// <param name="lpOemName">A pointer to a buffer that receives the OEM string that corresponds to Name. This parameter can be NULL.</param>
/// <param name="OemNameSize">The size of the lpOemName buffer, in characters. If lpOemName is NULL, this parameter must be 0 (zero).</param>
/// <param name="pbNameContainsSpaces">Indicates whether or not a name contains spaces. This parameter can be NULL. If the name is not a valid 8.3 FAT file system name, this parameter is undefined.</param>
/// <param name="pbNameLegal">If the function succeeds, this parameter indicates whether a file name is a valid 8.3 FAT file name when the current OEM code page is applied to the file name.</param>
/// <returns>
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.
/// </returns>
/// <remarks>
/// This function can be used to determine whether or not a file name can be passed to a 16-bit Windows-based application or an MS-DOS-based application.
/// </remarks>
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
static extern bool CheckNameLegalDOS8Dot3A(
    [In] string lpName,
    [Out] StringBuilder lpOemName,
    [In, MarshalAs(UnmanagedType.U4)] int OemNameSize,
    [Out] out bool pbNameContainsSpaces,
    [Out] out bool pbNameLegal);
/// <summary>
/// Determines whether the specified name can be used to create a file on a FAT file system. (Unicode version)
/// </summary>
/// <param name="lpName">The file name, in 8.3 format.</param>
/// <param name="lpOemName">A pointer to a buffer that receives the OEM string that corresponds to Name. This parameter can be NULL.</param>
/// <param name="OemNameSize">The size of the lpOemName buffer, in characters. If lpOemName is NULL, this parameter must be 0 (zero).</param>
/// <param name="pbNameContainsSpaces">Indicates whether or not a name contains spaces. This parameter can be NULL. If the name is not a valid 8.3 FAT file system name, this parameter is undefined.</param>
/// <param name="pbNameLegal">If the function succeeds, this parameter indicates whether a file name is a valid 8.3 FAT file name when the current OEM code page is applied to the file name.</param>
/// <returns>
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.
/// </returns>
/// <remarks>
/// This function can be used to determine whether or not a file name can be passed to a 16-bit Windows-based application or an MS-DOS-based application.
/// </remarks>
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
static extern bool CheckNameLegalDOS8Dot3W(
    [In] string lpName,
    [Out] StringBuilder lpOemName,
    [In, MarshalAs(UnmanagedType.U4)] int OemNameSize,
    [Out] out bool pbNameContainsSpaces,
    [Out] out bool pbNameLegal);
/// <summary>
/// Determines whether the specified name can be used to create a file on a FAT file system. (Auto character set)
/// </summary>
/// <param name="lpName">The file name, in 8.3 format.</param>
/// <param name="lpOemName">A pointer to a buffer that receives the OEM string that corresponds to Name. This parameter can be NULL.</param>
/// <param name="OemNameSize">The size of the lpOemName buffer, in characters. If lpOemName is NULL, this parameter must be 0 (zero).</param>
/// <param name="pbNameContainsSpaces">Indicates whether or not a name contains spaces. This parameter can be NULL. If the name is not a valid 8.3 FAT file system name, this parameter is undefined.</param>
/// <param name="pbNameLegal">If the function succeeds, this parameter indicates whether a file name is a valid 8.3 FAT file name when the current OEM code page is applied to the file name.</param>
/// <returns>
/// If the function succeeds, the return value is nonzero.
/// If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.
/// </returns>
/// <remarks>
/// This function can be used to determine whether or not a file name can be passed to a 16-bit Windows-based application or an MS-DOS-based application.
/// </remarks>
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = false, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
static extern bool CheckNameLegalDOS8Dot3(
    [In] string lpName,
    [Out] StringBuilder lpOemName,
    [In, MarshalAs(UnmanagedType.U4)] int OemNameSize,
    [Out] out bool pbNameContainsSpaces,
    [Out] out bool pbNameLegal);