#cs
功能:获取媒体文件的相关信息
目的:学习对ListView的相关操作(感谢3mile的热情帮助)
GUICtrlCreateListView();GUICtrlCreateListViewItem();GUICtrlSetData();GUICtrlDelete();_GUICtrlListView_DeleteAllItems();
_GUICtrlListView_DeleteItem;_GUICtrlListView_DeleteItemsSelected();
_GUICtrlListView_AddArray() 把数组添加到ListView中;
_GUICtrlListView_AddColumn() 为ListView添加新的 列,可设置列的宽度
_GUICtrlListView_AddItem() 为ListView添加新的 项
_GUICtrlListView_SetItemSelected() 设置哪个列表项被选择,注意列表项序号是从 0 开始
_GUICtrlListView_GetSelectedIndicates() 获得被选列表项的 索引号
_GUICtrlListView_SetItem() 编辑列表项的某列数据,注意 列 也是 从 0 开始
_GUICtrlListView_SetItemText() 编辑列表项的某列数据
_GUICtrlListView_GetItemText() 获取列表项某列的文本内容
_GUICtrlListView_DeleteItem() 删除列表项
_GUICtrlListView_DeleteAllItems() 删除所有列表项
_GUICtrlListView_DeleteItemsSelected() 删除被选择的列表项
_GUICtrlListView_GetView()和_GUICtrlListView_SetView不是很懂!以何种方式查看listview?可通过后者具体设置,有0 到 4 方式的选择
等同于 _GUICtrlListView_GetViewDetails;_GUICtrlListView_GetViewLarge();_GUICtrlListView_GetViewSmall;_GUICtrlListView_GetViewList
_GUICtrlListView_BeginUpdate()和_GUICtrlListView_EndUpdate()
_GUICtrlListView_HideColumn 隐藏列
1。如果该$FileList=_FileListToArray($Target,'*.*',1)语句换成$FileList=_FileListToArray($Target,'*.avi',1)
,就只是获取AVI类型媒体文件的信息;
2。将ListViewItem项拖动到用GUICtrlSetState(-1, $GUI_DROPACCEPTED)设置的编辑框或输入框控件上;
3. 注意该 $sRL=_GetInfoArray($Target&$Filelist[$i])语句的路径问题,我就是忘了$Target了,所以没获得任何信息;
#ce
#include<Array.au3>
#include <file.au3>
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>;GUICtrlSetState(-1,$GUI_DROPACCEPTED)需要
#include <GuiImageList.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Dim $Target="F:\家庭录象";要查看的媒体文件所在目录
Dim $FileList[1];用于接收文件夹内的文件的数组
Dim $i,$Number=1;用于计数的变量
Dim $ListView1;第1个ListView变量
Dim $Item[1];ListView的项变量
Dim $iSubItem
Dim $exStyles
$Form1_1 = GUICreate("显示同一文件夹下多个AVI的媒体信息", 787, 401, 210, 154)
$ListView1 = GUICtrlCreateListView("序号 |文件格式 |视频格式 |音频格式 |音频编码 |视频编码 |总码率 "& _
"|视频码率 |音频码率 |视频分辨率 |视频分辨率 ", 0, 32, 785, 241)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, $exStyles)
GUISetState(@SW_SHOW, $Form1_1)
$hImage = _GUIImageList_Create()
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($ListView1, 0xFF0000, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($ListView1, 0x00FF00, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($ListView1, 0x0000FF, 16, 16))
_GUICtrlListView_SetImageList($ListView1, $hImage, 1)
$FileList=_FileListToArray($Target,'*.avi',1);将指定类型的媒体类型文件送到数组中,也可以是 *.*
If IsArray($FileList)=0 Then;送入到数组失败处理
MsgBox(0,'','目标文件夹里没有文件')
Exit
Else;送入到数组成功处理,显示获得的相关信息
;_GUICtrlListView_BeginUpdate($ListView1);开始更新ListView,不使用他ListView会逐条项的更新,而不是等ListView完全更新后再显示
For $i=1 To $FileList[0] Step 1
$sRL=_GetInfoArray($Target&$Filelist[$i])
;_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1));设置$ListView之前,先清除它里面的所有项
GUICtrlCreateListViewItem($Number&"|" & $sRL[0]&"|"&$sRL[1]&"|"&$sRL[2]&"|"&$sRL[3]&"|"&$sRL[4] & _
"|"&$sRL[5]&"|"&$sRL[6]&"|"&$sRL[7]&"|"&$sRL[8]&"|"&$sRL[9],$ListView1)
;$Item & $i =GUICtrlCreateListViewItem($Number&"|" & $sRL[0]&"|"&$sRL[1]&"|"&$sRL[2]&"|"&$sRL[3]&"|"&$sRL[4] & _
; "|"&$sRL[5]&"|"&$sRL[6]&"|"&$sRL[7]&"|"&$sRL[8]&"|"&$sRL[9],$ListView1)
$Number +=1
Sleep(1000)
;MsgBox(0,'',$sRL[0]&"|"&$sRL[1]&"|"&$sRL[2]&"|"&$sRL[3]&"|"&$sRL[4]&"|"&$sRL[5]&"|"&$sRL[6]&"|"&$sRL[7]&"|"&$sRL[8]&"|"&$sRL[9])
;_ArrayDisplay($sRL)
;MsgBox(0,'',$FileList[$i])
Next
;_GUICtrlListView_EndUpdate($ListView1);停止ListView的更新
EndIf
; ;把listview的项拖动到用GUICtrlSetState(-1, $GUI_DROPACCEPTED)设置的输入框或编辑框控件内
While 1
Sleep(100)
WEnd
Func _GetInfoArray($sMediaFile)
Local $sRL[1]
$sDLL = DllOpen("MediaInfo.dll")
$sHandle = DllCall($sDLL, "ptr", "MediaInfo_New")
$Open_Result = DllCall($sDLL, "int", "MediaInfo_Open", "ptr", $sHandle[0], "wstr", $sMediaFile)
;获取文件格式
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;%Format/String%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle[0], "int", 0)
$sRL[0] = $Inform[0]
;获取视频格式
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;%Video_Format_List%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle[0], "int", 0)
_ArrayAdd($sRL, $Inform[0])
;获取音频格式
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;%Audio_Format_List%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle[0], "int", 0)
_ArrayAdd($sRL, $Inform[0])
;获取音频编码
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;%Audio_Codec_List%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle[0], "int", 0)
_ArrayAdd($sRL, $Inform[0])
;获取视频编码
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;%Video_Codec_List%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle[0], "int", 0)
_ArrayAdd($sRL, $Inform[0])
;获取总码率
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;%BitRate/String%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle[0], "int", 0)
_ArrayAdd($sRL, $Inform[0])
;获取视频码率
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "Video;%BitRate/String%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle[0], "int", 0)
_ArrayAdd($sRL, $Inform[0])
;获取音频码率
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "Audio;%BitRate/String%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle[0], "int", 0)
_ArrayAdd($sRL, $Inform[0])
;获取视频分辨率
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "Video;%Width%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle[0], "int", 0)
$sWidth = $Inform[0]
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "Video;%Height%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle[0], "int", 0)
$sHigh = $Inform[0]
If $sHigh <> '' And $sWidth <> '' Then
_ArrayAdd($sRL, $sWidth & ' X ' & $sHigh)
Else
_ArrayAdd($sRL, '')
EndIf
;获取视频刷新率
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "Video;%FrameRate/String%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle[0], "int", 0)
_ArrayAdd($sRL, $Inform[0])
;删除Handle和DLL
$sHandle = DllCall($sDLL, "none", "MediaInfoList_Delete", "ptr", $sHandle[0])
DllClose($sDLL)
Return $sRL
EndFunc ;==>_GetInfoArray