• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# PropVariant类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PropVariant的典型用法代码示例。如果您正苦于以下问题:C# PropVariant类的具体用法?C# PropVariant怎么用?C# PropVariant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PropVariant类属于命名空间,在下文中一共展示了PropVariant类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FromPropVariant

 public static ManagedPropVariant FromPropVariant(PropVariant propVariant)
 {
     // Do a bitwise copy from the PropVariant that was passed in.
     ManagedPropVariant managedPropVariant = new ManagedPropVariant();
     UnsafeNativeMethods.CopyFromPropVariant(out managedPropVariant, ref propVariant);
     return managedPropVariant;
 }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:7,代码来源:ISettingsProvider.cs


示例2: CreateLeafCondition

        /// <summary>
        /// Creates a leaf condition node that represents a comparison of property value and constant value. 
        /// </summary>
        /// <param name="propertyName">The name of a property to be compared, or null for an unspecified property. 
        /// The locale name of the leaf node is LOCALE_NAME_USER_DEFAULT.</param>
        /// <param name="value">The constant value against which the property value should be compared.</param>
        /// <param name="operation">Specific condition to be used when comparing the actual value and the expected value of the given property</param>
        /// <returns>SearchCondition based on the given parameters</returns>
        /// <remarks>
        /// The search will only work for files that are indexed, as well as the specific properties are indexed. To find 
        /// the properties that are indexed, look for the specific property's property description and 
        /// <see cref="P:Microsoft.WindowsAPICodePack.Shell.PropertySystem.ShellPropertyDescription.TypeFlags"/> property for IsQueryable flag.
        /// </remarks>
        public static SearchCondition CreateLeafCondition(string propertyName, string value, SearchConditionOperation operation)
        {
            PropVariant propVar = new PropVariant();
            propVar.SetString(value);

            return CreateLeafCondition(propertyName, propVar, null, operation);
        }
开发者ID:TanyaTPG,项目名称:Log2Console,代码行数:20,代码来源:SearchConditionFactory.cs


示例3: CreateLeafCondition

 /// <summary>
 /// Creates a leaf condition node that represents a comparison of property value and constant value. 
 /// </summary>
 /// <param name="propertyName">The name of a property to be compared, or null for an unspecified property. 
 /// The locale name of the leaf node is LOCALE_NAME_USER_DEFAULT.</param>
 /// <param name="value">The constant value against which the property value should be compared.</param>
 /// <param name="operation">Specific condition to be used when comparing the actual value and the expected value of the given property</param>
 /// <returns>SearchCondition based on the given parameters</returns>
 /// <remarks>
 /// The search will only work for files that are indexed, as well as the specific properties are indexed. To find 
 /// the properties that are indexed, look for the specific property's property description and 
 /// <see cref="P:Microsoft.WindowsAPICodePack.Shell.PropertySystem.ShellPropertyDescription.TypeFlags"/> property for IsQueryable flag.
 /// </remarks>
 public static SearchCondition CreateLeafCondition(string propertyName, string value, SearchConditionOperation operation)
 {
     using (PropVariant propVar = new PropVariant(value))
     {
         return CreateLeafCondition(propertyName, propVar, null, operation);
     }
 }
开发者ID:Corillian,项目名称:Windows-API-Code-Pack-1.1,代码行数:20,代码来源:SearchConditionFactory.cs


