Ejemplo n.º 1
0
		public long EnumProperties(IntPtr enumerator) => 0x80004001L; // Not implemented

		public int GetProperty(uint index, PropID propId, ref PropVariant value)
		{
			var file = fileNames[(int)index];
			switch (propId)
			{
				case PropID.Attributes:
					value.VarType = VarEnum.VT_UI4;
					value.IntValue = (int)(Directory.Exists(file) ? FileAttributes.Directory : FileAttributes.Archive);
					break;
				case PropID.LastWriteTime:
					value.VarType = VarEnum.VT_FILETIME;
					value.LongValue = new FileInfo(file).LastWriteTime.ToFileTime();
					break;
				case PropID.Path:
					value.VarType = VarEnum.VT_BSTR;
					value.Value = Marshal.StringToBSTR(file.Substring(basePath.Length));
					break;
				case PropID.IsDirectory:
					value.VarType = VarEnum.VT_BOOL;
					value.LongValue = Convert.ToByte(Directory.Exists(file));
					break;
				case PropID.IsAnti:
					value.VarType = VarEnum.VT_BOOL;
					value.LongValue = 0;
					break;
				case PropID.Size:
					value.VarType = VarEnum.VT_UI8;
					value.LongValue = new FileInfo(file).Length;
					break;
			}

			return 0;
		}
Ejemplo n.º 2
0
		private static extern int PropVariantClear(ref PropVariant pvar);