当前位置: 首页>>代码示例>>C#>>正文


C# PropVariant.Dispose方法代码示例

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


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

示例1: WndProc


//.........这里部分代码省略.........
                      }

                      nmlv.item.pszText = val.Trim();
                    } else {
                      var temp = currentItem;
                      var isi2 = (IShellItem2)temp.ComInterface;
                      var guid = new Guid(InterfaceGuids.IPropertyStore);
                      IPropertyStore propStore = null;
                      isi2.GetPropertyStore(GetPropertyStoreOptions.FastPropertiesOnly, ref guid, out propStore);
                      PROPERTYKEY pk = currentCollumn.pkey;
                      var pvar = new PropVariant();
                      if (propStore != null && propStore.GetValue(ref pk, pvar) == HResult.S_OK) {
                        if (pvar.Value == null) {
                          if (this.IconSize == 16) {
                            this.SmallImageList.EnqueueSubitemsGet(Tuple.Create(nmlv.item.iItem, nmlv.item.iSubItem, pk));
                          } else {
                            this.LargeImageList.EnqueueSubitemsGet(Tuple.Create(nmlv.item.iItem, nmlv.item.iSubItem, pk));
                          }
                        } else {
                          var val = String.Empty;
                          if (currentCollumn.CollumnType == typeof(DateTime))
                            val = ((DateTime)pvar.Value).ToString(Thread.CurrentThread.CurrentUICulture);
                          else if (currentCollumn.CollumnType == typeof(Int64))
                            val =
                                $"{Math.Ceiling(Convert.ToDouble(pvar.Value.ToString()) / 1024):# ### ### ##0} KB";
                          else if (currentCollumn.CollumnType == typeof(PerceivedType))
                            val = ((PerceivedType)pvar.Value).ToString();
                          else if (currentCollumn.CollumnType == typeof(FileAttributes))
                            val = this.GetFilePropertiesString(pvar.Value);
                          else
                            val = pvar.Value.ToString();

                          nmlv.item.pszText = val.Trim();
                          pvar.Dispose();
                        }
                      }
                    }
                  }

                  Marshal.StructureToPtr(nmlv, m.LParam, false);
                }
              }

              if ((nmlv.item.mask & LVIF.LVIF_COLUMNS) == LVIF.LVIF_COLUMNS && this.CurrentFolder?.ParsingName.Equals(KnownFolders.Computer.ParsingName) == false) {
                int[] columns = null;
                var refGuidPDL = typeof(IPropertyDescriptionList).GUID;
                var refGuidPD = typeof(IPropertyDescription).GUID;
                var iShellItem2 = (IShellItem2)currentItem.ComInterface;

                var ptrPDL = IntPtr.Zero;
                iShellItem2.GetPropertyDescriptionList(SpecialProperties.PropListTileInfo, ref refGuidPDL,
                        out ptrPDL);
                IPropertyDescriptionList propertyDescriptionList = (IPropertyDescriptionList)Marshal.GetObjectForIUnknown(ptrPDL);
                var descriptionsCount = 0u;
                propertyDescriptionList.GetCount(out descriptionsCount);
                nmlv.item.cColumns = (int)descriptionsCount;
                columns = new int[nmlv.item.cColumns];
                Marshal.Copy(nmlv.item.puColumns, columns, 0, nmlv.item.cColumns);
                for (uint i = 0; i < descriptionsCount; i++) {
                  IPropertyDescription propertyDescription = null;
                  propertyDescriptionList.GetAt(i, ref refGuidPD, out propertyDescription);
                  PROPERTYKEY pkey;
                  propertyDescription.GetPropertyKey(out pkey);
                  Collumns column = null;
                  if (this.AllAvailableColumns.TryGetValue(pkey, out column)) {
                    columns[i] = column.Index;
开发者ID:Gainedge,项目名称:BetterExplorer,代码行数:67,代码来源:ShellViewEx.cs


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