Example #1
0
        /// <summary>
        /// Sets the window's application id by its window handle.
        /// </summary>
        /// <param name="hwnd">The window handle.</param>
        /// <param name="appId">The application id.</param>
        public static void SetWindowAppId(IntPtr hwnd, string appId)
        {
            IPropertyStore propStore = InternalGetWindowPropertyStore(hwnd);

            PropVariant pv = new PropVariant();
            pv.SetValue(appId);
            propStore.SetValue(ref PropertyKey.PKEY_AppUserModel_ID, ref pv);

            Marshal.ReleaseComObject(propStore);
        }
Example #2
0
 private static extern int PropVariantClear(ref PropVariant pvar);
Example #3
0
        /// <summary>
        /// Gets the shell <b>IShellLink</b> representation
        /// of the object.
        /// </summary>
        /// <returns>An <b>IShellLink</b> up-cast to <b>object</b>.</returns>
        public object GetShellRepresentation()
        {
            IShellLinkW shellLink = (IShellLinkW)new CShellLink();

            IPropertyStore propertyStore = (IPropertyStore)shellLink;
            PropVariant propVariant = new PropVariant();

            if (IsSeparator)
            {
                propVariant.SetValue(true);
                propertyStore.SetValue(ref PropertyKey.PKEY_AppUserModel_IsDestListSeparator, ref propVariant);
                propVariant.Clear();
            }
            else
            {
                shellLink.SetPath(Path);

                if (!String.IsNullOrEmpty(IconLocation))
                    shellLink.SetIconLocation(IconLocation, IconIndex);
                if (!String.IsNullOrEmpty(Arguments))
                    shellLink.SetArguments(Arguments);
                if (!String.IsNullOrEmpty(WorkingDirectory))
                    shellLink.SetWorkingDirectory(WorkingDirectory);
                shellLink.SetShowCmd((uint)ShowCommand);

                propVariant.SetValue(Title);
                propertyStore.SetValue(ref PropertyKey.PKEY_Title, ref propVariant);
                propVariant.Clear();
            }

            propertyStore.Commit();

            return shellLink;
        }
Example #4
0
 private static extern int PropVariantClear(ref PropVariant pvar);