SHCreateDirectoryEx 创建多级目录

本文介绍SHCreateDirectoryEx函数,用于创建文件系统中的新文件夹。详细解释了函数的参数、返回值及注意事项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SHCreateDirectoryEx Function


Creates a new file system folder.

Syntax

int SHCreateDirectoryEx(      
    HWND hwnd,     LPCTSTR pszPath,     SECURITY_ATTRIBUTES *psa );

Parameters

hwnd
[in] Handle to a parent window. This parameter can be set to NULL if no user interface will be displayed.
pszPath
[in] Pointer to a null-terminated string specifiying the fully qualified path of the directory. This string is of maximum length of 248 characters, including the null terminator.
psa
[in] Pointer to a SECURITY_ATTRIBUTES structure with the directory's security attribute. Set this parameter to NULL if no security attributes need to be set.

Return Value

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 .

ERROR_BAD_PATHNAMEThe pszPath parameter was set to a relative path.
ERROR_FILENAME_EXCED_RANGEThe path pointed to by pszPath is too long.
ERROR_PATH_NOT_FOUNDThe system cannot find the path pointed to by pszPath. The path may contain an invalid entry.
ERROR_FILE_EXISTSThe directory exists.
ERROR_ALREADY_EXISTSThe directory exists.
ERROR_CANCELLEDThe 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, they will be created as well. SHCreateDirectoryEx also verifies that the files will be visible. If not:

  • If hwnd is set to a valid window handle, a message box is displayed warning the user that he or she might not be able to access the files. If the user chooses not to proceed, the function returns ERROR_CANCELLED.
  • If hwnd is set to NULL, no user interface is displayed and the function returns ERROR_CANCELLED.

Function Information

Minimum DLL Versionshell32.dll version 5.0 or later
Custom ImplementationNo
Headershlobj.h
Import libraryshell32.lib
Minimum operating systemsWindows 2000, Windows Millennium Edition
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值