Win32 API Reference

Comprehensive documentation for the Windows API

Shell32 Functions

Functions for interacting with the Windows shell, including file operations, shortcuts, and system information.

SHFileOperation

Performs file operations such as copy, move, rename, and delete.

Header: shlobj.h

Syntax:
BOOL SHFileOperation(PSHFILEOPSTRUCTA lpFileOp); or BOOL SHFileOperation(PSHFILEOPSTRUCTW lpFileOp);
Parameters:
lpFileOp: A pointer to a SHFILEOPSTRUCT structure that contains all necessary information to perform the requested operation.
Return Value:
Returns a non-zero value if successful, or zero otherwise.
typedef struct _SHFILEOPSTRUCT { HWND hwnd; UINT wFunc; LPCSTR pszFrom; LPCSTR pszTo; FILEOP_FLAGS fFlags; BOOL fAnyOperationsAborted; LPVOID hNameMappings; LPCSTR lpszProgressTitle; } SHFILEOPSTRUCT, *PSHFILEOPSTRUCT, SHFILEOPSTRUCTA, *PSHFILEOPSTRUCTA;

SHOpenFolderAndSelectItems

Opens a folder and selects one or more items within it.

Header: shlobj.h

Syntax:
HRESULT SHOpenFolderAndSelectItems(PCIDLIST_ABSOLUTE pidlFolder, PCUITEMID_CHILD_ARRAY apidlSelect, HWND hwnd, DWORD dwFlags);
Parameters:
pidlFolder: The folder to open.
apidlSelect: An array of item IDs to select.
hwnd: The parent window handle.
dwFlags: Flags specifying how to open the folder.
Return Value:
Returns a success or error code.
HRESULT SHOpenFolderAndSelectItems( PCIDLIST_ABSOLUTE pidlFolder, PCUITEMID_CHILD_ARRAY apidlSelect, HWND hwnd, DWORD dwFlags );

SHCreateDirectoryEx

Creates a directory, including any necessary parent directories.

Header: shlobj.h

Syntax:
HRESULT SHCreateDirectoryEx( HWND hwnd, PCWSTR pszPath, PSECURITY_ATTRIBUTES psap );
Parameters:
hwnd: The owner window.
pszPath: The path of the directory to create.
psap: Security attributes.
Return Value:
Returns a success or error code.
HRESULT SHCreateDirectoryEx( HWND hwnd, PCWSTR pszPath, PSECURITY_ATTRIBUTES psap );

SHDeleteDirectory

Deletes an empty directory.

Header: shlobj.h

Syntax:
BOOL SHDeleteDirectory(PCWSTR pszPath);
Parameters:
pszPath: The path of the directory to delete.
Return Value:
Returns TRUE if successful, FALSE otherwise.
BOOL SHDeleteDirectory( PCWSTR pszPath );

SHAddToRecentDocs

Adds a document to the "Recent Documents" list.

Header: shlobj.h

Syntax:
void SHAddToRecentDocs( UINT enumFormatID, PCWSTR pszPath );
Parameters:
enumFormatID: The format of the document.
pszPath: The path of the document.
void SHAddToRecentDocs( UINT enumFormatID, PCWSTR pszPath );