Export (0) Print
Expand All
Expand Minimize
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.]

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 [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

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

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.