返回列表 发帖
本帖最后由 jyswjjgdwtdtj 于 2024-9-21 13:34 编辑
  1. $oshell=new-object -comobject shell.application
  2. $s="C:\Users\xx\Desktop\1.docx"
  3. $ofolder=$oshell.NameSpace(17)
  4. $ofolderitem=$ofolder.ParseName($s)
  5. $ss=$ofolderitem.ExtendedProperty("DocArthor")
  6. $ss.GetType()
  7. #IsPublic IsSerial Name                                     BaseType
  8. #-------- -------- ----                                     --------
  9. #True     True     String[]                                 System.Array
  10. $ss.length
  11. #1
复制代码

用c#鼓捣半天总是报错
  1.     [DispId(1610809345)]
  2.     [return: MarshalAs(UnmanagedType.Struct)]
  3.     object ExtendedProperty([In][MarshalAs(UnmanagedType.BStr)] string bstrPropName);
复制代码
vbs的ubound函数可以正常使用至于为什么会是个string()可能是允许一个文档有多个作者吧
你好

TOP

回复 8# flashercs


   我试图这样
  1.         String s = s = @"C:\Users\xx\Desktop\1.docx";
  2.         var ofolder =(new Shell32.Shell()).NameSpace(17);
  3.         var ofolderitem = (Shell32.FolderItem2)ofolder.ParseName(s);
  4.         var ss = ofolderitem.ExtendedProperty("DocAuthor");
复制代码
你好

TOP

本帖最后由 jyswjjgdwtdtj 于 2024-9-22 21:53 编辑

不用猜了
  1. public static VariantType VarType(object VarName) {
  2.     if (VarName == null) {
  3.         return VariantType.Object;
  4.     }
  5.     return VarTypeFromComType(VarName.GetType());
  6. }
  7. internal static VariantType VarTypeFromComType(Type typ) {
  8.     if ((object) typ == null) {
  9.         return VariantType.Object;
  10.     }
  11.     if (typ.IsArray) {
  12.         typ = typ.GetElementType();
  13.         if (typ.IsArray) {
  14.             return (VariantType) 8201;
  15.         }
  16.         VariantType variantType = VarTypeFromComType(typ);
  17.         if ((variantType & VariantType.Array) != 0) {
  18.             return (VariantType) 8201;
  19.         }
  20.         return variantType | VariantType.Array;
  21.     }
  22.     if (typ.IsEnum) {
  23.         typ = Enum.GetUnderlyingType(typ);
  24.     }
  25.     if ((object) typ == null) {
  26.         return VariantType.Empty;
  27.     }
  28.     switch (Type.GetTypeCode(typ)) {
  29.         case TypeCode.String:
  30.             return VariantType.String;
  31.         case TypeCode.Int32:
  32.             return VariantType.Integer;
  33.         case TypeCode.Int16:
  34.             return VariantType.Short;
  35.         case TypeCode.Int64:
  36.             return VariantType.Long;
  37.         case TypeCode.Single:
  38.             return VariantType.Single;
  39.         case TypeCode.Double:
  40.             return VariantType.Double;
  41.         case TypeCode.DateTime:
  42.             return VariantType.Date;
  43.         case TypeCode.Boolean:
  44.             return VariantType.Boolean;
  45.         case TypeCode.Decimal:
  46.             return VariantType.Decimal;
  47.         case TypeCode.Byte:
  48.             return VariantType.Byte;
  49.         case TypeCode.Char:
  50.             return VariantType.Char;
  51.         case TypeCode.DBNull:
  52.             return VariantType.Null;
  53.         default:
  54.             if ((object) typ == typeof(Missing) || (object) typ == typeof(Exception) || typ.IsSubclassOf(typeof(Exception))) {
  55.                 return VariantType.Error;
  56.             }
  57.             if (typ.IsValueType) {
  58.                 return VariantType.UserDefinedType;
  59.             }
  60.             return VariantType.Object;
  61.     }
  62. }
  63. public enum VariantType {
  64.     Empty = 0, Null = 1, Short = 2, Integer = 3, Single = 4, Double = 5, Currency = 6, Date = 7, String = 8, Object = 9, Error = 10, Boolean = 11, Variant = 12, DataObject = 13, Decimal = 14, Byte = 17, Char = 18, Long = 20, UserDefinedType = 36, Array = 8192
  65. }
复制代码
这里的short对应vbsint interger对于vbslong
你好

TOP

返回列表