Applies to: desktop apps only
Sets the short name for the specified file. The file must be on an NTFS file system volume.
Syntax
BOOL WINAPI SetFileShortName( __in HANDLE hFile, __in LPCTSTR lpShortName );
Parameters
- hFile [in]
-
A handle to the file. The file must be opened with either the GENERIC_ALL access right or GENERIC_WRITE|DELETE, and with the FILE_FLAG_BACKUP_SEMANTICS file attribute.
- lpShortName [in]
-
A pointer to a string that specifies the short name for the file.
Specifying an empty (zero-length) string will remove the short file name, if it exists for the file specified by the hFile parameter. If a short file name does not exist, the function will do nothing and return success.
Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: This behavior is not supported. The parameter must contain a valid string of one or more characters.
Return value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError. GetLastError may return one of the following error codes that are specific to this function.
| Return code | Description |
|---|---|
|
The specified short name is not unique. |
|
Either the specified file has been opened in case-sensitive mode or the specified short name is invalid. |
Remarks
The caller of this function must have the SE_RESTORE_NAME privilege. For more information, see Running with Special Privileges.
Requirements
|
Minimum supported client | Windows XP |
|---|---|
|
Minimum supported server | Windows Server 2003 |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names | SetFileShortNameW (Unicode) and SetFileShortNameA (ANSI) |
See also
Send comments about this topic to Microsoft
Build date: 4/17/2012