#Include <File.au3>
#Include <Array.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include '_FileGetShortName.au3'
Dim $FileList,$DriveVar
$Form1 = GUICreate("文件列表", 283, 408, -1, -1)
$ListView1 = GUICtrlCreateListView("盘符|文件名", 8, 8, 266, 390)
$menu_C1 = GUICtrlCreateContextMenu($ListView1);创建上下文菜单(右键)
$SeeMenu = GUICtrlCreateMenuItem("查看这个文件", $menu_C1);创建一个菜单项目控件
$menu_C2 = GUICtrlCreateMenuItem("删除这个文件", $menu_C1);创建一个菜单项目控件
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES));加虚线
GUISetState(@SW_SHOW)
$DriveVar = DriveGetDrive('FIXED');得到固定的分区
For $i = 1 To $DriveVar[0];
$DriveVar[$i] = StringUpper($DriveVar[$i]) & '\'
$FileList = _FileListToArray ($DriveVar[$i]);取这个位置的文件,把他放到变量里,成数组
;~ MsgBox(0,0,$FileList[0])
For $x = 1 To $FileList[0]
GUICtrlCreateListViewItem($DriveVar[$i] & '|' & $FileList[$x], $ListView1)
Next
Next
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $menu_C2
_filedel()
Case $SeeMenu
_SeeFile()
EndSwitch
WEnd
Func _filedel()
Local $fileduan8,$gettxt,$Strn,$Strnspin
$gettxt = GUICtrlRead($ListView1)
$Strn = GUICtrlRead($gettxt)
$Strnspin = StringSplit($Strn, "|")
;~ ClipPut($Strnspin[2])
$fileduan8 = _FileGetShortName($Strnspin[1] & $Strnspin[2],1)
;~ MsgBox(0,0,$fileduan8)
If MsgBox(32 + 4,'提示','是否重设文件属性与删除文件?' & @CRLF & @CRLF & '请确定这个目录或文件的重要性。') = 6 Then
FileSetAttrib($fileduan8,'-RASH')
FileDelete($fileduan8)
DirRemove($fileduan8,1)
While 1
If FileExists($fileduan8) = 0 Then ExitLoop
Sleep(500)
WEnd
GUICtrlDelete($gettxt)
MsgBox(4096,'提示','删除成功.')
EndIf
EndFunc
Func _SeeFile()
Local $fileduan8,$gettxt,$Strn,$Strnspin
$gettxt = GUICtrlRead($ListView1)
;~ MsgBox(0,0,$gettxt)
$Strn = GUICtrlRead($gettxt)
;~ MsgBox(0,0,$Strn)
$Strnspin = StringSplit($Strn, "|")
;~ ClipPut($Strnspin[2])
$fileduan8 = _FileGetShortName($Strnspin[1] & $Strnspin[2],1)
ShellExecute($fileduan8,'',@ScriptDir)
EndFunc
|