using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class Shell32
{
/// One or more of the following flags used to support design mode, debugging, and testing scenarios.
[PInvokeData("shobjidl_core.h", MSDNShortId = "NF:shobjidl_core.IApplicationActivationManager.ActivateApplication")]
[Flags]
public enum ACTIVATEOPTIONS
{
/// No flags are set.
AO_NONE = 0,
///
/// The app is being activated for design mode, so it can't create its normal window. The creation of the app's window must be
/// done by design tools that load the necessary components by communicating with a designer-specified service on the site chain
/// established through the activation manager. Note that this means that the splash screen seen during regular activations
/// won't be seen.
/// Note that you must enable debug mode on the app's package to succesfully use design mode.
///
AO_DESIGNMODE = 0x1,
/// Do not display an error dialog if the app fails to activate.
AO_NOERRORUI = 0x2,
///
/// Do not display the app's splash screen when the app is activated. You must enable debug mode on the app's package when you
/// use this flag; otherwise, the PLM will terminate the app after a few seconds.
///
AO_NOSPLASHSCREEN = 0x4,
/// The application is being activated in prelaunch mode. This value is supported starting in Windows 10.
AO_PRELAUNCH = 0x2000000
}
///
/// Provides methods which activate Windows Store apps for the Launch, File, and Protocol extensions. You will normally use this
/// interface in debuggers and design tools.
///
///
/// When to Implement
///
/// Do not implement this interface yourself. Windows provides an implementation as part of the CApplicationActivationManager class.
/// To get an instance of this class, call CoCreateInstance with the CLSID_ApplicationActivationManager class ID.
///
/// Usage notes
///
/// An IApplicationActivationManager object creates a thread in its host process to serve any activated event arguments
/// objects (LaunchActivatedEventArgs, FileActivatedEventArgs, and ProtocolActivatedEventArgs) that are passed to the app. If the
/// calling process is long-lived, you can create this object in-proc, based on the assumption that the event arguments will exist
/// long enough for the target app to use them. However, if the calling process is spawned only to launch the target app, it should
/// create the IApplicationActivationManager object out-of-process, by using CLSCTX_LOCAL_SERVER. This causes the object to
/// be created in a Dllhost.exe instance that automatically manages the object's lifetime based on outstanding references to the
/// activated event argument objects.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-iapplicationactivationmanager
[PInvokeData("shobjidl_core.h", MSDNShortId = "NN:shobjidl_core.IApplicationActivationManager")]
[ComImport, Guid("2e941141-7f97-4756-ba1d-9decde894a3d"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(ApplicationActivationManager))]
public interface IApplicationActivationManager
{
/// Activates the specified Windows Store app for the generic launch contract (Windows.Launch) in the current session.
/// The application user model ID of the Windows Store app.
/// A pointer to an optional, app-specific, argument string.
///
/// One or more of the following flags used to support design mode, debugging, and testing scenarios.
/// AO_NONE (0x00000000)
/// No flags are set.
/// AO_DESIGNMODE (0x00000001)
///
/// The app is being activated for design mode, so it can't create its normal window. The creation of the app's window must be
/// done by design tools that load the necessary components by communicating with a designer-specified service on the site chain
/// established through the activation manager. Note that this means that the splash screen seen during regular activations
/// won't be seen.
///
/// Note that you must enable debug mode on the app's package to succesfully use design mode.
/// AO_NOERRORUI (0x00000002)
/// Do not display an error dialog if the app fails to activate.
/// AO_NOSPLASHSCREEN (0x00000004)
///
/// Do not display the app's splash screen when the app is activated. You must enable debug mode on the app's package when you
/// use this flag; otherwise, the PLM will terminate the app after a few seconds.
///
/// AO_PRELAUNCH (0x2000000)
/// The application is being activated in prelaunch mode. This value is supported starting in Windows 10.
///
///
/// A pointer to a value that, when this method returns successfully, receives the process ID of the app instance that fulfils
/// this contract.
///
/// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationactivationmanager-activateapplication
// HRESULT ActivateApplication( LPCWSTR appUserModelId, LPCWSTR arguments, ACTIVATEOPTIONS options, DWORD *processId );
void ActivateApplication([MarshalAs(UnmanagedType.LPWStr)] string appUserModelId, [MarshalAs(UnmanagedType.LPWStr)] string arguments, ACTIVATEOPTIONS options, out uint processId);
/// Activates the specified Windows Store app for the file contract (Windows.File).
/// The application user model ID of the Windows Store app.
///
/// A pointer to an array of Shell items, each representing a file. This value is converted to a VectorView of StorageItem
/// objects that is passed to the app through FileActivatedEventArgs.
///
/// The verb being applied to the file or files specified by itemArray.
///
/// A pointer to a value that, when this method returns successfully, receives the process ID of the app instance that fulfils
/// this contract.
///
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationactivationmanager-activateforfile
// HRESULT ActivateForFile( LPCWSTR appUserModelId, IShellItemArray *itemArray, LPCWSTR verb, DWORD *processId );
void ActivateForFile([MarshalAs(UnmanagedType.LPWStr)] string appUserModelId, IShellItemArray itemArray, [MarshalAs(UnmanagedType.LPWStr)] string verb, out uint processId);
/// Activates the specified Windows Store app for the protocol contract (Windows.Protocol).
/// The application user model ID of the Windows Store app.
///
/// A pointer to an array of a single Shell item. The first item in the array is converted into a Uri object that is passed to
/// the app through ProtocolActivatedEventArgs. Any items in the array except for the first element are ignored.
///
///
/// A pointer to a value that, when this method returns successfully, receives the process ID of the app instance that fulfils
/// this contract.
///
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iapplicationactivationmanager-activateforprotocol
// HRESULT ActivateForProtocol( LPCWSTR appUserModelId, IShellItemArray *itemArray, DWORD *processId );
void ActivateForProtocol([MarshalAs(UnmanagedType.LPWStr)] string appUserModelId, IShellItemArray itemArray, out uint processId);
}
/// CLSID_ApplicationActivationManager
[PInvokeData("shobjidl_core.h", MSDNShortId = "NN:shobjidl_core.IDesktopWallpaper")]
[ComImport, Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C"), ClassInterface(ClassInterfaceType.None)]
public class ApplicationActivationManager { }
}
}