Shell32SHGetFileInfo(String, FileAttributes, ShellFileInfo, UInt32, SHGetFileInfoFlags) Method

Retrieves information about an object in the file system, such as a file, folder, directory, or drive root.

Definition

Namespace: DevCase.Win32.NativeMethods
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Shell32.dll", CharSet = CharSet.Auto, BestFitMapping = false, 
	ThrowOnUnmappableChar = true)]
public static IntPtr SHGetFileInfo(
	string path,
	FileAttributes fileAttribs,
	ref ShellFileInfo refShellFileInfo,
	uint size,
	SHGetFileInfoFlags flags
)

Parameters

path  String
A pointer to a null-terminated string of maximum length MAX_PATH that contains the path and file name. Both absolute and relative paths are valid.

If the flags parameter includes the PIDL flag, this parameter must be the address of an ITEMIDLIST (PIDL) structure that contains the list of item identifiers that uniquely identifies the file within the Shell's namespace. The PIDL must be a fully qualified PIDL. Relative PIDLs are not allowed.

If the uFlags parameter includes the UseFileAttributes flag, this parameter does not have to be a valid file name. The function will proceed as if the file exists with the specified name and with the file attributes passed in the fileAttribs parameter. This allows you to obtain information about a file type by passing just the extension for path parameter and passing FILE_ATTRIBUTE_NORMAL in fileAttribs parameter

fileAttribs  FileAttributes
A combination of one or more file attribute flags.

If flags parameter does not include the UseFileAttributes flag, this parameter is ignored.

refShellFileInfo  ShellFileInfo
Pointer to a ShellFileInfo structure to receive the file information.
size  UInt32
The size, in bytes, of the ShellFileInfo structure pointed to by the refShellFileInfo parameter.
flags  SHGetFileInfoFlags
The flags that specify the file information to retrieve.

Return Value

IntPtr
Returns a value whose meaning depends on the flags parameter.

If flags parameter does not contain ExeType or SysIconIndex, the return value is nonzero if successful, or zero otherwise.

If flags parameter contains the ExeType flag, the return value specifies the type of the executable.

Remarks

See Also