2 out of 3 rated this helpful - Rate this topic

SHCreateDirectory function

[SHCreateDirectory is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.]

Applies to: desktop apps only

Creates a new file system folder.

Syntax

int SHCreateDirectory(
  __in_opt  HWND hwnd,
  __in      PCWSTR pszPath
);

Parameters

hwnd [in, optional]

Type: HWND

A handle to a parent window. This parameter can be set to NULL if no user interface is displayed.

pszPath [in]

Type: PCWSTR

A pointer to a null-terminated Unicode string that contains the fully qualified path of the directory. This string should have no more than MAX_PATH characters, including the terminating null character.

Return value

Type: int

Returns ERROR_SUCCESS if successful. If the operation fails, other error codes can be returned, including those listed here. For values not specifically listed, see System Error Codes.

Return codeDescription
ERROR_BAD_PATHNAME

The pszPath parameter was set to a relative path.

ERROR_FILENAME_EXCED_RANGE

The path pointed to by pszPath is too long.

ERROR_FILE_EXISTS

The directory exists.

ERROR_ALREADY_EXISTS

The directory exists.

ERROR_CANCELLED

The user canceled the operation.

 

Remarks

This function creates a file system folder whose fully qualified path is given by pszPath. If one or more of the intermediate folders do not exist, it creates them.

To set security attributes on a new folder, use SHCreateDirectoryEx.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

End of client support

Windows XP with SP2

End of server support

Windows Server 2003

Header

Shlobj.h

Library

Shell32.lib

DLL

Shell32.dll (version 5.0 or later)

See also

SHCreateDirectoryEx

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Dropped in Vista
This function has indeed been dropped from Windows Vista. Use SHCreateDirectoryEx instead.