Пример #1
0
        static void ActivateFile(string appUserModelId, string path)
        {
            var appActiveManager = new ApplicationActivationManager();
            var items            = SHCreateShellItemArrayFromParsingName(path);

            appActiveManager.ActivateForFile(appUserModelId, items, "Open", out uint _);
        }
Пример #2
0
        public static void Activate(string appId, string file, string verb)
        {
            ApplicationActivationManager appActiveManager = new ApplicationActivationManager();//Class not registered
            IShellItem pShellItem = SafeNativeMethods.SHCreateItemFromParsingNameIShellItem(file, IntPtr.Zero, typeof(IShellItem).GUID);

            if (pShellItem != null)
            {
                if (SafeNativeMethods.SHCreateShellItemArrayFromShellItem(pShellItem, typeof(IShellItemArray).GUID, out IShellItemArray pShellItemArray) == (int)HResult.Ok)
                {
                    appActiveManager.ActivateForFile(appId, pShellItemArray, verb, out _);
                }
            }
        }
 private static void Main(string[] args)
 {
     ApplicationActivationManager appActiveManager = new ApplicationActivationManager();//Class not registered
     uint pid;
     appActiveManager.ActivateApplication("2c123c17-8b21-4eb8-8b7f-fdc35c8b7718_n2533ggrncqjt!App", null, ActivateOptions.None, out pid);
     Console.WriteLine("Activated");
     Console.ReadLine();
     
     IShellItemArray array = GetShellItemArray(@"C:\temp\somefile.xyz");
     appActiveManager.ActivateForFile("2c123c17-8b21-4eb8-8b7f-fdc35c8b7718_n2533ggrncqjt!App", array, "Open",
         out pid);
     Console.WriteLine("Activated for file");
     Console.ReadLine();
 }
Пример #4
0
        public override Process Start()
        {
            IntPtr shellItem  = IntPtr.Zero;
            Guid   IShellItem = new Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe");

            SHCreateItemFromParsingName(this.File.FilePath, IntPtr.Zero, IShellItem, out shellItem);
            Guid   IShellItemArray = new Guid("B63EA76D-1F85-456F-A19C-48159EFA858B");
            IntPtr shellItemArray  = IntPtr.Zero;

            SHCreateShellItemArrayFromShellItem(shellItem, IShellItemArray, out shellItemArray);
            ApplicationActivationManager aam = new ApplicationActivationManager();
            uint procId;

            aam.ActivateForFile(this.AppUserModelID, shellItemArray, "open", out procId);
            return(Process.GetProcessById((int)procId));
        }