示例4: UpdateProperty

        public virtual int UpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue)
        {
            Command command = ParentCommandManager.Get((CommandId)commandId);
            if (command == null)
            {
                return NullCommandUpdateProperty(commandId, ref key, currentValue, out newValue);
            }

            try
            {
                newValue = new PropVariant();
                command.GetPropVariant(key, currentValue, ref newValue);

                if (newValue.IsNull())
                {
                    Trace.Fail("Didn't property update property for " + PropertyKeys.GetName(key) + " on command " + ((CommandId)commandId).ToString());

                    newValue = PropVariant.FromObject(currentValue.PropVariant.Value);
                }
            }
            catch (Exception ex)
            {
                Trace.Fail("Exception in UpdateProperty for " + PropertyKeys.GetName(key) + " on command " + commandId + ": " + ex);
                newValue = PropVariant.FromObject(currentValue.PropVariant.Value);
            }

            return HRESULT.S_OK;
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:28,代码来源:GenericCommandHandler.cs


示例5: SearchCondition

        internal SearchCondition(ICondition nativeSearchCondition)
        {
            if (nativeSearchCondition == null)
            {
                throw new ArgumentNullException("nativeSearchCondition");
            }

            NativeSearchCondition = nativeSearchCondition;

            HResult hr = NativeSearchCondition.GetConditionType(out conditionType);

            if (!CoreErrorHelper.Succeeded(hr))
            {
                throw new ShellException(hr);
            }

            if (ConditionType == SearchConditionType.Leaf)
            {
                using (PropVariant propVar = new PropVariant())
                {
                    hr = NativeSearchCondition.GetComparisonInfo(out canonicalName, out conditionOperation, propVar);

                    if (!CoreErrorHelper.Succeeded(hr))
                    {
                        throw new ShellException(hr);
                    }

                    PropertyValue = propVar.Value.ToString();
                }
            }
        }
开发者ID:Corillian,项目名称:Windows-API-Code-Pack-1.1,代码行数:31,代码来源:SearchCondition.cs


示例6: InstallShortcut

        private void InstallShortcut(String shortcutPath)
        {
            // Find the path to the current executable
            String exePath = Process.GetCurrentProcess().MainModule.FileName;
            IShellLinkW newShortcut = (IShellLinkW)new CShellLink();

            // Create a shortcut to the exe
            ShellHelpers.ErrorHelper.VerifySucceeded(newShortcut.SetPath(exePath));
            ShellHelpers.ErrorHelper.VerifySucceeded(newShortcut.SetArguments(""));

            // Open the shortcut property store, set the AppUserModelId property
            IPropertyStore newShortcutProperties = (IPropertyStore)newShortcut;

            using (PropVariant appId = new PropVariant(APP_ID))
            {
                ShellHelpers.ErrorHelper.VerifySucceeded(
                    newShortcutProperties.SetValue(SystemProperties.System.AppUserModel.ID, appId));
                ShellHelpers.ErrorHelper.VerifySucceeded(newShortcutProperties.Commit());
            }

            // Commit the shortcut to disk
            IPersistFile newShortcutSave = (IPersistFile)newShortcut;

            ShellHelpers.ErrorHelper.VerifySucceeded(newShortcutSave.Save(shortcutPath, true));
        }
开发者ID:Xifax,项目名称:NagMePlenty,代码行数:25,代码来源:ShortcutHelper.cs


示例7: ToPropVariant

 public static PropVariant ToPropVariant(ManagedPropVariant managedPropVariant)
 {
     // Do a bitwise copy from the ManagedPropVariant that was passed in.
     PropVariant propVariant = new PropVariant();
     UnsafeNativeMethods.CopyToPropVariant(out propVariant, ref managedPropVariant);
     return propVariant;
 }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:7,代码来源:ISettingsProvider.cs


示例8: FromString

            public static PropVariant FromString(string str)
            {
                var pv = new PropVariant() {
                    variantType = 31,  // VT_LPWSTR
                    pointerValue = Marshal.StringToCoTaskMemUni(str),
                };

                return pv;
            }
开发者ID:skaryshev,项目名称:Squirrel.Windows,代码行数:9,代码来源:ShellFile.cs


示例9: GetPropVariant

 public override void GetPropVariant(PropertyKey key, PropVariantRef currentValue, ref PropVariant value)
 {
     if (key == PropertyKeys.ContextAvailable)
     {
         value.SetUInt((uint)ContextAvailability);
     }
     else
         base.GetPropVariant(key, currentValue, ref value);
 }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:9,代码来源:ContextAvailabilityCommand.cs


示例10: FromObjectNullTest

        public void FromObjectNullTest()
        {
            using (PropVariant pv = new PropVariant())
            {

                Assert.True(pv.IsNullOrEmpty);
                Assert.Equal(VarEnum.VT_EMPTY, pv.VarType);
                Assert.Null(pv.Value);
            }
        }
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:10,代码来源:PropVariantTests.cs


示例11: SetWindowProperty

        internal static void SetWindowProperty(IntPtr hwnd, PropertyKey propkey, string value)
        {
            // Get the IPropertyStore for the given window handle
            IPropertyStore propStore = GetWindowPropertyStore(hwnd);

            // Set the value
            PropVariant pv = new PropVariant();
            propStore.SetValue(ref propkey, ref pv);

            // Dispose the IPropertyStore and PropVariant
            Marshal.ReleaseComObject(propStore);
            pv.Clear();
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:13,代码来源:ShellHelper.cs


示例12: ListOrExtract

        private static void ListOrExtract(string archiveName, uint level)
        {
            using (SevenZipFormat Format = new SevenZipFormat(SevenZipDllPath))
            {
            IInArchive Archive = Format.CreateInArchive(SevenZipFormat.GetClassIdFromKnownFormat(KnownSevenZipFormat.Zip));
            if (Archive == null)
                return;

            try
            {
                using (InStreamWrapper ArchiveStream = new InStreamWrapper(File.OpenRead(archiveName)))
                {
                    IArchiveOpenCallback OpenCallback = new ArchiveOpenCallback();

                    // 32k CheckPos is not enough for some 7z archive formats
                    ulong CheckPos = 128 * 1024;
                    if (Archive.Open(ArchiveStream, ref CheckPos, OpenCallback) != 0)
                        //ShowHelp();
                    if (!Directory.Exists(@"tmp_dir"))
                        Directory.CreateDirectory(@"tmp_dir");

                    //Console.WriteLine(archiveName);

                    uint Count = Archive.GetNumberOfItems();
                    for (uint I = 0; I < Count; I++)
                    {
                        PropVariant Name = new PropVariant();
                        Archive.GetProperty(I, ItemPropId.kpidPath, ref Name);
                        string FileName = (string)Name.GetObject();
                        Program.f1.label1.Text = FileName;
                        Application.DoEvents();
                        for(int i = 0; i < level; i++)
                            Console.Write("\t");
                        Console.Write(FileName + "\n");
                        FileName += level;
                        Archive.Extract(new uint[] { I }, 1, 0, new ArchiveExtractCallback(I, FileName));
                        Program.Determine_Parser(new System.IO.FileInfo("tmp_dir//" + FileName), level);
                    }
                }
            }
            finally
            {
                Marshal.ReleaseComObject(Archive);
                Directory.Delete(@"tmp_dir", true);
            }
            }
        }
开发者ID:mtotheikle,项目名称:EWU-OIT-SSN-Scanner,代码行数:47,代码来源:SevenZipFunctions.cs


示例13: GetValue

        public HRESULT GetValue(ref PropertyKey key, out PropVariant value)
        {
            if (key == RibbonProperties.Label)
            {
                if ((_label == null) || (_label.Trim() == string.Empty))
                {
                    value = PropVariant.Empty;
                }
                else
                {
                    value = PropVariant.FromObject(_label);
                }
                return HRESULT.S_OK;
            }

            if (key == RibbonProperties.LabelDescription)
            {
                if ((_labelDescription == null) || (_labelDescription.Trim() == string.Empty))
                {
                    value = PropVariant.Empty;
                }
                else
                {
                    value = PropVariant.FromObject(_labelDescription);
                }
                return HRESULT.S_OK;
            }

            if (key == RibbonProperties.Pinned)
            {
                if (_pinned.HasValue)
                {
                    value = PropVariant.FromObject(_pinned.Value);
                }
                else
                {
                    value = PropVariant.Empty;
                }
                return HRESULT.S_OK;
            }

            Debug.WriteLine(string.Format("Class {0} does not support property: {1}.", GetType().ToString(), RibbonProperties.GetPropertyKeyName(ref key)));

            value = PropVariant.Empty;
            return HRESULT.E_NOTIMPL;
        }
开发者ID:taozhengbo,项目名称:sdrsharp_experimental,代码行数:46,代码来源:RecentItemsPropertySet.cs


示例14: GetValue

        public HRESULT GetValue(ref PropertyKey key, out PropVariant value)
        {
            if (key == RibbonProperties.CommandID)
            {
                if (_commandID.HasValue)
                {
                    value = PropVariant.FromObject(_commandID.Value);
                }
                else
                {
                    value = PropVariant.Empty;
                }
                return HRESULT.S_OK;
            }

            if (key == RibbonProperties.CommandType)
            {
                if (_commandType.HasValue)
                {
                    value = PropVariant.FromObject((uint)_commandType.Value);
                }
                else
                {
                    value = PropVariant.Empty;
                }
                return HRESULT.S_OK;
            }

            if (key == RibbonProperties.CategoryID)
            {
                if (_categoryID.HasValue)
                {
                    value = PropVariant.FromObject(_categoryID.Value);
                }
                else
                {
                    value = PropVariant.Empty;
                }
                return HRESULT.S_OK;
            }

            Debug.WriteLine(string.Format("Class {0} does not support property: {1}.", GetType(), RibbonProperties.GetPropertyKeyName(ref key)));

            value = PropVariant.Empty;
            return HRESULT.E_NOTIMPL;
        }
开发者ID:taozhengbo,项目名称:sdrsharp_experimental,代码行数:46,代码来源:GalleryCommandPropertySet.cs


示例15: CreateImagePropVariant

        public static void CreateImagePropVariant(Image image, out PropVariant pv)
        {
            try
            {
                pv = new PropVariant();

                // Note that the missing image is a 32x32 png.
                if (image == null)
                    image = Images.Missing_LargeImage;

                pv.SetIUnknown(CreateImage(((Bitmap)image).GetHbitmap(), ImageCreationOptions.Transfer));
            }
            catch (Exception ex)
            {
                Trace.Fail("Failed to create image PropVariant: " + ex);
                pv = new PropVariant();
            }
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:18,代码来源:RibbonHelper.cs


示例16: InstallShortcut

        private static void InstallShortcut(string shortcutPath)
        {
            var exePath = Process.GetCurrentProcess().MainModule.FileName;
            var newShortcut = (IShellLinkW)new CShellLink();

            ErrorHelper.VerifySucceeded(newShortcut.SetPath(exePath));
            ErrorHelper.VerifySucceeded(newShortcut.SetArguments(""));

            var newShortcutProperties = (IPropertyStore)newShortcut;

            using (var appId = new PropVariant(Toast.AppId))
            {
                ErrorHelper.VerifySucceeded(newShortcutProperties.SetValue(SystemProperties.System.AppUserModel.ID, appId));
                ErrorHelper.VerifySucceeded(newShortcutProperties.Commit());
            }

            var newShortcutSave = (IPersistFile)newShortcut;

            ErrorHelper.VerifySucceeded(newShortcutSave.Save(shortcutPath, true));
        }
开发者ID:Sinwee,项目名称:KanColleViewer,代码行数:20,代码来源:Windows8Notifier.cs


示例17: GetSetting

        public ManagedPropVariant GetSetting(ContentEditorSetting setting)
        {
            switch (setting)
            {
                case ContentEditorSetting.MshtmlOptionKeyPath:
                    return ManagedPropVariant.FromPropVariant(GetMshtmlOptionKeyPath());

                case ContentEditorSetting.ImageDefaultSize:
                    return ManagedPropVariant.FromPropVariant(GetImageDefaultSize());

                case ContentEditorSetting.Language:
                    return ManagedPropVariant.FromPropVariant(GetLanguage());

                default:
                    Debug.Fail("Unexpected ContentEditorSetting!");
                    PropVariant propVariant = new PropVariant();
                    propVariant.SetError();
                    return ManagedPropVariant.FromPropVariant(propVariant);
            }
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:20,代码来源:OpenLiveWriterSettingsProvider.cs


示例18: InstallShortcut

        private static void InstallShortcut(string exePath, string shortcutPath, string appId)
        {
            IShellLinkW newShortcut = (IShellLinkW)new CShellLink();

            // Create a shortcut to the exe
            ShellHelpers.ErrorHelper.VerifySucceeded(newShortcut.SetPath(exePath));
            ShellHelpers.ErrorHelper.VerifySucceeded(newShortcut.SetArguments(""));

            // Open the shortcut property store, set the AppUserModelId property
            IPropertyStore newShortcutProperties = (IPropertyStore)newShortcut;

            using (PropVariant appIdProperty = new PropVariant(appId))
            {
                ShellHelpers.ErrorHelper.VerifySucceeded(newShortcutProperties.SetValue(SystemProperties.System.AppUserModel.ID, appIdProperty));
                ShellHelpers.ErrorHelper.VerifySucceeded(newShortcutProperties.Commit());
            }

            // Commit the shortcut to disk
            IPersistFile newShortcutSave = (IPersistFile)newShortcut;

            ShellHelpers.ErrorHelper.VerifySucceeded(newShortcutSave.Save(shortcutPath, true));
        }
开发者ID:PlagueHO,项目名称:toaster,代码行数:22,代码来源:Program.cs


示例19: SearchCondition

        internal SearchCondition(ICondition nativeSearchCondition)
        {
            if (nativeSearchCondition == null) throw new ArgumentNullException("nativeSearchCondition");

            NativeSearchCondition = nativeSearchCondition;

            HResult hr = NativeSearchCondition.GetConditionType(out conditionType);

            if (hr != HResult.S_OK) return;

            if (ConditionType == SearchConditionType.Leaf)
            {
                using (var propVar = new PropVariant())
                {
                    hr = NativeSearchCondition.GetComparisonInfo(out canonicalName, out conditionOperation, propVar);

                    if (hr != HResult.S_OK) return;

                    PropertyValue = propVar.Value.ToString();
                }
            }
        }
开发者ID:Gainedge,项目名称:BetterExplorer,代码行数:22,代码来源:SearchCondition.cs


示例20: Main

        static void Main(string[] args)
        {
            if (args.Length < 2)
              {
            ShowHelp();
            return;
              }

              try
              {
            string ArchiveName;
            uint FileNumber = 0xFFFFFFFF;
            bool Extract;

            switch (args[0])
            {
              case "l":
            ArchiveName = args[1];
            Extract = false;
            break;
              case "e":
            ArchiveName = args[1];
            Extract = true;
            if ((args.Length < 3) || !uint.TryParse(args[2], out FileNumber))
            {
              ShowHelp();
              return;
            }
            break;
              default:
            ShowHelp();
            return;
            }

            using (SevenZipFormat Format = new SevenZipFormat(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "7z.dll")))
            {
              IInArchive Archive = Format.CreateInArchive(SevenZipFormat.GetClassIdFromKnownFormat(KnownSevenZipFormat.Zip));
              if (Archive == null)
              {
            ShowHelp();
            return;
              }

              try
              {
            using (InStreamWrapper ArchiveStream = new InStreamWrapper(File.OpenRead(ArchiveName)))
            {
              ulong CheckPos = 32 * 1024;
              if (Archive.Open(ArchiveStream, ref CheckPos, null) != 0)
                ShowHelp();

              Console.Write("Archive: ");
              Console.WriteLine(ArchiveName);

              if (Extract)
              {
                PropVariant Name = new PropVariant();
                Archive.GetProperty(FileNumber, ItemPropId.kpidPath, ref Name);
                string FileName = (string)Name.GetObject();

                Console.Write("Extracting: ");
                Console.Write(FileName);
                Console.Write(' ');

                Archive.Extract(new uint[] { FileNumber }, 1, 0, new ArchiveCallback(FileNumber, FileName));
              }
              else
              {
                Console.WriteLine("List:");
                uint Count = Archive.GetNumberOfItems();
                for (uint I = 0; I < Count; I++)
                {
                  PropVariant Name = new PropVariant();
                  Archive.GetProperty(I, ItemPropId.kpidPath, ref Name);
                  Console.Write(I);
                  Console.Write(' ');
                  Console.WriteLine(Name.GetObject());
                }
              }
            }
              }
              finally
              {
            Marshal.ReleaseComObject(Archive);
              }
            }
              }
              catch (Exception e)
              {
            Console.Write("Error: ");
            Console.WriteLine(e.Message);
              }
        }
开发者ID:GiladShoham,项目名称:RedRock,代码行数:93,代码来源:Program.cs



注:本文中的PropVariant类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PropagationFlags类代码示例发布时间:2022-05-24
下一篇:
C# PropDef类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap