MSDN Documentation

Shell32 Functions

The Shell32.dll library provides functions for interacting with the Windows Shell. This includes functionality for managing files, folders, shortcuts, and other shell-related operations.

Commonly Used Functions

ShellExecute

Performs an operation on a specified file.

Shell_NotifyIcon

Manages notification icons in the taskbar.

DragAcceptFiles

Registers a window to accept dropped files.

SHBrowseForFolder

Displays a dialog box that allows the user to select a folder.

SHFileOperation

Performs a file operation (copy, move, rename, delete).

SHGetFolderPath

Retrieves the path of a special folder.

SHGetSpecialFolderPath

Retrieves the path of a special folder (deprecated, use SHGetFolderPath).

SHAppInfo

Retrieves information about installed applications.

SHSetCurrentDirectory

Sets the current directory for the process.

SHChangeNotify

Notifies the Shell about changes to the file system.

ShellExecute

Prototype:

HINSTANCE ShellExecute(
  HWND    hwnd,
  LPCTSTR lpOperation,
  LPCTSTR lpFile,
  LPCTSTR lpParameters,
  LPCTSTR lpDirectory,
  INT     nShowCmd
);

Description:

This function performs an operation on a specified file. It can be used to open a document, print a document, explore a folder, or execute a program.

Parameters:

Return Value:

If the function succeeds, it returns a value greater than 32. If the function fails, it returns a value that indicates the error.

Shell_NotifyIcon

Prototype:

BOOL Shell_NotifyIcon(
  DWORD dwMessage,
  PNOTIFYICONDATA pnid
);

Description:

This function is used to add, modify, or delete a notification icon in the taskbar's notification area.

Parameters:

Return Value:

Returns TRUE if successful, FALSE otherwise.

SHBrowseForFolder

Prototype:

LPITEMIDLIST SHBrowseForFolder(
  LPBROWSEINFO lpbi
);

Description:

Displays a dialog box that allows the user to select a folder. The function returns the PIDL (Pointer to an Item ID List) of the selected folder.

Parameters:

Return Value:

Returns a pointer to an item ID list that specifies the path of the folder the user selected. If the user cancels the dialog box, it returns NULL.

SHFileOperation

Prototype:

int SHFileOperation(
  PSHFILEOPSTRUCTA pfo
);

Description:

This function performs a file operation such as copying, moving, renaming, or deleting files and directories.

Parameters:

Return Value:

Returns zero if the operation is successful; otherwise, returns a nonzero error value.

SHGetFolderPath

Prototype:

HRESULT SHGetFolderPath(
  HWND    hwndOwner,
  int     nFolder,
  HANDLE  hToken,
  DWORD   dwFlags,
  LPTSTR  pszPath
);

Description:

Retrieves the path of a special folder, such as the user's profile directory, the system directory, or the desktop.

Parameters:

Return Value:

Returns S_OK if successful, or an error code otherwise.

SHChangeNotify

Prototype:

void SHChangeNotify(
  LONG wEventId,
  UINT uFlags,
  LPCVOID dwItem1,
  LPCVOID dwItem2
);

Description:

Notifies the Shell about changes to the file system, such as file creation, deletion, or renaming. This allows the Shell to update its views and caches accordingly.

Parameters: