; Example 1:
Obj := Filexpro( A_AhkPath,, "System.FileFRN" )
DriveGet, Serial, Serial, % SubStr(A_AhkPath, 1, 2)
MsgBox % Format( "{:08X}-{:016X}", Serial, obj["System.FileFRN"] )  ; File ID

; Example 2:
Obj := Filexpro(A_WinDir . "\Media\chimes.wav",, "System.Audio.ChannelCount" 
                         , "System.Audio.Compression"
                         , "System.Audio.EncodingBitrate"
                         , "System.Audio.Format"
                         , "System.Audio.IsVariableBitRate"
                         , "System.Audio.PeakValue"
                         , "System.Audio.SampleRate"
                         , "System.Audio.SampleSize"
                         , "System.Audio.StreamName"
                         , "System.Audio.StreamNumber" )
MsgBox % obj["System.Audio.EncodingBitrate"]

; Example 3:
mp4 := Filexpro("D:\电影视频\测试.mp4",, "System.Video.FrameWidth", "System.Video.FrameHeight")
MsgBox % "视频尺寸:" mp4["System.Video.FrameWidth"] "x" mp4["System.Video.FrameHeight"]
Return

; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=59882
Filexpro( sFile := "", Kind := "", P* ) {  ; v.90 By SKAN on D1CC @ goo.gl/jyXFo9
    Local
    Static xDetails 

    If ( sFile = "" ) {  ; Deinit static variable
        xDetails := ""
        Return
    }

    fex := {}, _FileExt := "" 

    Loop, Files, % RTrim(sfile,"\*/."), DF 
    {
        If not FileExist( sFile:=A_LoopFileLongPath )
            Return

        SplitPath, sFile, _FileExt, _Dir, _Ext, _File, _Drv

        If ( p[p.length()] = "xInfo" ) {  ; Last parameter is xInfo 
            p.Pop()  ; Delete parameter
            fex.SetCapacity(11)  ; Make room for Extra info
            fex["_Attrib"] := A_LoopFileAttrib
            fex["_Dir"] := _Dir
            fex["_Drv"] := _Drv
            fex["_Ext"] := _Ext
            fex["_File"] := _File
            fex["_File.Ext"] := _FileExt
            fex["_FilePath"] := sFile
            fex["_FileSize"] := A_LoopFileSize
            fex["_FileTimeA"] := A_LoopFileTimeAccessed
            fex["_FileTimeC"] := A_LoopFileTimeCreated
            fex["_FileTimeM"] := A_LoopFileTimeModified
        }
        Break
    }

    If Not ( _FileExt )  ; Filepath not resolved
        Return

    objShl := ComObjCreate("Shell.Application")
    objDir := objShl.NameSpace(_Dir) 
    objItm := objDir.ParseName(_FileExt) 

    If ( VarSetCapacity(xDetails) = 0 ) {  ; Init static variable
        i:=-1,  xDetails:={},  xDetails.SetCapacity(309)
        While ( i++ < 309 )
            xDetails[ objDir.GetDetailsOf(0,i) ] := i
        xDetails.Delete("")
    }

    If ( Kind and Kind <> objDir.GetDetailsOf(objItm,11) )  ; File isn't desired kind  
        Return

    i:=0,  nParams:=p.Count(),  fex.SetCapacity(nParams + 11) 

    While ( i++ < nParams ) {
        Prop := p[i]

        If ( (Dot:=InStr(Prop,".")) and (Prop:=(Dot=1 ? "System":"") . Prop) ) {
            fex[Prop] := objItm.ExtendedProperty(Prop)
            Continue 
        }

        If ( PropNum := xDetails[Prop] ) > -1
        {
            fex[Prop] := ObjDir.GetDetailsOf(objItm,PropNum)
            Continue 
        }  
    }
    fex.SetCapacity(-1)
    Return fex  
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。