Beispiel #1
0
        public static void ActivateApplication(string appUserModelId, bool waitForExit = false)
        {
            ApplicationActivationManager appActiveManager = new ApplicationActivationManager();
            uint pid;
            CommonHRESULTValues result = (CommonHRESULTValues)appActiveManager.ActivateApplication(appUserModelId, null, ActivateOptions.None, out pid);

            if (result == CommonHRESULTValues.S_OK)
            {
                if (waitForExit)
                {
                    Process process = Process.GetProcessById((int)pid);
                    process.WaitForExit();
                }
            }
            else
            {
                throw new Exception("ActivateForFile failed error code: " + result);
            }
        }
Beispiel #2
0
        public static void ActivateForFile(string appUserModelId, string filePullPath, string verb, bool waitForExit = false)
        {
            ApplicationActivationManager appActiveManager = new ApplicationActivationManager();//Class not registered
            IShellItemArray array = GetShellItemArray(filePullPath);

            uint pid;
            CommonHRESULTValues result = (CommonHRESULTValues)appActiveManager.ActivateForFile(appUserModelId, array, verb, out pid);

            if (result == CommonHRESULTValues.S_OK)
            {
                if (waitForExit)
                {
                    Process process = Process.GetProcessById((int)pid);
                    process.WaitForExit();
                }
            }
            else
            {
                throw new Exception("ActivateForFile failed error code: " + result);
            }
        }