Beispiel #1
0
        public object GetShellRepresentation()
        {
            IShellLinkW shellLink = (IShellLinkW)new CShellLink();
            IPropertyStore propertyStore = (IPropertyStore)shellLink;
            PropVariant propVariant = new PropVariant();

            if (IsSeparator)
            {
                propVariant.SetValue(true);

                HResult setValueResult = propertyStore.SetValue(ref PropertyKey.PKEY_AppUserModel_IsDestListSeparator, ref propVariant);
                setValueResult.ThrowIf();

                propVariant.Clear();
                propVariant.Dispose();
            }
            else
            {
                HResult setPathResult = shellLink.SetPath(Path);
                setPathResult.ThrowIf();

                if (!String.IsNullOrEmpty(IconLocation))
                {
                    HResult setIconLocationResult = shellLink.SetIconLocation(IconLocation, IconIndex);
                    setIconLocationResult.ThrowIf();
                }
                if (!String.IsNullOrEmpty(Arguments))
                {
                    HResult setArgumentsResult = shellLink.SetArguments(Arguments);
                    setArgumentsResult.ThrowIf();
                }
                if (!String.IsNullOrEmpty(WorkingDirectory))
                {
                    HResult setWorkingDirectoryResult = shellLink.SetWorkingDirectory(WorkingDirectory);
                    setWorkingDirectoryResult.ThrowIf();
                }

                HResult setShowCmdResult = shellLink.SetShowCmd((uint)ShowCommand);
                setShowCmdResult.ThrowIf();

                propVariant.SetValue(Title);

                HResult setValueResult = propertyStore.SetValue(ref PropertyKey.PKEY_Title, ref propVariant);
                setValueResult.ThrowIf();

                propVariant.Clear();
                propVariant.Dispose();
            }

            HResult commitResult = propertyStore.Commit();
            commitResult.ThrowIf();

            return shellLink;
        }
Beispiel #2
0
 public static extern HResult PropVariantClear(ref PropVariant pvar);