|
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981
using global::System;
using global::System.Diagnostics;
using global::System.Diagnostics.CodeAnalysis;
using global::System.Runtime.CompilerServices;
using global::System.Runtime.InteropServices;
using global::System.Runtime.Versioning;
using winmdroot = global::Windows.Win32;
namespace Windows.Win32
{
/// <content>
/// Contains extern methods from "SHELL32.dll".
/// </content>
internal static partial class PInvoke
{
/// <inheritdoc cref="FindExecutable(winmdroot.Foundation.PCWSTR, winmdroot.Foundation.PCWSTR, winmdroot.Foundation.PWSTR)"/>
[SupportedOSPlatform("windows5.1.2600")]
internal static unsafe winmdroot.Foundation.HINSTANCE FindExecutable(string lpFile, string lpDirectory, winmdroot.Foundation.PWSTR lpResult)
{
fixed (char* lpDirectoryLocal = lpDirectory)
{
fixed (char* lpFileLocal = lpFile)
{
winmdroot.Foundation.HINSTANCE __result = PInvoke.FindExecutable(lpFileLocal, lpDirectoryLocal, lpResult);
return __result;
}
}
}
/// <summary>Retrieves the name of and handle to the executable (.exe) file associated with a specific document file. (Unicode)</summary>
/// <param name="lpFile">
/// <para>Type: <b>LPCTSTR</b> The address of a <b>null</b>-terminated string that specifies a file name. This file should be a document.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shellapi/nf-shellapi-findexecutablew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpDirectory">
/// <para>Type: <b>LPCTSTR</b> The address of a <b>null</b>-terminated string that specifies the default directory. This value can be <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shellapi/nf-shellapi-findexecutablew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpResult">
/// <para>Type: <b>LPTSTR</b> The address of a buffer that receives the file name of the associated executable file. This file name is a <b>null</b>-terminated string that specifies the executable file started when an "open" by association is run on the file specified in the <i>lpFile</i> parameter. Put simply, this is the application that is launched when the document file is directly double-clicked or when <b>Open</b> is chosen from the file's shortcut menu. This parameter must contain a valid non-<b>null</b> value and is assumed to be of length MAX_PATH. Responsibility for validating the value is left to the programmer.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shellapi/nf-shellapi-findexecutablew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HINSTANCE</b> Returns a value greater than 32 if successful, or a value less than or equal to 32 representing an error.</para>
/// <para>The following table lists possible error values. </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>
/// <para>Use <b>FindExecutable</b> for documents. If you want to retrieve the path of an executable file, use the following:</para>
/// <para></para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shellapi/nf-shellapi-findexecutablew#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("SHELL32.dll", ExactSpelling = true, EntryPoint = "FindExecutableW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.1.2600")]
internal static extern winmdroot.Foundation.HINSTANCE FindExecutable(winmdroot.Foundation.PCWSTR lpFile, winmdroot.Foundation.PCWSTR lpDirectory, winmdroot.Foundation.PWSTR lpResult);
/// <inheritdoc cref="SHBrowseForFolder(winmdroot.UI.Shell.BROWSEINFOW*)"/>
[SupportedOSPlatform("windows5.1.2600")]
internal static unsafe winmdroot.UI.Shell.Common.ITEMIDLIST* SHBrowseForFolder(in winmdroot.UI.Shell.BROWSEINFOW lpbi)
{
fixed (winmdroot.UI.Shell.BROWSEINFOW* lpbiLocal = &lpbi)
{
winmdroot.UI.Shell.Common.ITEMIDLIST* __result = PInvoke.SHBrowseForFolder(lpbiLocal);
return __result;
}
}
/// <summary>Displays a dialog box that enables the user to select a Shell folder. (Unicode)</summary>
/// <param name="lpbi">
/// <para>Type: <b>LPBROWSEINFO</b> A pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/shlobj_core/ns-shlobj_core-browseinfoa">BROWSEINFO</a> structure that contains information used to display the dialog box.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shbrowseforfolderw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>PIDLIST_ABSOLUTE</b> Returns a PIDL that specifies the location of the selected folder relative to the root of the namespace. If the user chooses the <b>Cancel</b> button in the dialog box, the return value is <b>NULL</b>.</para>
/// <para>It is possible that the PIDL returned is that of a folder shortcut rather than a folder. For a full discussion of this case, see the Remarks section.</para>
/// </returns>
/// <remarks>
/// <para>For Windows Vista or later, it is recommended that you use <a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ifiledialog">IFileDialog</a> with the FOS_PICKFOLDERS option rather than the SHBrowseForFolder function. This uses the Open Files dialog in pick folders mode and is the preferred implementation. You must initialize Component Object Model (COM) before you call <b>SHBrowseForFolder</b>. If you initialize COM using <a href="https://docs.microsoft.com/windows/desktop/api/combaseapi/nf-combaseapi-coinitializeex">CoInitializeEx</a>, you must set the COINIT_APARTMENTTHREADED flag in its <i>dwCoInit</i> parameter. You can also use <a href="https://docs.microsoft.com/windows/desktop/api/objbase/nf-objbase-coinitialize">CoInitialize</a> or <a href="https://docs.microsoft.com/windows/desktop/api/ole2/nf-ole2-oleinitialize">OleInitialize</a>, which always use apartment threading. If you require drag-and-drop functionality, <b>OleInitialize</b> is recommended because it initializes the required OLE as well as COM. <div class="alert"><b>Note</b> If COM is initialized using <a href="https://docs.microsoft.com/windows/desktop/api/combaseapi/nf-combaseapi-coinitializeex">CoInitializeEx</a> with the COINIT_MULTITHREADED flag, <b>SHBrowseForFolder</b> fails if the calling application uses the BIF_USENEWUI or BIF_NEWDIALOGSTYLE flag in the <a href="https://docs.microsoft.com/windows/desktop/api/shlobj_core/ns-shlobj_core-browseinfoa">BROWSEINFO</a> structure.</div> <div> </div> It is the responsibility of the calling application to call <a href="https://docs.microsoft.com/windows/desktop/api/combaseapi/nf-combaseapi-cotaskmemfree">CoTaskMemFree</a> to free the IDList returned by <b>SHBrowseForFolder</b> when it is no longer needed. There are two styles of dialog box available. The older style is displayed by default and is not resizable. The newer style provides a number of additional features, including drag-and-drop capability within the dialog box, reordering, deletion, shortcut menus, the ability to create new folders, and other shortcut menu commands. Initially, it is larger than the older dialog box, but the user can resize it. To specify a dialog box using the newer style, set the <b>BIF_USENEWUI</b> flag in the <b>ulFlags</b> member of the <a href="https://docs.microsoft.com/windows/desktop/api/shlobj_core/ns-shlobj_core-browseinfoa">BROWSEINFO</a> structure. If you implement a callback function, specified in the <b>lpfn</b> member of the <a href="https://docs.microsoft.com/windows/desktop/api/shlobj_core/ns-shlobj_core-browseinfoa">BROWSEINFO</a> structure, you receive a handle to the dialog box. One use of this window handle is to modify the layout or contents of the dialog box. Because it is not resizable, modifying the older style dialog box is relatively straightforward. Modifying the newer style dialog box is much more difficult, and not recommended. Not only does it have a different size and layout than the old style, but its dimensions and the positions of its controls change every time it is resized by the user. If the BIF_RETURNONLYFSDIRS flag is set in the <b>ulFlags</b> member of the <a href="https://docs.microsoft.com/windows/desktop/api/shlobj_core/ns-shlobj_core-browseinfoa">BROWSEINFO</a> structure, the <b>OK</b> button remains enabled for "\\server" items, as well as "\\server\share" and directory items. However, if the user selects a "\\server" item, passing the PIDL returned by <b>SHBrowseForFolder</b> to <a href="https://docs.microsoft.com/windows/desktop/api/shlobj_core/nf-shlobj_core-shgetpathfromidlista">SHGetPathFromIDList</a> fails. <h3><a id="Custom_Filtering"></a><a id="custom_filtering"></a><a id="CUSTOM_FILTERING"></a>Custom Filtering</h3> As of Windows XP, <b>SHBrowseForFolder</b> supports custom filtering on the contents of the dialog box. To create a custom filter, follow these steps.</para>
/// <para></para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shbrowseforfolderw#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("SHELL32.dll", ExactSpelling = true, EntryPoint = "SHBrowseForFolderW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.1.2600")]
internal static extern unsafe winmdroot.UI.Shell.Common.ITEMIDLIST* SHBrowseForFolder(winmdroot.UI.Shell.BROWSEINFOW* lpbi);
/// <inheritdoc cref="SHCreateItemFromParsingName(winmdroot.Foundation.PCWSTR, winmdroot.System.Com.IBindCtx*, global::System.Guid*, void**)"/>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe winmdroot.Foundation.HRESULT SHCreateItemFromParsingName(string pszPath, winmdroot.System.Com.IBindCtx* pbc, in global::System.Guid riid, out void* ppv)
{
fixed (void** ppvLocal = &ppv)
{
fixed (global::System.Guid* riidLocal = &riid)
{
fixed (char* pszPathLocal = pszPath)
{
winmdroot.Foundation.HRESULT __result = PInvoke.SHCreateItemFromParsingName(pszPathLocal, pbc, riidLocal, ppvLocal);
return __result;
}
}
}
}
/// <summary>Creates and initializes a Shell item object from a parsing name.</summary>
/// <param name="pszPath">
/// <para>Type: <b>PCWSTR</b> A pointer to a display name.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-shcreateitemfromparsingname#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="pbc">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/api/objidl/nn-objidl-ibindctx">IBindCtx</a>*</b> Optional. A pointer to a bind context used to pass parameters as inputs and outputs to the parsing function. These passed parameters are often specific to the data source and are documented by the data source owners. For example, the file system data source accepts the name being parsed (as a <a href="https://docs.microsoft.com/windows/desktop/api/minwinbase/ns-minwinbase-win32_find_dataa">WIN32_FIND_DATA</a> structure), using the <a href="https://docs.microsoft.com/windows/desktop/shell/str-constants">STR_FILE_SYS_BIND_DATA</a> bind context parameter.</para>
/// <para><a href="https://docs.microsoft.com/windows/desktop/shell/str-constants">STR_PARSE_PREFER_FOLDER_BROWSING</a> can be passed to indicate that URLs are parsed using the file system data source when possible. Construct a bind context object using <a href="https://docs.microsoft.com/windows/desktop/api/objbase/nf-objbase-createbindctx">CreateBindCtx</a> and populate the values using <a href="https://docs.microsoft.com/windows/desktop/api/objidl/nf-objidl-ibindctx-registerobjectparam">IBindCtx::RegisterObjectParam</a>. See <b>Bind Context String Keys</b> for a complete list of these. See the <a href="https://docs.microsoft.com/previous-versions/windows/desktop/legacy/dd940368(v=vs.85)">Parsing With Parameters Sample</a> for an example of the use of this parameter.</para>
/// <para>If no data is being passed to or received from the parsing function, this value can be <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-shcreateitemfromparsingname#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="riid">
/// <para>Type: <b>REFIID</b> A reference to the IID of the interface to retrieve through <i>ppv</i>, typically <b>IID_IShellItem</b> or <b>IID_IShellItem2</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-shcreateitemfromparsingname#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="ppv">
/// <para>Type: <b>void**</b> When this method returns successfully, contains the interface pointer requested in <i>riid</i>. This is typically <a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ishellitem">IShellItem</a> or <a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ishellitem2">IShellItem2</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-shcreateitemfromparsingname#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HRESULT</b> If this function succeeds, it returns <b>S_OK</b>. Otherwise, it returns an <b>HRESULT</b> error code.</para>
/// </returns>
/// <remarks>We recommend that you use the <b>IID_PPV_ARGS</b> macro, defined in Objbase.h, to package the <i>riid</i> and <i>ppv</i> parameters. This macro provides the correct <b>IID</b> based on the interface pointed to by the value in <i>ppv</i>, which eliminates the possibility of a coding error in <i>riid</i> that could lead to unexpected results.</remarks>
[DllImport("SHELL32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows6.0.6000")]
internal static extern unsafe winmdroot.Foundation.HRESULT SHCreateItemFromParsingName(winmdroot.Foundation.PCWSTR pszPath, [Optional] winmdroot.System.Com.IBindCtx* pbc, global::System.Guid* riid, void** ppv);
/// <inheritdoc cref="SHCreateShellItem(winmdroot.UI.Shell.Common.ITEMIDLIST*, winmdroot.UI.Shell.IShellFolder*, winmdroot.UI.Shell.Common.ITEMIDLIST*, winmdroot.UI.Shell.IShellItem**)"/>
[SupportedOSPlatform("windows5.1.2600")]
internal static unsafe winmdroot.Foundation.HRESULT SHCreateShellItem(winmdroot.UI.Shell.Common.ITEMIDLIST? pidlParent, winmdroot.UI.Shell.IShellFolder* psfParent, in winmdroot.UI.Shell.Common.ITEMIDLIST pidl, winmdroot.UI.Shell.IShellItem** ppsi)
{
fixed (winmdroot.UI.Shell.Common.ITEMIDLIST* pidlLocal = &pidl)
{
winmdroot.UI.Shell.Common.ITEMIDLIST pidlParentLocal = pidlParent ?? default(winmdroot.UI.Shell.Common.ITEMIDLIST);
winmdroot.Foundation.HRESULT __result = PInvoke.SHCreateShellItem(pidlParent.HasValue ? &pidlParentLocal : null, psfParent, pidlLocal, ppsi);
return __result;
}
}
/// <summary>Creates an IShellItem object.</summary>
/// <param name="pidlParent">
/// <para>Type: <b>PCIDLIST_ABSOLUTE</b> A PIDL to the parent. This value can be <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shcreateshellitem#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="psfParent">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ishellfolder">IShellFolder</a>*</b> A pointer to the parent <a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ishellfolder">IShellFolder</a>. This value can be <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shcreateshellitem#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="pidl">
/// <para>Type: <b>PCUITEMID_CHILD</b> A PIDL to the requested item. If parent information is not included in <i>pidlParent</i> or <i>psfParent</i>, this must be an absolute PIDL.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shcreateshellitem#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="ppsi">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ishellitem">IShellItem</a>**</b> When this method returns, contains the interface pointer to the new <a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ishellitem">IShellItem</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shcreateshellitem#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HRESULT</b> If this function succeeds, it returns <b>S_OK</b>. Otherwise, it returns an <b>HRESULT</b> error code.</para>
/// </returns>
/// <remarks>
/// <para><b>SHCreateShellItem</b> creates an object that represents a Shell namespace item. The caller must provide parent information in <i>pidlParent</i> or <i>psfParent</i>; alternatively, the caller can provide an absolute IDList in the <i>pidl</i> parameter. There are three valid calling patterns for this function:</para>
/// <para></para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shcreateshellitem#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("SHELL32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.1.2600")]
internal static extern unsafe winmdroot.Foundation.HRESULT SHCreateShellItem([Optional] winmdroot.UI.Shell.Common.ITEMIDLIST* pidlParent, [Optional] winmdroot.UI.Shell.IShellFolder* psfParent, winmdroot.UI.Shell.Common.ITEMIDLIST* pidl, winmdroot.UI.Shell.IShellItem** ppsi);
/// <inheritdoc cref="ShellExecute(winmdroot.Foundation.HWND, winmdroot.Foundation.PCWSTR, winmdroot.Foundation.PCWSTR, winmdroot.Foundation.PCWSTR, winmdroot.Foundation.PCWSTR, winmdroot.UI.WindowsAndMessaging.SHOW_WINDOW_CMD)"/>
[SupportedOSPlatform("windows5.1.2600")]
internal static unsafe winmdroot.Foundation.HINSTANCE ShellExecute(winmdroot.Foundation.HWND hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, winmdroot.UI.WindowsAndMessaging.SHOW_WINDOW_CMD nShowCmd)
{
fixed (char* lpDirectoryLocal = lpDirectory)
{
fixed (char* lpParametersLocal = lpParameters)
{
fixed (char* lpFileLocal = lpFile)
{
fixed (char* lpOperationLocal = lpOperation)
{
winmdroot.Foundation.HINSTANCE __result = PInvoke.ShellExecute(hwnd, lpOperationLocal, lpFileLocal, lpParametersLocal, lpDirectoryLocal, nShowCmd);
return __result;
}
}
}
}
}
/// <summary>Performs an operation on a specified file. (ShellExecuteW)</summary>
/// <param name="hwnd">
/// <para>Type: <b>HWND</b> A handle to the parent window used for displaying a UI or error messages. This value can be <b>NULL</b> if the operation is not associated with a window.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shellapi/nf-shellapi-shellexecutew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpOperation">
/// <para>Type: <b>LPCTSTR</b> A pointer to a <b>null</b>-terminated string, referred to in this case as a <i>verb</i>, that specifies the action to be performed. The set of available verbs depends on the particular file or folder. Generally, the actions available from an object's shortcut menu are available verbs. The following verbs are commonly used:</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shellapi/nf-shellapi-shellexecutew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpFile">
/// <para>Type: <b>LPCTSTR</b> A pointer to a <b>null</b>-terminated string that specifies the file or object on which to execute the specified verb. To specify a Shell namespace object, pass the fully qualified parse name. Note that not all verbs are supported on all objects. For example, not all document types support the "print" verb. If a relative path is used for the <i>lpDirectory</i> parameter do not use a relative path for <i>lpFile</i>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shellapi/nf-shellapi-shellexecutew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpParameters">
/// <para>Type: <b>LPCTSTR</b> If <i>lpFile</i> specifies an executable file, this parameter is a pointer to a <b>null</b>-terminated string that specifies the parameters to be passed to the application. The format of this string is determined by the verb that is to be invoked. If <i>lpFile</i> specifies a document file, <i>lpParameters</i> should be <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shellapi/nf-shellapi-shellexecutew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lpDirectory">
/// <para>Type: <b>LPCTSTR</b> A pointer to a <b>null</b>-terminated string that specifies the default (working) directory for the action. If this value is <b>NULL</b>, the current working directory is used. If a relative path is provided at <i>lpFile</i>, do not use a relative path for <i>lpDirectory</i>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shellapi/nf-shellapi-shellexecutew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nShowCmd">
/// <para>Type: <b>INT</b> The flags that specify how an application is to be displayed when it is opened. If <i>lpFile</i> specifies a document file, the flag is simply passed to the associated application. It is up to the application to decide how to handle it. It can be any of the values that can be specified in the <i>nCmdShow</i> parameter for the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-showwindow">ShowWindow</a> function.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shellapi/nf-shellapi-shellexecutew#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HINSTANCE</b> If the function succeeds, it returns a value greater than 32. If the function fails, it returns an error value that indicates the cause of the failure. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however. It can be cast only to an <b>INT_PTR</b> and compared to either 32 or the following error codes below. </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>
/// <para>Because <b>ShellExecute</b> can delegate execution to Shell extensions (data sources, context menu handlers, verb implementations) that are activated using Component Object Model (COM), COM should be initialized before <b>ShellExecute</b> is called. Some Shell extensions require the COM single-threaded apartment (STA) type. In that case, COM should be initialized as shown here:</para>
/// <para></para>
/// <para>This doc was truncated.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shellapi/nf-shellapi-shellexecutew#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("SHELL32.dll", ExactSpelling = true, EntryPoint = "ShellExecuteW"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.1.2600")]
internal static extern winmdroot.Foundation.HINSTANCE ShellExecute(winmdroot.Foundation.HWND hwnd, winmdroot.Foundation.PCWSTR lpOperation, winmdroot.Foundation.PCWSTR lpFile, winmdroot.Foundation.PCWSTR lpParameters, winmdroot.Foundation.PCWSTR lpDirectory, winmdroot.UI.WindowsAndMessaging.SHOW_WINDOW_CMD nShowCmd);
/// <inheritdoc cref="SHGetKnownFolderPath(global::System.Guid*, winmdroot.UI.Shell.KNOWN_FOLDER_FLAG, winmdroot.Foundation.HANDLE, winmdroot.Foundation.PWSTR*)"/>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe winmdroot.Foundation.HRESULT SHGetKnownFolderPath(in global::System.Guid rfid, winmdroot.UI.Shell.KNOWN_FOLDER_FLAG dwFlags, winmdroot.Foundation.HANDLE hToken, out winmdroot.Foundation.PWSTR ppszPath)
{
fixed (winmdroot.Foundation.PWSTR* ppszPathLocal = &ppszPath)
{
fixed (global::System.Guid* rfidLocal = &rfid)
{
winmdroot.Foundation.HRESULT __result = PInvoke.SHGetKnownFolderPath(rfidLocal, dwFlags, hToken, ppszPathLocal);
return __result;
}
}
}
/// <summary>Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID.</summary>
/// <param name="rfid">
/// <para>Type: <b>REFKNOWNFOLDERID</b> A reference to the <a href="https://docs.microsoft.com/windows/desktop/shell/knownfolderid">KNOWNFOLDERID</a> that identifies the folder.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="dwFlags">
/// <para>Type: <b>DWORD</b> Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the <a href="https://docs.microsoft.com/windows/desktop/api/shlobj_core/ne-shlobj_core-known_folder_flag">KNOWN_FOLDER_FLAG</a> values.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hToken">
/// <para>Type: <b>HANDLE</b> An <a href="https://docs.microsoft.com/windows/desktop/SecAuthZ/access-tokens">access token</a> that represents a particular user. If this parameter is <b>NULL</b>, which is the most common usage, the function requests the known folder for the current user.</para>
/// <para>Request a specific user's folder by passing the <i>hToken</i> of that user. This is typically done in the context of a service that has sufficient privileges to retrieve the token of a given user. That token must be opened with <a href="https://docs.microsoft.com/windows/desktop/SecAuthZ/access-rights-for-access-token-objects">TOKEN_QUERY</a> and <a href="https://docs.microsoft.com/windows/desktop/SecAuthZ/access-rights-for-access-token-objects">TOKEN_IMPERSONATE</a> rights. In some cases, you also need to include <a href="https://docs.microsoft.com/windows/desktop/SecAuthZ/access-rights-for-access-token-objects">TOKEN_DUPLICATE</a>. In addition to passing the user's <i>hToken</i>, the registry hive of that specific user must be mounted. See <a href="https://docs.microsoft.com/windows/desktop/SecAuthZ/access-control">Access Control</a> for further discussion of access control issues. Assigning the <i>hToken</i> parameter a value of -1 indicates the Default User. This allows clients of <b>SHGetKnownFolderPath</b> to find folder locations (such as the <b>Desktop</b> folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special folders such as <b>Documents</b> and <b>Desktop</b>. Any items added to the Default User folder also appear in any new user account. Note that access to the Default User folders requires administrator privileges.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="ppszPath">
/// <para>Type: <b>PWSTR*</b> When this method returns, contains the address of a pointer to a null-terminated Unicode string that specifies the path of the known folder. The calling process is responsible for freeing this resource once it is no longer needed by calling <a href="https://docs.microsoft.com/windows/desktop/api/combaseapi/nf-combaseapi-cotaskmemfree">CoTaskMemFree</a>, whether <b>SHGetKnownFolderPath</b> succeeds or not. The returned path does not include a trailing backslash. For example, "C:\Users" is returned rather than "C:\Users\\".</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HRESULT</b> Returns S_OK if successful, or an error value otherwise, including the following: </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>This function replaces <a href="https://docs.microsoft.com/windows/desktop/api/shlobj_core/nf-shlobj_core-shgetfolderpatha">SHGetFolderPath</a>. That older function is now simply a wrapper for <b>SHGetKnownFolderPath</b>.</remarks>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe winmdroot.Foundation.HRESULT SHGetKnownFolderPath(global::System.Guid* rfid, winmdroot.UI.Shell.KNOWN_FOLDER_FLAG dwFlags, winmdroot.Foundation.HANDLE hToken, winmdroot.Foundation.PWSTR* ppszPath)
{
winmdroot.Foundation.HRESULT __retVal = LocalExternFunction(rfid, (uint)dwFlags, hToken, ppszPath);
return __retVal;
[DllImport("SHELL32.dll", ExactSpelling = true, EntryPoint = "SHGetKnownFolderPath"),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
static extern unsafe winmdroot.Foundation.HRESULT LocalExternFunction(global::System.Guid* rfid, uint dwFlags, winmdroot.Foundation.HANDLE hToken, winmdroot.Foundation.PWSTR* ppszPath);
}
/// <inheritdoc cref="SHGetPathFromIDListEx(winmdroot.UI.Shell.Common.ITEMIDLIST*, winmdroot.Foundation.PWSTR, uint, winmdroot.UI.Shell.GPFIDL_FLAGS)"/>
[SupportedOSPlatform("windows6.0.6000")]
internal static unsafe winmdroot.Foundation.BOOL SHGetPathFromIDListEx(in winmdroot.UI.Shell.Common.ITEMIDLIST pidl, winmdroot.Foundation.PWSTR pszPath, uint cchPath, winmdroot.UI.Shell.GPFIDL_FLAGS uOpts)
{
fixed (winmdroot.UI.Shell.Common.ITEMIDLIST* pidlLocal = &pidl)
{
winmdroot.Foundation.BOOL __result = PInvoke.SHGetPathFromIDListEx(pidlLocal, pszPath, cchPath, uOpts);
return __result;
}
}
/// <summary>Converts an item identifier list to a file system path. This function extends SHGetPathFromIDList by allowing you to set the initial size of the string buffer and declare the options below.</summary>
/// <param name="pidl">
/// <para>Type: <b>PCIDLIST_ABSOLUTE</b> A pointer to an item identifier list that specifies a file or directory location relative to the root of the namespace (the desktop).</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetpathfromidlistex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="pszPath">
/// <para>Type: <b>PWSTR</b> When this function is called it is passed a null-terminated, Unicode buffer to receive the file system path. This buffer is of size <i>cchPath</i>.</para>
/// <para>When this function returns, contains the address of a null-terminated, Unicode buffer that contains the file system path. This buffer is of size <i>cchPath</i>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetpathfromidlistex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="cchPath">
/// <para>Type: <b>DWORD</b> The size of the buffer pointed to by <i>pszPath</i>, in characters.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetpathfromidlistex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="uOpts">
/// <para>Type: <b>GPFIDL_FLAGS</b> These flags determine the type of path returned.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetpathfromidlistex#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>BOOL</b> Returns <b>TRUE</b> if successful; otherwise, <b>FALSE</b>.</para>
/// </returns>
/// <remarks>
/// <para>Except for UNC printer names, if the location specified by the <i>pidl</i> parameter is not part of the file system, this function fails. If the <i>pidl</i> parameter specifies a shortcut, the <i>pszPath</i> contains the path to the shortcut, not to the shortcut's target.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetpathfromidlistex#">Read more on docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("SHELL32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows6.0.6000")]
internal static extern unsafe winmdroot.Foundation.BOOL SHGetPathFromIDListEx(winmdroot.UI.Shell.Common.ITEMIDLIST* pidl, winmdroot.Foundation.PWSTR pszPath, uint cchPath, winmdroot.UI.Shell.GPFIDL_FLAGS uOpts);
/// <inheritdoc cref="SHGetSpecialFolderLocation(winmdroot.Foundation.HWND, int, winmdroot.UI.Shell.Common.ITEMIDLIST**)"/>
[SupportedOSPlatform("windows5.0")]
internal static unsafe winmdroot.Foundation.HRESULT SHGetSpecialFolderLocation(int csidl, out winmdroot.UI.Shell.Common.ITEMIDLIST* ppidl)
{
fixed (winmdroot.UI.Shell.Common.ITEMIDLIST** ppidlLocal = &ppidl)
{
winmdroot.Foundation.HRESULT __result = PInvoke.SHGetSpecialFolderLocation(default, csidl, ppidlLocal);
return __result;
}
}
/// <summary>SHGetSpecialFolderLocation is not supported and may be altered or unavailable in the future. Instead, use SHGetFolderLocation.</summary>
/// <param name="hwnd">
/// <para>Type: <b>HWND</b> Reserved.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetspecialfolderlocation#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="csidl">
/// <para>Type: <b>int</b> A <a href="https://docs.microsoft.com/windows/desktop/shell/csidl">CSIDL</a> value that identifies the folder of interest.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetspecialfolderlocation#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="ppidl">
/// <para>Type: <b>PIDLIST_ABSOLUTE*</b> A PIDL specifying the folder's location relative to the root of the namespace (the desktop). It is the responsibility of the calling application to free the returned IDList by using <a href="https://docs.microsoft.com/windows/desktop/api/combaseapi/nf-combaseapi-cotaskmemfree">CoTaskMemFree</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetspecialfolderlocation#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HRESULT</b> If this function succeeds, it returns <b>S_OK</b>. Otherwise, it returns an <b>HRESULT</b> error code.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetspecialfolderlocation">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("SHELL32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.0")]
internal static extern unsafe winmdroot.Foundation.HRESULT SHGetSpecialFolderLocation(winmdroot.Foundation.HWND hwnd, int csidl, winmdroot.UI.Shell.Common.ITEMIDLIST** ppidl);
/// <inheritdoc cref="SHParseDisplayName(winmdroot.Foundation.PCWSTR, winmdroot.System.Com.IBindCtx*, winmdroot.UI.Shell.Common.ITEMIDLIST**, uint, uint*)"/>
[SupportedOSPlatform("windows5.1.2600")]
internal static unsafe winmdroot.Foundation.HRESULT SHParseDisplayName(string pszName, winmdroot.System.Com.IBindCtx* pbc, out winmdroot.UI.Shell.Common.ITEMIDLIST* ppidl, uint sfgaoIn, uint* psfgaoOut)
{
fixed (winmdroot.UI.Shell.Common.ITEMIDLIST** ppidlLocal = &ppidl)
{
fixed (char* pszNameLocal = pszName)
{
winmdroot.Foundation.HRESULT __result = PInvoke.SHParseDisplayName(pszNameLocal, pbc, ppidlLocal, sfgaoIn, psfgaoOut);
return __result;
}
}
}
/// <summary>Translates a Shell namespace object's display name into an item identifier list and returns the attributes of the object. This function is the preferred method to convert a string to a pointer to an item identifier list (PIDL).</summary>
/// <param name="pszName">
/// <para>Type: <b>LPCWSTR</b> A pointer to a zero-terminated wide string that contains the display name to parse.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shparsedisplayname#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="pbc">
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/api/objidl/nn-objidl-ibindctx">IBindCtx</a>*</b> A bind context that controls the parsing operation. This parameter is normally set to <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shparsedisplayname#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="ppidl">
/// <para>Type: <b>PIDLIST_ABSOLUTE*</b> The address of a pointer to a variable of type <a href="https://docs.microsoft.com/windows/desktop/api/shtypes/ns-shtypes-itemidlist">ITEMIDLIST</a> that receives the item identifier list for the object. If an error occurs, then this parameter is set to <b>NULL</b>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shparsedisplayname#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="sfgaoIn">
/// <para>Type: <b>SFGAOF</b> A <b>ULONG</b> value that specifies the attributes to query. To query for one or more attributes, initialize this parameter with the flags that represent the attributes of interest. For a list of available SFGAO flags, see <a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nf-shobjidl_core-ishellfolder-getattributesof">IShellFolder::GetAttributesOf</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shparsedisplayname#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="psfgaoOut">
/// <para>Type: <b>SFGAOF*</b> A pointer to a <b>ULONG</b>. On return, those attributes that are true for the object and were requested in <i>sfgaoIn</i> are set. An object's attribute flags can be zero or a combination of SFGAO flags. For a list of available SFGAO flags, see <a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nf-shobjidl_core-ishellfolder-getattributesof">IShellFolder::GetAttributesOf</a>.</para>
/// <para><see href="https://learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shparsedisplayname#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>HRESULT</b> If this function succeeds, it returns <b>S_OK</b>. Otherwise, it returns an <b>HRESULT</b> error code.</para>
/// </returns>
/// <remarks>You should call this function from a background thread. Failure to do so could cause the UI to stop responding.</remarks>
[DllImport("SHELL32.dll", ExactSpelling = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
[SupportedOSPlatform("windows5.1.2600")]
internal static extern unsafe winmdroot.Foundation.HRESULT SHParseDisplayName(winmdroot.Foundation.PCWSTR pszName, [Optional] winmdroot.System.Com.IBindCtx* pbc, winmdroot.UI.Shell.Common.ITEMIDLIST** ppidl, uint sfgaoIn, [Optional] uint* psfgaoOut);
}
}
|