#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=icons\Program.ico
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Description=FileCommander
#AutoIt3Wrapper_Res_Fileversion=2.6.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Oscar (www.autoit.de)
#AutoIt3Wrapper_Res_Language=1031
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <APIShellExConstants.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <Constants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <GDIPlus.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <ListBoxConstants.au3>
#include <ListViewConstants.au3>
#include <Misc.au3>
#include <SendMessage.au3>
#include <StructureConstants.au3>
#include <UDFGlobalID.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Opt('GUIOnEventMode', 1)
Opt('GUICloseOnESC', 0)
Opt('MustDeclareVars', 1)
Opt('GUIResizeMode', $GUI_DOCKAUTO)
Opt('MouseCoordMode', 0)

Global $sTitle = 'FileCommander'
Global $sVersion = '2.6.0.2'
_Singleton($sTitle & $sVersion)

Global $sDate = '25.01.2011'
Global $sAppDir = @AppDataDir & '\FileCommander\'
If Not FileExists($sAppDir) Then DirCreate($sAppDir)
Global $sIniFile = $sAppDir & 'FileCommander.ini'
Global $sScriptDir = _AddTrailingBackslash(@ScriptDir)
Global $sIconDir = $sScriptDir & 'icons\'
Global $sLogfile = $sAppDir & 'FileCommander.log'
Global $sHexEditor = IniRead($sIniFile, 'Config', 'HexEditor', $sScriptDir & 'tools\HexView.exe')
If Not FileExists($sHexEditor) Then $sHexEditor = ''
Global $fLogfile = Execute(IniRead($sIniFile, 'Config', 'Logfile', False))
Global $fShowHidden = Execute(IniRead($sIniFile, 'Config', 'ShowHidden', True))
Global $fShowDrives = Execute(IniRead($sIniFile, 'Config', 'ShowDrives', True))
Global $fMaximized = Execute(IniRead($sIniFile, 'Config', 'Maximized', False))
Global $fLargeIcons = Execute(IniRead($sIniFile, 'Config', 'LargeIcons', False))
Global $fGridLines = Execute(IniRead($sIniFile, 'Config', 'GridLines', False))
Global $iWidth = IniRead($sIniFile, 'Config', 'Width', 980)
Global $iHeight = IniRead($sIniFile, 'Config', 'Height', 502)
Global $iX = IniRead($sIniFile, 'Config', 'X', @DesktopWidth / 2 - 490)
If $iX = -32000 Then $iX = @DesktopWidth / 2 - 490
Global $iY = IniRead($sIniFile, 'Config', 'Y', @DesktopHeight / 2 - 251)
If $iY = -32000 Then $iY = @DesktopHeight / 2 - 251

Global $aDropToolbarPath = IniReadSection($sIniFile, 'DropToolbarPath')
If Not IsArray($aDropToolbarPath) Then Global $aDropToolbarPath[1][2] = [[0, 0]]
Global $aDropToolbarIcon = IniReadSection($sIniFile, 'DropToolbarIcon')
If Not IsArray($aDropToolbarIcon) Then Global $aDropToolbarIcon[1][2] = [[0, 0]]
Global $ahDropToolbarButton[1][4]

Global $aColWidth[5], $aSize[5] = [100, 60, 60, 100, 40]
For $i = 0 To 4
	$aColWidth[$i] = IniRead($sIniFile, 'Config', 'LVCol' & $i, $aSize[$i])
Next
Global $sColOrder = IniRead($sIniFile, 'Config', 'ColOrder', '0|1|2|3|4')
Global $aDrives = DriveGetDrive('FIXED'), $fChangePath = False
Global $aDirPath[2] = [IniRead($sIniFile, 'Config', 'LeftPath', ''), IniRead($sIniFile, 'Config', 'RightPath', '')]
If Not FileExists($aDirPath[0]) Then $aDirPath[0] = StringUpper($aDrives[1]) & '\'
If Not FileExists($aDirPath[1]) Then $aDirPath[1] = StringUpper($aDrives[1]) & '\'
Global $aDirList = IniReadSection($sIniFile, 'DirList')
If Not IsArray($aDirList) Then Global $aDirList[1][2] = [[0, '']]

Global $sIniVersion = IniRead($sIniFile, 'Program', 'Version', '0.0.0.0')
If $sIniVersion < '1.3.0.0' Then ; update from old Inifile
	FileDelete($sIniFile)
	IniWrite($sIniFile, 'Config', 'X', $iX)
	IniWrite($sIniFile, 'Config', 'Y', $iY)
	IniWrite($sIniFile, 'Config', 'Width', $iWidth)
	IniWrite($sIniFile, 'Config', 'Height', $iHeight)
	IniWrite($sIniFile, 'Config', 'Maximized', $fMaximized)
	For $i = 0 To 4
		IniWrite($sIniFile, 'Config', 'LVCol' & $i, $aColWidth[$i])
	Next
	IniWrite($sIniFile, 'Config', 'ColOrder', $sColOrder)
	IniWrite($sIniFile, 'Config', 'Logfile', $fLogfile)
	IniWrite($sIniFile, 'Config', 'LeftPath', $aDirPath[0])
	IniWrite($sIniFile, 'Config', 'RightPath', $aDirPath[1])
EndIf
IniWrite($sIniFile, 'Program', 'Version', $sVersion)

Global $aColorActive[2] = [0x005599, 0xFFFF22], $aColorInactive[2] = [0xEEEEEE, 0x000000]
Global $sHeader = 'Name|Erw.|Größe|Datum|Attr.', $aHeader = StringSplit($sHeader, '|', 2)
Global $ahDriveButtons, $ahDriveIcon[2], $ahLabel[2], $ahPath[2], $ahDirList[2], $ahReload[2], $ahUp[2], $ahLV[2], $ahInfo[2], $ahContextMenu[2]
Global $aLastTopIndex[2][1024][2]
Global $iActiveLV = 0, $fCancel = False, $iCopySize = 0, $iCopyTransferred = 0, $iCopyTimer, $fTabSelect, $fSearchCancel = False
Global $s7zexe = FileGetShortName($sScriptDir & '7-zip\7za.exe')
Global $oShellApp = ObjCreate('shell.application')

TCPStartup()
_GDIPlus_Startup()

Global $iWinTitleMenuHeight = _WinAPI_GetSystemMetrics(4) + _WinAPI_GetSystemMetrics(15) + _WinAPI_GetSystemMetrics(33)
Global $User32Dll = DllOpen('user32.dll')

Global Const $tagSHFILEINFO = 'ptr hIcon; int iIcon; DWORD dwAttributes; CHAR szDisplayName[255]; CHAR szTypeName[80];'
;Global Const $SHGFI_USEFILEATTRIBUTES = 0x10
;Global Const $SHGFI_SYSICONINDEX = 0x4000
;Global Const $SHGFI_SMALLICON = 0x1
;Global Const $SHGFI_LARGEICON = 0x0
Global $FOLDER_ICON_INDEX = _GUIImageList_GetFileIconIndex(@SystemDir, $fLargeIcons, 1)
Global $UP_ICON_INDEX = _GUIImageList_GetFileIconIndex($sIconDir & 'up.ico', $fLargeIcons, 1)

; Main-Gui
Global $hGui = GUICreate($sTitle & '   v' & StringLeft($sVersion, 3), 700, 502, $iX, $iY, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_CLIPSIBLINGS), $WS_EX_ACCEPTFILES)
GUISetOnEvent($GUI_EVENT_CLOSE, '_End')
GUISetOnEvent($GUI_EVENT_DROPPED, '_DragAndDrop')
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, '_DragMe')
GUISetBkColor(0xC0C0C0)
GUISetFont(10, 400, 0, 'Tahoma', $hGui, 5)
GUISetIcon($sIconDir & 'program.ico', 0)

Global $hFileMenu = GUICtrlCreateMenu('Datei')
GUICtrlCreateMenuItem('Vorschaufenster öffnen (Alt+v)', $hFileMenu)
GUICtrlSetOnEvent(-1, '_PreviewSetState')
GUICtrlCreateMenuItem('', $hFileMenu)
GUICtrlCreateMenuItem('Suche... (Alt+s)', $hFileMenu)
GUICtrlSetOnEvent(-1, '_OpenSearchGui')
GUICtrlCreateMenuItem('', $hFileMenu)
GUICtrlCreateMenuItem('Datei-Datum der markierten Einträge ändern', $hFileMenu)
GUICtrlSetOnEvent(-1, '_ChangeDate')
GUICtrlCreateMenuItem('Datei-Attribute der markierten Einträge ändern', $hFileMenu)
GUICtrlSetOnEvent(-1, '_ChangeAttr')
GUICtrlCreateMenuItem('', $hFileMenu)
GUICtrlCreateMenuItem('Die markierten Einträge mit 7z packen', $hFileMenu)
GUICtrlSetOnEvent(-1, '_Pack7z')
GUICtrlCreateMenuItem('Die markierten ZIP/7z-Archive entpacken', $hFileMenu)
GUICtrlSetOnEvent(-1, '_UnPack7z')
GUICtrlCreateMenuItem('', $hFileMenu)
GUICtrlCreateMenuItem('Eigenschaften', $hFileMenu)
GUICtrlSetOnEvent(-1, '_FileProperties')
GUICtrlCreateMenuItem('', $hFileMenu)
GUICtrlCreateMenuItem('Programm beenden', $hFileMenu)
GUICtrlSetOnEvent(-1, '_End')
Global $hEditMenu = GUICtrlCreateMenu('Markieren')
GUICtrlCreateMenuItem('Alles markieren', $hEditMenu)
GUICtrlSetOnEvent(-1, '_MarkAll')
GUICtrlCreateMenuItem('Nichts markieren', $hEditMenu)
GUICtrlSetOnEvent(-1, '_MarkNothing')
GUICtrlCreateMenuItem('Alle Verzeichnisse markieren', $hEditMenu)
GUICtrlSetOnEvent(-1, '_MarkDirs')
GUICtrlCreateMenuItem('Größe der markierten Verzeichnisse einlesen', $hEditMenu)
GUICtrlSetOnEvent(-1, '_ReadMarkDirSize')
GUICtrlCreateMenuItem('Größe aller Verzeichnisse einlesen', $hEditMenu)
GUICtrlSetOnEvent(-1, '_ReadAllDirSize')
GUICtrlCreateMenuItem('Alle Dateien markieren', $hEditMenu)
GUICtrlSetOnEvent(-1, '_MarkFiles')
GUICtrlCreateMenuItem('Alle Dateien mit der gleichen Endung markieren', $hEditMenu)
GUICtrlSetOnEvent(-1, '_MarkSameExt')
Global $hConfigMenu = GUICtrlCreateMenu('Einstellungen')
Global $hShowHidden = GUICtrlCreateMenuItem('Versteckte Verzeichnisse und Dateien anzeigen', $hConfigMenu)
GUICtrlSetOnEvent(-1, '_SwitchHidden')
If $fShowHidden Then GUICtrlSetState(-1, $GUI_CHECKED)
Global $hShowDrives = GUICtrlCreateMenuItem('Versteckte Laufwerke anzeigen', $hConfigMenu)
GUICtrlSetOnEvent(-1, '_SwitchShowDrives')
If $fShowDrives Then GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateMenuItem('Laufwerke konfigurieren', $hConfigMenu)
GUICtrlSetOnEvent(-1, '_ConfigDrives')
If Not FileExists($sScriptDir & 'tools\RegWrite.exe') Then GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateMenuItem('', $hConfigMenu)
Global $hLargeIcons = GUICtrlCreateMenuItem('Grosse Icons für die Dateilisten benutzen', $hConfigMenu)
GUICtrlSetOnEvent(-1, '_SwitchLargeIcons')
If $fLargeIcons Then GUICtrlSetState(-1, $GUI_CHECKED)
Global $hGridLines = GUICtrlCreateMenuItem('Gitternetzlinien für die Dateilisten benutzen', $hConfigMenu)
GUICtrlSetOnEvent(-1, '_SwitchGridLines')
If $fGridLines Then GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateMenuItem('', $hConfigMenu)
Global $hLogfile = GUICtrlCreateMenuItem('Kopier-/Löschvorgänge in Logdatei schreiben', $hConfigMenu)
GUICtrlSetOnEvent(-1, '_SwitchLogfile')
If $fLogfile Then GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateMenuItem('Hex-Editor auswählen...', $hConfigMenu)
GUICtrlSetOnEvent(-1, '_SelectHexEdit')
Global $hHelpMenu = GUICtrlCreateMenu('?')
GUICtrlCreateMenuItem('Programm-Informationen', $hHelpMenu)
GUICtrlSetOnEvent(-1, '_ProgInfo')
GUICtrlCreateMenuItem('Danksagungen', $hHelpMenu)
GUICtrlSetOnEvent(-1, '_Thanks')

Global $hDropToolbar = GUICtrlCreateLabel('', -2, 0, 704, 47, Default, $GUI_WS_EX_PARENTDRAG + $WS_EX_STATICEDGE)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

_DropToolbar_CreateButtons()

_CreateDriveButtons()

$ahDriveIcon[0] = GUICtrlCreateButton('', 2, 82, 42, 40, BitOR($BS_VCENTER, $BS_ICON))
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_DriveProperties')

$ahLabel[0] = GUICtrlCreateLabel('', 46, 82, 303, 18)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)

$ahPath[0] = GUICtrlCreateInput('', 46, 100, 236, 22, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_WANTRETURN))
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_ReadPath')

$ahDirList[0] = GUICtrlCreateButton('', 283, 100, 22, 22, $BS_ICON)
GUICtrlSetImage(-1, $sIconDir & 'fav.ico', 1, 0)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_OpenDirList')
GUICtrlSetTip(-1, 'Verzeichnisliste (Favoriten)' & @CR & 'Linke Maustaste = Liste anzeigen' & @CR & 'Rechte Maustaste = Liste bearbeiten')
Global $hContext = GUICtrlCreateContextMenu($ahDirList[0])
GUICtrlCreateMenuItem('Aktuelles Verzeichnis hinzufügen', $hContext)
GUICtrlSetOnEvent(-1, '_AddDirToFav')
GUICtrlCreateMenuItem('Verzeichnisliste bearbeiten', $hContext)
GUICtrlSetOnEvent(-1, '_ShowEditGui')

$ahReload[0] = GUICtrlCreateButton('', 305, 100, 22, 22, $BS_ICON)
GUICtrlSetImage(-1, $sIconDir & 'refresh.ico', 1, 0)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_ReloadLeftLV')
GUICtrlSetTip(-1, 'Verzeichnis neu einlesen')

$ahUp[0] = GUICtrlCreateButton('', 327, 100, 22, 22, $BS_ICON)
GUICtrlSetImage(-1, $sIconDir & 'up.ico', 1, 0)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_LVLeftUp')
GUICtrlSetTip(-1, 'Eine Verzeichnisebene nach oben wechseln')

$ahLV[0] = GUICtrlCreateListView($sHeader, 2, 124, 347, 272, $LVS_SHOWSELALWAYS, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))
GUICtrlSetFont(-1, 10, 400, 0, 'Tahoma', 5)
GUICtrlSetOnEvent(-1, '_SortLV')
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKTOP)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
_CreateContextMenu($ahLV[0], 0)

$ahInfo[0] = GUICtrlCreateLabel('', 2, 397, 347, 20, Default, $WS_EX_CLIENTEDGE)
GUICtrlSetBkColor(-1, 0xFFFFAA)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)

$ahDriveIcon[1] = GUICtrlCreateButton('', 350, 82, 42, 40, BitOR($BS_VCENTER, $BS_ICON))
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_DriveProperties')

$ahLabel[1] = GUICtrlCreateLabel('', 394, 82, 303, 18, Default)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)

$ahPath[1] = GUICtrlCreateInput('', 394, 100, 236, 22, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_WANTRETURN))
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_ReadPath')

$ahDirList[1] = GUICtrlCreateButton('', 631, 100, 22, 22, $BS_ICON)
GUICtrlSetImage(-1, $sIconDir & 'fav.ico', 1, 0)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_OpenDirList')
GUICtrlSetTip(-1, 'Verzeichnisliste (Favoriten)' & @CR & 'Linke Maustaste = Liste anzeigen' & @CR & 'Rechte Maustaste = Liste bearbeiten')
Global $hContext = GUICtrlCreateContextMenu($ahDirList[1])
GUICtrlCreateMenuItem('Aktuelles Verzeichnis hinzufügen', $hContext)
GUICtrlSetOnEvent(-1, '_AddDirToFav')
GUICtrlCreateMenuItem('Verzeichnisliste bearbeiten', $hContext)
GUICtrlSetOnEvent(-1, '_ShowEditGui')

$ahReload[1] = GUICtrlCreateButton('', 653, 100, 22, 22, $BS_ICON)
GUICtrlSetImage(-1, $sIconDir & 'Refresh.ico', 1, 0)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_ReloadRightLV')
GUICtrlSetTip(-1, 'Verzeichnis neu einlesen')

$ahUp[0] = GUICtrlCreateButton('', 675, 100, 22, 22, $BS_ICON)
GUICtrlSetImage(-1, $sIconDir & 'up.ico', 1, 0)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_LVRightUp')
GUICtrlSetTip(-1, 'Eine Verzeichnisebene nach oben wechseln')

$ahLV[1] = GUICtrlCreateListView($sHeader, 350, 124, 347, 272, $LVS_SHOWSELALWAYS, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP))
GUICtrlSetFont(-1, 10, 400, 0, 'Tahoma', 5)
GUICtrlSetOnEvent(-1, '_SortLV')
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKTOP)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
_CreateContextMenu($ahLV[1], 1)

$ahInfo[1] = GUICtrlCreateLabel('', 350, 397, 347, 20, Default, $WS_EX_CLIENTEDGE)
GUICtrlSetBkColor(-1, 0xFFFFAA)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)

For $i = 0 To 4
	_GUICtrlListView_SetColumnWidth(GUICtrlGetHandle($ahLV[0]), $i, $aColWidth[$i])
	_GUICtrlListView_SetColumnWidth(GUICtrlGetHandle($ahLV[1]), $i, $aColWidth[$i])
Next
_GUICtrlListView_JustifyColumn($ahLV[0], 2, 1)
_GUICtrlListView_JustifyColumn($ahLV[1], 2, 1)
_GUICtrlListView_SetColumnOrder($ahLV[0], $sColOrder)
_GUICtrlListView_SetColumnOrder($ahLV[1], $sColOrder)

_GUICtrlListView_SetImageList($ahLV[0], _GUIImageList_GetSystemImageList($fLargeIcons), 1)
_GUICtrlListView_SetImageList($ahLV[1], _GUIImageList_GetSystemImageList($fLargeIcons), 1)

Global $hRunHexEdit = GUICtrlCreateButton('&Anzeigen (Hex)', 0, 420, 100, 25)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_RunHexEdit')

Global $hRename = GUICtrlCreateButton('&Umbenennen', 100, 420, 100, 25)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_Rename')

Global $hMove = GUICtrlCreateButton('&Verschieben', 200, 420, 100, 25)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_CopyMoveSelItems')

Global $hCopy = GUICtrlCreateButton('&Kopieren', 300, 420, 100, 25)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_CopyMoveSelItems')

Global $hDelete = GUICtrlCreateButton('&Löschen', 400, 420, 100, 25)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_Delete')

Global $hNewDir = GUICtrlCreateButton('Neuer &Ordner', 500, 420, 100, 25)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_NewDir')

Global $hNewFile = GUICtrlCreateButton('Neue &Datei', 600, 420, 100, 25)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
GUICtrlSetOnEvent(-1, '_NewFile')

Global $hProgress = GUICtrlCreateProgress(1, 446, 698, 12)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)

Global $hStatus = _GUICtrlStatusBar_Create($hGui)
Global $aStatusIcons[2]
$aStatusIcons[0] = _WinAPI_LoadShell32Icon(221)
$aStatusIcons[1] = _WinAPI_LoadShell32Icon(219)

Global $hDummy = GUICtrlCreateDummy()
GUICtrlSetOnEvent(-1, '_LVActUp')
Global $hDummy2 = GUICtrlCreateDummy()
GUICtrlSetOnEvent(-1, '_EnterKey')
Global $hDummy3 = GUICtrlCreateDummy()
GUICtrlSetOnEvent(-1, '_RotateLeft')
Global $hDummy4 = GUICtrlCreateDummy()
GUICtrlSetOnEvent(-1, '_RotateRight')

; Preview-Gui
Global $iPreviewMaxDim = 640, $hPreviewBitmap, $iPreviewWidth, $iPreviewHeight, $sPreviewFilename, $fPreviewShow = False
Global $aDecoder = _GDIPlus_Decoders(), $sPreviewExt, $iPreviewAngle = 0
For $i = 1 To $aDecoder[0][0]
	$sPreviewExt &= $aDecoder[$i][6]
Next
Global $hPreviewGui = GUICreate('Vorschau-Fenster', $iPreviewMaxDim, $iPreviewMaxDim + 24, -1, 0, BitOR($WS_SYSMENU, $WS_CAPTION), Default, $hGui)
GUISetOnEvent($GUI_EVENT_CLOSE, '_PreviewSetState')
GUISetIcon('shell32.dll', -140, $hPreviewGui)
Global $hPreviewGraphic = _GDIPlus_GraphicsCreateFromHWND($hPreviewGui)
Global $hPreviewStatus = _GUICtrlStatusBar_Create($hPreviewGui)

; Copy-Gui
Global $ahCopyInfo[4], $ahCopyProgressFile[2], $ahCopyProgressAll[2]
Global $hCopyGui = GUICreate($sTitle, 700, 190, -1, -1, BitOR($WS_POPUPWINDOW, $WS_CAPTION), Default, $hGui)
GUISetBkColor(0xDDDDDD)
GUISetIcon($sIconDir & 'program.ico', 0)
GUISetFont(11, 400, 0, 'Verdana', $hCopyGui, 5)
$ahCopyInfo[2] = GUICtrlCreateLabel('', 10, 10, 80, 18)
$ahCopyInfo[3] = GUICtrlCreateLabel('', 90, 10, 600, 18)
GUICtrlCreateLabel('Datei: ', 10, 37, 40, 16)
GUICtrlSetFont(-1, 9)
$ahCopyInfo[0] = GUICtrlCreateLabel('', 55, 37, 640, 16)
GUICtrlSetFont(-1, 9)
GUICtrlCreateLabel('Nach: ', 10, 60, 40, 16)
GUICtrlSetFont(-1, 9)
$ahCopyInfo[1] = GUICtrlCreateLabel('', 55, 60, 640, 16)
GUICtrlSetFont(-1, 9)
$ahCopyProgressFile[0] = GUICtrlCreateLabel('0%', 655, 90, 40, 18)
GUICtrlSetFont(-1, 10)
$ahCopyProgressFile[1] = GUICtrlCreateProgress(10, 90, 640, 16)
$ahCopyProgressAll[0] = GUICtrlCreateLabel('0%', 655, 126, 40, 18)
GUICtrlSetFont(-1, 10)
$ahCopyProgressAll[1] = GUICtrlCreateProgress(10, 120, 640, 28)
Global $hCopyCancel = GUICtrlCreateButton('Abbrechen', 300, 160, 100, 25)
GUICtrlSetFont(-1, 10)

; CopyExists-Gui
Global $hExistsGui = GUICreate($sTitle, 550, 145, -1, -1, BitOR($WS_POPUPWINDOW, $WS_CAPTION), Default, $hCopyGui)
GUISetBkColor(0xFFCC66)
GUISetIcon('user32.dll', -2)
GUISetFont(9, 400, 0, 'Tahoma', $hExistsGui, 5)
GUICtrlCreateGroup('Datei existiert bereits ', 10, 10, 530, 55)
Global $hCopyFileExists = GUICtrlCreateLabel('', 20, 35, 490, 16)
GUICtrlCreateGroup('', -99, -99, 1, 1)
Global $hExistsOverwrite = GUICtrlCreateButton('Überschreiben', 170, 80, 120, 25)
Global $hExistsOverwriteAll = GUICtrlCreateButton('Alle Überschreiben', 170, 110, 120, 25)
Global $hExistsSkip = GUICtrlCreateButton('Überspringen', 300, 80, 120, 25)
Global $hExistsSkipAll = GUICtrlCreateButton('Alle Überspringen', 300, 110, 120, 25)
Global $hExistsRename = GUICtrlCreateButton('Umbenennen', 430, 80, 110, 25)
Global $hExistsCancel = GUICtrlCreateButton('Abbrechen', 430, 110, 110, 25)

; Attribute-Gui
Global $hAttrGui = GUICreate($sTitle & ' - Dateiattribute bearbeiten', 370, 290, -1, -1, BitOR($WS_POPUPWINDOW, $WS_CAPTION), Default, $hGui)
GUISetBkColor(0xBBBBBB)
GUISetIcon($sIconDir & 'program.ico', 0)
GUISetFont(10, 400, 0, 'Tahoma', $hAttrGui, 5)
GUICtrlCreateLabel('Hier können die Dateiattribute der markierten Dateien und Verzeichnisse geändert werden.', 20, 10, 320, 35)
Global $hRecursiv = GUICtrlCreateCheckbox('Bei Verzeichnissen rekursiv ändern', 30, 56, 320, 20)
Global $ahAttr[4], $aAttrName[4] = ['R = ReadOnly', 'A = Archive', 'S = System', 'H = Hidden']
GUICtrlCreateGroup('Dateiattribute ändern (Tristate-Modus = unverändert):', 10, 90, 350, 110)
For $i = 0 To 3
	$ahAttr[$i] = GUICtrlCreateCheckbox($aAttrName[$i], 30, 110 + $i * 20, 150, 20, $BS_AUTO3STATE)
	GUICtrlSetState(-1, $GUI_INDETERMINATE)
Next
GUICtrlCreateGroup('', -99, -99, 1, 1)
GUICtrlCreateIcon('user32.dll', -2, 15, 210, 32, 32)
GUICtrlCreateLabel('Änderungen sollten nur von erfahrenen Benutzern vorgenommen werden!', 55, 210, 300, 40)
Global $hAttrAccept = GUICtrlCreateButton('Übernehmen', 150, 255, 100, 25)
Global $hAttrCancel = GUICtrlCreateButton('Abbrechen', 260, 255, 100, 25)

; Filedate-Gui
Global $ahFileDate[3][7] = [[0, 0, 0, 0, 'Erstellt am:', '', ''],[0, 0, 0, 0, 'Geändert am:', '', ''],[0, 0, 0, 0, 'Letzter Zugriff:', '', '']]
Global $hFileTimeGui = GUICreate($sTitle & ' - Datei-/Verzeichnisdatum ändern', 470, 290, -1, -1, BitOR($WS_POPUPWINDOW, $WS_CAPTION), Default, $hGui)
GUISetBkColor(0xBBBBBB)
GUISetIcon('shell32.dll', -21)
GUISetFont(10, 400, 0, 'Verdana', $hFileTimeGui, 5)
GUICtrlCreateGroup('Datei-/Verzeichnisname', 5, 5, 460, 80)
GUICtrlSetFont(-1, 9, 400, 2)
Global $hFTGFilename = GUICtrlCreateInput('', 20, 28, 430, 24, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY))
GUICtrlSetBkColor(-1, 0xFFEEAA)
GUICtrlCreateGroup('', -99, -99, 1, 1)
Global $hFTGRecursiv = GUICtrlCreateCheckbox('Bei Verzeichnissen rekursiv ändern (inkl. Dateien)', 20, 60, 420, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateGroup('Neues Datei-/Verzeichnisdatum', 5, 95, 460, 140)
GUICtrlSetFont(-1, 9, 400, 2)
For $i = 0 To 2
	GUICtrlCreateLabel($ahFileDate[$i][4], 20, 128 + $i * 36, 110, 20)
	$ahFileDate[$i][0] = GUICtrlCreateDate('', 130, 120 + $i * 36, 115, 32, $DTS_SHORTDATEFORMAT)
	$ahFileDate[$i][1] = GUICtrlCreateDate('', 260, 120 + $i * 36, 90, 32, $DTS_TIMEFORMAT)
	$ahFileDate[$i][2] = GUICtrlCreateButton('', 360, 121 + $i * 36, 40, 30, $BS_ICON)
	GUICtrlSetImage(-1, $sIconDir & 'time.ico', 0, 0)
	GUICtrlSetTip(-1, 'Aktuelles Datum/Uhrzeit (jetzt)')
	$ahFileDate[$i][3] = GUICtrlCreateButton('', 410, 121 + $i * 36, 40, 30, $BS_ICON)
	GUICtrlSetImage(-1, 'shell32.dll', -21, 0)
	GUICtrlSetTip(-1, 'Bisheriges Datum/Uhrzeit')
Next
GUICtrlCreateGroup('', -99, -99, 1, 1)
Global $hFTGAccept = GUICtrlCreateButton('Übernehmen', 210, 250, 120, 30)
Global $hFTGCancel = GUICtrlCreateButton('Abbrechen', 340, 250, 120, 30)

; DirList-Gui
Global $hDirListGui = GUICreate($sTitle, 240, 300, -1, -1, $WS_POPUP, Default, $hGui)
GUISetFont(10, 400, 0, 'Tahoma', $hDirListGui, 5)
Global $hDirList = GUICtrlCreateList('', 0, 0, 240, 300, BitOR($LBS_NOINTEGRALHEIGHT, $LBS_SORT, $WS_VSCROLL))
GUICtrlSetOnEvent(-1, '_SelectDir')

; DirListEdit-Gui
Global $hEditGui = GUICreate($sTitle & ' - Verzeichnisliste bearbeiten', 640, 320, -1, -1, BitOR($WS_POPUPWINDOW, $WS_CAPTION), Default, $hGui)
GUISetOnEvent($GUI_EVENT_CLOSE, '_HideEditGui')
GUISetFont(10, 400, 0, 'Tahoma', $hEditGui, 5)
GUISetBkColor(0xC8C8C8)
GUISetIcon($sIconDir & 'program.ico', 0, $hEditGui)
Global $hEditLV = GUICtrlCreateListView('Name|Pfad', 5, 5, 630, 230)
Global $hEditContext = GUICtrlCreateContextMenu($hEditLV)
GUICtrlCreateMenuItem('Eintrag löschen', $hEditContext)
GUICtrlSetOnEvent(-1, '_DirListItemDelete')
GUICtrlCreateGroup('Eintrag ändern:', 5, 240, 630, 75)
GUICtrlCreateLabel('Name', 20, 262, 100, 18)
Global $hEditName = GUICtrlCreateInput('', 20, 280, 280, 20)
GUICtrlCreateLabel('Pfad', 305, 262, 100, 18)
Global $hEditPath = GUICtrlCreateInput('', 305, 280, 280, 20)
Global $hEditOk = GUICtrlCreateButton('Ok', 590, 279, 35, 22)
GUICtrlSetOnEvent(-1, '_DirListItemOk')
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateGroup('', -99, -99, 1, 1)

For $i = 1 To $aDirList[0][0]
	GUICtrlSetData($hDirList, $aDirList[$i][0])
	GUICtrlCreateListViewItem($aDirList[$i][0] & '|' & $aDirList[$i][1], $hEditLV)
Next
_GUICtrlListView_SetColumnWidth($hEditLV, 0, 300)
_GUICtrlListView_SetColumnWidth($hEditLV, 1, 300)

; Search-Gui
Global $hSearchGui = GUICreate($sTitle & ' - Suchfunktion', 640, 500, -1, -1, BitOR($WS_POPUPWINDOW, $WS_CAPTION), Default, $hGui)
GUISetOnEvent($GUI_EVENT_CLOSE, '_HideSearchGui')
GUISetFont(10, 400, 0, 'Verdana', $hSearchGui, 5)
GUISetBkColor(0xC8C8C8)
GUISetIcon($sIconDir & 'program.ico', 0, $hSearchGui)
GUICtrlCreateGroup('Suche in:', 10, 10, 620, 60)
GUICtrlSetFont(-1, 9, 400, 0, 'Verdana', 5)
GUICtrlCreateButton('', 18, 30, 30, 30, $BS_ICON)
GUICtrlSetImage(-1, $sIconDir & 'open.ico')
GUICtrlSetOnEvent(-1, '_SelectSearchDir')
Global $hSearchDir = GUICtrlCreateInput('', 50, 32, 490, 25, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY))
GUICtrlSetBkColor(-1, 0xFFFFCC)
Global $hSearchRek = GUICtrlCreateCheckbox('Rekursiv', 545, 36, 70, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateGroup('', -99, -99, 1, 1)
GUICtrlCreateGroup('Suche nach:', 10, 80, 500, 90)
GUICtrlSetFont(-1, 9, 400, 0, 'Verdana', 5)
Global $hSearchKeyword = GUICtrlCreateInput('', 20, 102, 480, 25, BitOR($ES_LEFT, $ES_AUTOHSCROLL))
Global $hSearchRegExp = GUICtrlCreateCheckbox('RegExp', 20, 136, 80, 20)
Global $hSearchCaseSense = GUICtrlCreateCheckbox('Groß-/Kleinschreibung beachten', 110, 136, 240, 20)
Global $hSearchSelect = GUICtrlCreateCombo('Dateien', 380, 136, 120, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData(-1, 'Ordner|Dateien + Ordner')
GUICtrlSetFont(-1, 9, 400, 0, 'Arial', 5)
GUICtrlCreateGroup('', -99, -99, 1, 1)
Global $hSearchStart = GUICtrlCreateButton('Suche starten', 520, 90, 110, 45)
GUICtrlSetFont(-1, 10, 400, 0, 'Arial', 5)
GUICtrlSetOnEvent(-1, '_SearchStartEvent')
Global $hSearchCancel = GUICtrlCreateButton('Abbrechen', 520, 140, 110, 30)
GUICtrlSetFont(-1, 10, 400, 0, 'Arial', 5)
GUICtrlSetOnEvent(-1, '_SearchCancelEvent')
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateGroup('Ergebnisse:', 10, 180, 620, 285)
GUICtrlSetFont(-1, 9, 400, 0, 'Verdana', 5)
Global $hSearchResults = GUICtrlCreateListView('Name|Größe|Datum', 20, 205, 600, 215, $LVS_SHOWSELALWAYS)
GUICtrlSetFont(-1, 9, 400, 0, 'Verdana', 5)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 300)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 120)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 120)
Global $hSearchResultsContext = GUICtrlCreateContextMenu($hSearchResults)
GUICtrlCreateMenuItem('Alles markieren', $hSearchResultsContext)
GUICtrlSetOnEvent(-1, '_SearchResultsSelectAll')
GUICtrlCreateMenuItem('Nichts markieren', $hSearchResultsContext)
GUICtrlSetOnEvent(-1, '_SearchResultsSelectNone')
_GUICtrlListView_JustifyColumn($hSearchResults, 1, 1)
GUICtrlCreateGroup('', -99, -99, 1, 1)
Global $ahSearchTools[5]
$ahSearchTools[0] = GUICtrlCreateButton('Gehe zu', 20, 430, 95, 25)
GUICtrlSetFont(-1, 10, 400, 0, 'Arial', 5)
GUICtrlSetOnEvent(-1, '_SearchGoto')
$ahSearchTools[1] = GUICtrlCreateButton('Ausführen', 120, 430, 95, 25)
GUICtrlSetFont(-1, 10, 400, 0, 'Arial', 5)
GUICtrlSetOnEvent(-1, '_SearchExecute')
$ahSearchTools[2] = GUICtrlCreateButton('Verschieben nach...', 220, 430, 130, 25)
GUICtrlSetFont(-1, 10, 400, 0, 'Arial', 5)
GUICtrlSetOnEvent(-1, '_SearchCopyMove')
$ahSearchTools[3] = GUICtrlCreateButton('Kopieren nach...', 355, 430, 130, 25)
GUICtrlSetFont(-1, 10, 400, 0, 'Arial', 5)
GUICtrlSetOnEvent(-1, '_SearchCopyMove')
$ahSearchTools[4] = GUICtrlCreateButton('Löschen', 490, 430, 130, 25)
GUICtrlSetFont(-1, 10, 400, 0, 'Arial', 5)
GUICtrlSetOnEvent(-1, '_SearchDelete')
_SearchToolsSetState($GUI_DISABLE)
Global $hSearchStatus = _GUICtrlStatusBar_Create($hSearchGui)
_GUICtrlStatusBar_SetIcon($hSearchStatus, 0, $aStatusIcons[0])
_GUICtrlStatusBar_SetText($hSearchStatus, 'Bereit.')

; Register Messages
GUIRegisterMsg($WM_SIZE, 'WM_SIZE')
GUIRegisterMsg($WM_MOVE, 'WM_MOVE')
GUIRegisterMsg($WM_PAINT, 'WM_PAINT')
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
;If Not IsDeclared('WM_DEVICECHANGE') Then Global Const $WM_DEVICECHANGE = 0x0219
GUIRegisterMsg($WM_DEVICECHANGE, 'WM_DEVICECHANGE')
GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO')
_GUICtrlListView_RegisterSortCallBack($ahLV[0])
_GUICtrlListView_RegisterSortCallBack($ahLV[1])
GUISetState(@SW_HIDE, $hGui)
If $fMaximized Then
	WinSetState($hGui, '', @SW_MAXIMIZE)
Else
	WinMove($hGui, '', $iX, $iY, $iWidth, $iHeight)
EndIf
If $fGridLines Then
	$fGridLines = False
	_SwitchGridLines()
EndIf
GUISetState(@SW_SHOW, $hGui)

Global $aAccelKeys[4][2] = [['^{BACKSPACE}', $hDummy],['{Enter}', $hDummy2],['{LEFT}', $hDummy3],['{RIGHT}', $hDummy4]]
GUISetAccelerators($aAccelKeys, $hGui)
GUISetAccelerators($aAccelKeys, $hPreviewGui)

GUICtrlSetData($ahPath[1], $aDirPath[1])
_CreateListViewItems($ahLV[1], $aDirPath[1])
_ChangeToolTip($aDirPath[1], 1)
_MarkLVButton(1)

GUICtrlSetData($ahPath[0], $aDirPath[0])
_CreateListViewItems($ahLV[0], $aDirPath[0])
_ChangeToolTip($aDirPath[0], 0)
_MarkLVButton(0)

GUICtrlSetState($ahLV[$iActiveLV], $GUI_FOCUS)

_ShowStatus('Fertig.', 0)
HotKeySet('!c', '_Cancel')
HotKeySet('!s', '_OpenSearchGui')
HotKeySet('!v', '_PreviewSetState')
AdlibRegister('_DeActivateButtons', 200)
Global $fSearchStart = False

While Sleep(100)
	If $fSearchStart Then
		$fSearchStart = False
		_SearchStart()
	EndIf
WEnd

Func _End()
	DllClose($User32Dll)
	TCPShutdown()
	$oShellApp = ''
	AdlibUnRegister('_DeActivateButtons')
	_GUICtrlListView_UnRegisterSortCallBack($ahLV[0])
	_GUICtrlListView_UnRegisterSortCallBack($ahLV[1])
	IniWrite($sIniFile, 'Config', 'Maximized', BitAND(WinGetState($hGui), 32) = 32)
	For $i = 0 To 4
		IniWrite($sIniFile, 'Config', 'LVCol' & $i, _GUICtrlListView_GetColumnWidth($ahLV[0], $i))
	Next
	IniWrite($sIniFile, 'Config', 'LeftPath', GUICtrlRead($ahPath[0]))
	IniWrite($sIniFile, 'Config', 'RightPath', GUICtrlRead($ahPath[1]))
	IniWrite($sIniFile, 'Config', 'ColOrder', $sColOrder)
	_WinAPI_DestroyIcon($aStatusIcons[0])
	_WinAPI_DestroyIcon($aStatusIcons[1])
	_GDIPlus_BitmapDispose($hPreviewBitmap)
	_GDIPlus_GraphicsDispose($hPreviewGraphic)
	_GDIPlus_Shutdown()
	Exit
EndFunc   ;==>_End

Func _OpenSearchGui()
	_GUICtrlStatusBar_SetIcon($hSearchStatus, 0, $aStatusIcons[0])
	_GUICtrlStatusBar_SetText($hSearchStatus, 'Bereit.')
	GUICtrlSetData($hSearchDir, $aDirPath[$iActiveLV])
	_SearchToolsSetState($GUI_DISABLE)
	GUICtrlSetState($hSearchKeyword, $GUI_FOCUS)
	GUICtrlSetState($hSearchStart, $GUI_DEFBUTTON)
	_GUICtrlListView_DeleteAllItems($hSearchResults)
	GUISetState(@SW_SHOW, $hSearchGui)
	GUISetState(@SW_DISABLE, $hGui)
EndFunc   ;==>_OpenSearchGui

Func _HideSearchGui()
	AdlibUnRegister('_CheckSearchResultsSelect')
	GUISetState(@SW_ENABLE, $hGui)
	GUISetState(@SW_HIDE, $hSearchGui)
EndFunc   ;==>_HideSearchGui

Func _SearchToolsSetState($iState)
	For $i = 0 To UBound($ahSearchTools) - 1
		GUICtrlSetState($ahSearchTools[$i], $iState)
	Next
EndFunc   ;==>_SearchToolsSetState

Func _SelectSearchDir()
	Local $sFolder
	$sFolder = FileSelectFolder('Suchverzeichnis auswählen', '', 2, GUICtrlRead($hSearchDir), $hSearchGui)
	If Not FileExists($sFolder) Then Return
	If StringRight($sFolder, 1) <> '\' Then $sFolder &= '\'
	GUICtrlSetData($hSearchDir, $sFolder)
	GUICtrlSetState($hSearchKeyword, $GUI_FOCUS)
EndFunc   ;==>_SelectSearchDir

Func _SearchStartEvent()
	$fSearchStart = True
EndFunc   ;==>_SearchStartEvent

Func _SearchCancelEvent()
	$fSearchCancel = True
EndFunc   ;==>_SearchCancelEvent

Func _SearchGoto()
	Local $aItemText, $sDir, $sFile, $iIndex = -1
	$aItemText = StringSplit(_GUICtrlListView_GetItemTextString($hSearchResults, -1), '|', 2)
	If Not IsArray($aItemText) Then Return
	_HideSearchGui()
	$sDir = StringRegExpReplace($aItemText[0], '(.+\\).*', '$1')
	$sFile = StringRegExpReplace($aItemText[0], '.+\\(.*)', '$1')
	GUICtrlSetData($ahPath[$iActiveLV], $sDir)
	$aDirPath[$iActiveLV] = $sDir
	_MarkLVButton($iActiveLV)
	_CreateListViewItems($ahLV[$iActiveLV], $sDir)
	If $sFile = '' Then Return
	Do
		$iIndex = _GUICtrlListView_FindText($ahLV[$iActiveLV], StringRegExpReplace($sFile, '(.+)\..+', '$1'), $iIndex, False, False)
		If $iIndex = -1 Then Return
	Until _GUICtrlListView_GetItemText($ahLV[$iActiveLV], $iIndex, 1) = StringRegExpReplace($sFile, '.+\.(.+)', '$1')
	_GUICtrlListView_EnsureVisible($ahLV[$iActiveLV], $iIndex)
	_GUICtrlListView_SetItemSelected($ahLV[$iActiveLV], $iIndex, True, True)
EndFunc   ;==>_SearchGoto

Func _SearchExecute()
	Local $aItemText
	$aItemText = StringSplit(_GUICtrlListView_GetItemTextString($hSearchResults, -1), '|', 2)
	If Not IsArray($aItemText) Then Return
	ShellExecute($aItemText[0], '', StringRegExpReplace($aItemText[0], '(.+\\).+', '$1'))
EndFunc   ;==>_SearchExecute

Func _SearchCopyMove()
	Local $hwndLV = GUICtrlGetHandle($hSearchResults), $aSelIndices, $iCtrlID = @GUI_CtrlId
	$aSelIndices = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	Local $sSourcePath, $sDestPath, $sName, $sExt, $sCopyFiles, $aCopyFiles, $aWinPos, $aDirSize, $sNewDir
	$sDestPath = FileSelectFolder('Zielverzeichnis auswählen:', '', 2, $aDirPath[1 - $iActiveLV], $hSearchGui)
	If Not FileExists($sDestPath) Then Return
	$sDestPath = _AddTrailingBackslash($sDestPath)
	Switch $iCtrlID
		Case $ahSearchTools[2] ; SearchMove
			Local $aMsg[2] = ['Verschiebevorgang abgebrochen.', 'Verschiebe']
		Case $ahSearchTools[3] ; SearchCopy
			Local $aMsg[2] = ['Kopiervorgang abgebrochen.', 'Kopiere']
	EndSwitch
	_GUICtrlStatusBar_SetIcon($hSearchStatus, 0, $aStatusIcons[0])
	_GUICtrlStatusBar_SetText($hSearchStatus, 'Erstelle Liste der Dateien. Bitte warten!')
	$iCopySize = 0
	$iCopyTransferred = 0
	For $i = 1 To $aSelIndices[0]
		$sName = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 0)
		If StringInStr(FileGetAttrib($sName), 'D') Then
			$sCopyFiles &= $sName & '\' & @CR
			$sCopyFiles &= _RecursiveFileListToArray($sName, 0, 0)
		Else
			$iCopySize += FileGetSize($sName)
			$sCopyFiles &= $sName & @CR
		EndIf
	Next
	$aCopyFiles = StringSplit(StringTrimRight($sCopyFiles, 1), @CR)
	$aWinPos = WinGetPos($hGui)
	WinMove($hCopyGui, '', $aWinPos[0] + $aWinPos[2] / 2 - 352, $aWinPos[1] + 160)
	GUICtrlSetData($ahCopyInfo[2], $aMsg[1] & '...')
	GUICtrlSetData($ahCopyInfo[3], '')
	For $i = 0 To 1
		GUICtrlSetData($ahCopyInfo[$i], '')
		GUICtrlSetData($ahCopyProgressFile[$i], 0 & _Iif($i = 0, '%', ''))
		GUICtrlSetData($ahCopyProgressAll[$i], 0 & _Iif($i = 0, '%', ''))
	Next
	Opt('GUIOnEventMode', 0)
	GUISetState(@SW_SHOW, $hCopyGui)
	Local $fSkipAll = False, $fOverwriteAll = False, $sDelDir, $sDestName
	$iCopyTimer = TimerInit()
	GUICtrlSetData($ahCopyInfo[1], '"' & $sDestPath & '"')
	GUICtrlSetTip($ahCopyInfo[1], $sDestPath)
	For $i = 1 To $aCopyFiles[0]
		$sSourcePath = StringRegExpReplace($aCopyFiles[$i], '(.+\\).+', '$1')
		$aCopyFiles[$i] = StringRegExpReplace($aCopyFiles[$i], '.+\\(.+)', '$1')
		If StringRight($aCopyFiles[$i], 1) = '\' Then
			$aDirSize = DirGetSize($sSourcePath & $aCopyFiles[$i], 3)
			If $aDirSize[1] = 0 And $aDirSize[2] = 0 Then ; If directory is empty, then create it in destination dir
				If DirCreate($sDestPath & $aCopyFiles[$i]) And $iCtrlID = $ahSearchTools[2] Then DirRemove($sSourcePath & $aCopyFiles[$i])
			EndIf
			ContinueLoop
		EndIf
		GUICtrlSetData($ahCopyInfo[0], '"' & $aCopyFiles[$i] & '"')
		GUICtrlSetTip($ahCopyInfo[0], $aCopyFiles[$i])
		$sDestName = $aCopyFiles[$i]
		If FileExists($sDestPath & $aCopyFiles[$i]) Then
			GUICtrlSetData($hCopyFileExists, $sDestPath & $aCopyFiles[$i])
			If $fSkipAll Then ContinueLoop
			If Not $fOverwriteAll Then
				$aWinPos = WinGetPos($hCopyGui)
				WinMove($hExistsGui, '', $aWinPos[0] + $aWinPos[2] / 2 - 285, $aWinPos[1] + 120)
				GUISetState(@SW_SHOW, $hExistsGui)
				_PlayDefaultSystemSound('SystemExclamation')
				While True
					Switch GUIGetMsg()
						Case $GUI_EVENT_CLOSE, $hExistsCancel
							GUISetState(@SW_HIDE, $hExistsGui)
							GUISetState(@SW_HIDE, $hCopyGui)
							Opt('GUIOnEventMode', 1)
							Return
						Case $hExistsRename
							Do
								$sDestName = InputBox('Datei umbenennen', 'Bitte neuen Dateinamen eingeben:', $aCopyFiles[$i], '', 320, 140, $aWinPos[0] + $aWinPos[2] / 2 - 160, $aWinPos[1] + 150, 0, $hExistsGui)
								If @error Then ContinueLoop 2
							Until Not FileExists($sDestPath & $sDestName)
							ExitLoop
						Case $hExistsSkip
							GUISetState(@SW_HIDE, $hExistsGui)
							ContinueLoop 2
						Case $hExistsSkipAll
							GUISetState(@SW_HIDE, $hExistsGui)
							$fSkipAll = True
							ContinueLoop 2
						Case $hExistsOverwrite
							ExitLoop
						Case $hExistsOverwriteAll
							$fOverwriteAll = True
							ExitLoop
					EndSwitch
				WEnd
				GUISetState(@SW_HIDE, $hExistsGui)
			EndIf
		EndIf
		Switch $iCtrlID
			Case $ahSearchTools[3]
				_FileProgressCopy($sSourcePath & $aCopyFiles[$i], $sDestPath & $sDestName)
				If Not @error Then
					_LogWrite('File "' & $sSourcePath & $aCopyFiles[$i] & '" copied to "' & $sDestPath & $sDestName & '"')
				Else
					GUISetState(@SW_HIDE, $hCopyGui)
					_GUICtrlStatusBar_SetIcon($hSearchStatus, 0, $aStatusIcons[0])
					_GUICtrlStatusBar_SetText($hSearchStatus, $aMsg[0])
					Return
				EndIf
			Case $ahSearchTools[2]
				If StringLeft($sSourcePath, 2) = StringLeft($sDestPath, 2) Then
					If FileMove($sSourcePath & $aCopyFiles[$i], $sDestPath & $sDestName, 9) Then _
							_LogWrite('File "' & $sSourcePath & $aCopyFiles[$i] & '" moved to "' & $sDestPath & $sDestName & '"')
				Else
					_FileProgressCopy($sSourcePath & $aCopyFiles[$i], $sDestPath & $sDestName)
					If Not @error Then
						If FileDelete($sSourcePath & $aCopyFiles[$i]) Then _
								_LogWrite('File "' & $sSourcePath & $aCopyFiles[$i] & '" moved to "' & $sDestPath & $sDestName & '"')
					Else
						GUISetState(@SW_HIDE, $hCopyGui)
						GUICtrlSetData($hProgress, 0)
						_GUICtrlStatusBar_SetIcon($hSearchStatus, 0, $aStatusIcons[0])
						_GUICtrlStatusBar_SetText($hSearchStatus, $aMsg[0])
						Return
					EndIf
				EndIf
				$sDelDir = StringLeft($aCopyFiles[$i], StringInStr($aCopyFiles[$i], '\'))
				If $sDelDir <> '' Then
					$aDirSize = DirGetSize($sSourcePath & $sDelDir, 1)
					If $aDirSize[1] = 0 Then DirRemove($sSourcePath & $sDelDir, 1)
				EndIf
		EndSwitch
	Next
	GUISetState(@SW_HIDE, $hCopyGui)
	Opt('GUIOnEventMode', 1)
	If $sDestPath = $aDirPath[$iActiveLV] Then _CreateListViewItems($ahLV[$iActiveLV], $aDirPath[$iActiveLV])
	If $sDestPath = $aDirPath[1 - $iActiveLV] Then _CreateListViewItems($ahLV[1 - $iActiveLV], $aDirPath[1 - $iActiveLV])
	_GUICtrlStatusBar_SetIcon($hSearchStatus, 0, $aStatusIcons[0])
	_GUICtrlStatusBar_SetText($hSearchStatus, 'Fertig.')
EndFunc   ;==>_SearchCopyMove

Func _SearchDelete()
	If MsgBox(4 + 48 + 256, $sTitle, 'Sollen die markierten ' & GUICtrlRead($hSearchSelect) & @CR & 'wirklich von der Festplatte gelöscht werden?', 0, $hGui) = 7 Then Return
	Local $hwndLV = GUICtrlGetHandle($hSearchResults), $aSelIndices, $sItem
	$aSelIndices = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	For $i = 1 To $aSelIndices[0]
		If $fCancel Then
			$fCancel = False
			If BitAND(WinGetState($hSearchGui), 8) Then
				_GUICtrlStatusBar_SetIcon($hSearchStatus, 0, $aStatusIcons[0])
				_GUICtrlStatusBar_SetText($hSearchStatus, 'Löschvorgang abgebrochen.')
				Return
			EndIf
		EndIf
		$sItem = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i])
		If FileExists($sItem) Then
			_GUICtrlStatusBar_SetIcon($hSearchStatus, 0, $aStatusIcons[0])
			_GUICtrlStatusBar_SetText($hSearchStatus, 'Lösche: ' & $sItem)
			If StringInStr(FileGetAttrib($sItem), 'D') Then
				If DirRemove($sItem, 1) Then _LogWrite('Delete DIR "' & $sItem & '"')
			Else
				If FileDelete($sItem) Then _LogWrite('Delete FILE "' & $sItem & '"')
			EndIf
		EndIf
	Next
	_GUICtrlListView_DeleteItemsSelected($hwndLV)
	_GUICtrlStatusBar_SetIcon($hSearchStatus, 0, $aStatusIcons[0])
	_GUICtrlStatusBar_SetText($hSearchStatus, 'Fertig.')
EndFunc   ;==>_SearchDelete

Func _CheckSearchResultsSelect()
	Local $iSelected = ControlListView($hSearchGui, '', $hSearchResults, 'GetSelectedCount')
	If $iSelected > 0 Then
		If BitAND(GUICtrlGetState($ahSearchTools[0]), $GUI_DISABLE) Then _SearchToolsSetState($GUI_ENABLE)
	Else
		If BitAND(GUICtrlGetState($ahSearchTools[0]), $GUI_ENABLE) Then _SearchToolsSetState($GUI_DISABLE)
	EndIf
EndFunc   ;==>_CheckSearchResultsSelect

Func _SearchResultsSelectAll()
	_GUICtrlListView_SetItemSelected($hSearchResults, -1, True)
EndFunc   ;==>_SearchResultsSelectAll

Func _SearchResultsSelectNone()
	_GUICtrlListView_SetItemSelected($hSearchResults, -1, False)
EndFunc   ;==>_SearchResultsSelectNone

Func _SearchStart()
	Local $iSearchResults
	GUICtrlSetState($hSearchStart, $GUI_DISABLE)
	GUICtrlSetState($hSearchCancel, $GUI_ENABLE)
	_SearchToolsSetState($GUI_DISABLE)
	AdlibUnRegister('_CheckSearchResultsSelect')
	$fSearchCancel = False
	_GUICtrlListView_BeginUpdate($hSearchResults)
	_GUICtrlListView_DeleteAllItems($hSearchResults)
	_GUICtrlListView_EndUpdate($hSearchResults)
	_SearchFile(GUICtrlRead($hSearchDir), GUICtrlRead($hSearchKeyword))
	$iSearchResults = _GUICtrlListView_GetItemCount($hSearchResults)
	If $iSearchResults > 0 Then
		GUICtrlSendMsg($hSearchResults, $LVM_SETCOLUMNWIDTH, 0, $LVSCW_AUTOSIZE)
		_GUICtrlListView_SetItemSelected($hSearchResults, 0, True, True)
		ControlFocus($hSearchGui, '', $hSearchResults)
		AdlibRegister('_CheckSearchResultsSelect', 200)
	EndIf
	If $fSearchCancel Then
		_GUICtrlStatusBar_SetIcon($hSearchStatus, 0, $aStatusIcons[0])
		_GUICtrlStatusBar_SetText($hSearchStatus, 'Suche abgebrochen:  ' & $iSearchResults & ' ' & GUICtrlRead($hSearchSelect) & ' gefunden.')
	Else
		_GUICtrlStatusBar_SetIcon($hSearchStatus, 0, $aStatusIcons[0])
		_GUICtrlStatusBar_SetText($hSearchStatus, 'Suche beendet:  ' & $iSearchResults & ' ' & GUICtrlRead($hSearchSelect) & ' gefunden.')
	EndIf
	GUICtrlSetState($hSearchStart, $GUI_ENABLE)
	GUICtrlSetState($hSearchCancel, $GUI_DISABLE)
EndFunc   ;==>_SearchStart

Func _SearchFile($sDir, $sSearch)
	Local $aDirs, $aFiles, $iSize, $sDate, $sAttr, $iCaseSense = 2, $sCaseSense = '(?i)', $iSelect
	If $fSearchCancel Then Return
	If BitAND(GUICtrlRead($hSearchCaseSense), $GUI_CHECKED) Then
		$iCaseSense = 1
		$sCaseSense = '(?-i)'
	EndIf
	Switch GUICtrlRead($hSearchSelect)
		Case 'Dateien'
			$iSelect = 1
		Case 'Ordner'
			$iSelect = 2
		Case 'Dateien + Ordner'
			$iSelect = 3
	EndSwitch
	If StringRight($sDir, 1) <> '\' Then $sDir &= '\'
	$aDirs = _FileListToArray($sDir, '*', 2)
	If Not @error Then
		For $i = 1 To $aDirs[0]
			If $fSearchCancel Then Return
			If _IsReparsePoint($sDir & $aDirs[$i]) Then ContinueLoop
			If BitAND($iSelect, 2) Then
				_GUICtrlStatusBar_SetIcon($hSearchStatus, 0, $aStatusIcons[0])
				_GUICtrlStatusBar_SetText($hSearchStatus, $sDir & $aDirs[$i])
				If BitAND(GUICtrlRead($hSearchRegExp), $GUI_CHECKED) Then
					If StringRegExp($sDir & $aDirs[$i], $sCaseSense & $sSearch) Then
						$sDate = StringRegExpReplace(FileGetTime($sDir & $aDirs[$i], 0, 1), '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})', '$3.$2.$1 $4:$5:$6')
						GUICtrlCreateListViewItem($sDir & $aDirs[$i] & '\|<DIR>|' & $sDate, $hSearchResults)
					EndIf
				Else
					If $sSearch = '' Or StringInStr($sDir & $aDirs[$i], $sSearch, $iCaseSense) Then
						$sDate = StringRegExpReplace(FileGetTime($sDir & $aDirs[$i], 0, 1), '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})', '$3.$2.$1 $4:$5:$6')
						GUICtrlCreateListViewItem($sDir & $aDirs[$i] & '\|<DIR>|' & $sDate, $hSearchResults)
					EndIf
				EndIf
			EndIf
			If BitAND(GUICtrlRead($hSearchRek), $GUI_CHECKED) Then _SearchFile($sDir & $aDirs[$i], $sSearch)
		Next
	EndIf
	If $fSearchCancel Then Return
	If BitAND($iSelect, 1) Then
		$aFiles = _FileListToArray($sDir, '*', 1)
		If Not @error Then
			For $i = 1 To $aFiles[0]
				If $fSearchCancel Then Return
				_GUICtrlStatusBar_SetIcon($hSearchStatus, 0, $aStatusIcons[0])
				_GUICtrlStatusBar_SetText($hSearchStatus, $sDir & $aFiles[$i])
				If BitAND(GUICtrlRead($hSearchRegExp), $GUI_CHECKED) Then
					If StringRegExp($aFiles[$i], $sCaseSense & $sSearch) Then
						$iSize = _StringAddThousandsSep(FileGetSize($sDir & $aFiles[$i]))
						$sDate = StringRegExpReplace(FileGetTime($sDir & $aFiles[$i], 0, 1), '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})', '$3.$2.$1 $4:$5:$6')
						GUICtrlCreateListViewItem($sDir & $aFiles[$i] & '|' & $iSize & '|' & $sDate, $hSearchResults)
					EndIf
				Else
					If $sSearch = '' Or StringInStr($aFiles[$i], $sSearch, $iCaseSense) Then
						$iSize = _StringAddThousandsSep(FileGetSize($sDir & $aFiles[$i]))
						$sDate = StringRegExpReplace(FileGetTime($sDir & $aFiles[$i], 0, 1), '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})', '$3.$2.$1 $4:$5:$6')
						GUICtrlCreateListViewItem($sDir & $aFiles[$i] & '|' & $iSize & '|' & $sDate, $hSearchResults)
					EndIf
				EndIf
			Next
		EndIf
	EndIf
EndFunc   ;==>_SearchFile

Func _AddTrailingBackslash($sPath)
	If StringRight($sPath, 1) <> '\' Then $sPath &= '\'
	Return $sPath
EndFunc   ;==>_AddTrailingBackslash

Func _ShowStatus($sMsg, $iError)
	If $iError Then
		_PlayDefaultSystemSound('SystemHand')
		GUICtrlSetData($hProgress, 0)
	EndIf
	_GUICtrlStatusBar_SetIcon($hStatus, 0, $aStatusIcons[$iError])
	_GUICtrlStatusBar_SetText($hStatus, $sMsg)
EndFunc   ;==>_ShowStatus

Func _DragAndDrop()
	Local $sPath, $iLV, $hwndLV, $aItemText, $i, $hDropContext, $hIcon
	Switch @GUI_DropId
		Case $hDropToolbar
			$iLV = Number(@GUI_DragId <> $ahLV[0])
			$hwndLV = GUICtrlGetHandle($ahLV[$iLV])
			$aItemText = _GUICtrlListView_GetItemTextArray($hwndLV, -1)
			If $aItemText[2] <> 'exe' Then Return
			$sPath = $aDirPath[$iLV]
			$aDropToolbarPath[0][0] += 1
			$i = $aDropToolbarPath[0][0]
			If $i = 0 Then $i = 1
			ReDim $aDropToolbarPath[$i + 1][2]
			$aDropToolbarPath[$i][0] = $aItemText[1]
			$aDropToolbarPath[$i][1] = $sPath & $aItemText[1] & '.' & $aItemText[2]
			IniWriteSection($sIniFile, 'DropToolbarPath', $aDropToolbarPath)
			ReDim $ahDropToolbarButton[$i][4]
			GUISwitch($hGui)
			$ahDropToolbarButton[$i - 1][0] = GUICtrlCreateButton($i, 4 + ($i - 1) * 44, 2, 42, 42, $BS_ICON)
			GUICtrlSetOnEvent(-1, '_DropToolbar_Execute')
			GUICtrlSetTip(-1, $aDropToolbarPath[$i][0])
			$hIcon = GUICtrlSetImage(-1, $aDropToolbarPath[$i][1], 0)
			If $hIcon = 0 Then GUICtrlSetImage(-1, 'shell32.dll', 1)
			GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE)
			$ahDropToolbarButton[$i - 1][1] = GUICtrlCreateContextMenu($ahDropToolbarButton[$i - 1][0])
			$ahDropToolbarButton[$i - 1][2] = GUICtrlCreateMenuItem('Löschen', $ahDropToolbarButton[$i - 1][1])
			GUICtrlSetOnEvent(-1, '_DropToolbar_DeleteButton')
			$ahDropToolbarButton[$i - 1][3] = GUICtrlCreateMenuItem('Umbenennen', $ahDropToolbarButton[$i - 1][1])
			GUICtrlSetOnEvent(-1, '_DropToolbar_RenameButton')
		Case $ahLV[0], $ahLV[1]
			If $ahLV[$iActiveLV] <> @GUI_DragId Then ControlFocus($hGui, '', $ahLV[1 - $iActiveLV])
			If _IsPressed('10', $User32Dll) Then
				ControlClick($hGui, '', $hMove)
			Else
				ControlClick($hGui, '', $hCopy)
			EndIf
	EndSwitch
EndFunc   ;==>_DragAndDrop

Func _DropToolbar_Execute()
	Local $sPath = $aDropToolbarPath[GUICtrlRead(@GUI_CtrlId)][1]
	ShellExecute($sPath, '', StringRegExpReplace($sPath, '(.+\\).+', '$1'))
EndFunc   ;==>_DropToolbar_Execute

Func _DragMe()
	Local $iTimer, $aInfo, $iOldState, $aPosC, $aPosM, $iOldIndex, $iNewIndex
	$aInfo = GUIGetCursorInfo($hGui)
	If $aInfo[4] = 0 Then Return
	;_ArrayDisplay($ahDropToolbarButton)
	Switch $aInfo[4]
		Case $ahDropToolbarButton[0][0] To $ahDropToolbarButton[UBound($ahDropToolbarButton) - 1][3]
			$iTimer = TimerInit()
			Do
				If Not _IsPressed('01', $User32Dll) Then Return ; Buttonklick kürzer als 250 mSek
			Until TimerDiff($iTimer) > 250
			$iOldState = GUICtrlGetState($aInfo[4])
			GUICtrlSetState($aInfo[4], $GUI_ONTOP)
			$aPosC = ControlGetPos($hGui, '', $aInfo[4])
			$aPosM = MouseGetPos()
			GUICtrlSetCursor($aInfo[4], 13)
			$iOldIndex = Int($aPosM[0] / 44) + 1
			If $iOldIndex < 1 Then $iOldIndex = 1
			If $iOldIndex >= UBound($ahDropToolbarButton) Then $iOldIndex = UBound($ahDropToolbarButton)
			While _IsPressed('01', $User32Dll)
				$aPosM = MouseGetPos()
				If $aPosM[0] > 0 And $aPosM[0] < (UBound($ahDropToolbarButton) * 44) Then
					GUICtrlSetPos($aInfo[4], Int($aPosM[0] / 44) * 44 + 4, $aPosC[1])
					MouseMove($aPosM[0], 50, 0)
				EndIf
				Sleep(10)
			WEnd
			$iNewIndex = Int($aPosM[0] / 44) + 1
			If $iNewIndex < 1 Then $iNewIndex = 1
			If $iNewIndex >= UBound($ahDropToolbarButton) Then $iNewIndex = UBound($ahDropToolbarButton)
			GUICtrlSetCursor($aInfo[4], 2)
			GUICtrlSetState($aInfo[4], $iOldState)
			If _ChangeArrayPos($iOldIndex, $iNewIndex) Then
				_DropToolbar_CreateButtons()
				IniWriteSection($sIniFile, 'DropToolbarPath', $aDropToolbarPath)
			EndIf
	EndSwitch
EndFunc   ;==>_DragMe

Func _ChangeArrayPos($iOld, $iNew)
	If Number($iOld) = Number($iNew) Then Return SetError(1, 0, 0)
	Local $aOld[1][2]
	$aOld[0][0] = $aDropToolbarPath[$iOld][0]
	$aOld[0][1] = $aDropToolbarPath[$iOld][1]
	If Number($iOld) < Number($iNew) Then
		For $i = $iOld To $iNew - 1
			$aDropToolbarPath[$i][0] = $aDropToolbarPath[$i + 1][0]
			$aDropToolbarPath[$i][1] = $aDropToolbarPath[$i + 1][1]
		Next
		$aDropToolbarPath[$iNew][0] = $aOld[0][0]
		$aDropToolbarPath[$iNew][1] = $aOld[0][1]
	Else
		For $i = $iOld To $iNew + 1 Step -1
			$aDropToolbarPath[$i][0] = $aDropToolbarPath[$i - 1][0]
			$aDropToolbarPath[$i][1] = $aDropToolbarPath[$i - 1][1]
		Next
		$aDropToolbarPath[$iNew][0] = $aOld[0][0]
		$aDropToolbarPath[$iNew][1] = $aOld[0][1]
	EndIf
	Return SetError(0, 0, 1)
EndFunc   ;==>_ChangeArrayPos

Func _DropToolbar_CreateButtons()
	Local $hDropContext, $i
	If IsArray($ahDropToolbarButton) Then
		For $i = 0 To UBound($ahDropToolbarButton) - 1
			For $j = 0 To 3
				GUICtrlDelete($ahDropToolbarButton[$i][$j])
			Next
		Next
		Global $ahDropToolbarButton[1][4] = [[0]]
	EndIf
	If $aDropToolbarPath[0][0] = 0 Then Return
	Global $ahDropToolbarButton[$aDropToolbarPath[0][0]][4]
	GUISwitch($hGui)
	For $i = 1 To $aDropToolbarPath[0][0]
		$ahDropToolbarButton[$i - 1][0] = GUICtrlCreateButton($i, 4 + ($i - 1) * 44, 2, 42, 42, $BS_ICON)
		GUICtrlSetOnEvent(-1, '_DropToolbar_Execute')
		GUICtrlSetTip(-1, $aDropToolbarPath[$i][0])
		GUICtrlSetImage(-1, $aDropToolbarPath[$i][1], 0)
		GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKSIZE)
		$ahDropToolbarButton[$i - 1][1] = GUICtrlCreateContextMenu($ahDropToolbarButton[$i - 1][0])
		$ahDropToolbarButton[$i - 1][2] = GUICtrlCreateMenuItem('Löschen', $ahDropToolbarButton[$i - 1][1])
		GUICtrlSetOnEvent(-1, '_DropToolbar_DeleteButton')
		$ahDropToolbarButton[$i - 1][3] = GUICtrlCreateMenuItem('Umbenennen', $ahDropToolbarButton[$i - 1][1])
		GUICtrlSetOnEvent(-1, '_DropToolbar_RenameButton')
	Next
EndFunc   ;==>_DropToolbar_CreateButtons

Func _DropToolbar_DeleteButton()
	Local $iElement = GUICtrlRead(@GUI_CtrlId - 2)
	_ArrayDelete($aDropToolbarPath, $iElement)
	$aDropToolbarPath[0][0] = UBound($aDropToolbarPath) - 1
	IniWriteSection($sIniFile, 'DropToolbarPath', $aDropToolbarPath)
	_DropToolbar_CreateButtons()
EndFunc   ;==>_DropToolbar_DeleteButton

Func _DropToolbar_RenameButton()
	Local $iElement = GUICtrlRead(@GUI_CtrlId - 3), $sNewName, $aWinPos = WinGetPos($hGui)
	$sNewName = InputBox($sTitle, 'Namen ändern:', $aDropToolbarPath[$iElement][0], '', 280, 130, $aWinPos[0] + $iElement * 44 + 12, $aWinPos[1], 0, $hGui)
	If @error Then Return
	$aDropToolbarPath[$iElement][0] = $sNewName
	GUICtrlSetTip($ahDropToolbarButton[$iElement - 1][0], $sNewName)
	IniWriteSection($sIniFile, 'DropToolbarPath', $aDropToolbarPath)
EndFunc   ;==>_DropToolbar_RenameButton

Func _SelectHexEdit()
	Local $sPath, $sDefaultDir = @ProgramFilesDir
	If $sHexEditor <> '' Then $sDefaultDir = StringRegExpReplace($sHexEditor, '(.+\\).+', '$1')
	GUISetState(@SW_DISABLE, $hGui)
	$sPath = FileOpenDialog($sTitle & ' - Hex-Editor auswählen', $sDefaultDir, 'Programm (*.exe)', 3, '', $hGui)
	GUISetState(@SW_ENABLE, $hGui)
	If Not FileExists($sPath) Then
		$sHexEditor = $sScriptDir & 'tools\HexView.exe'
	Else
		$sHexEditor = $sPath
	EndIf
	IniWrite($sIniFile, 'Config', 'HexEditor', $sHexEditor)
EndFunc   ;==>_SelectHexEdit

Func _RunHexEdit()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $aSelIndices = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	Local $sPath, $sName, $sExt
	If $aSelIndices[0] = 0 Then Return _ShowStatus('Fehler! Keine Einträge markiert.', 1)
	For $i = 1 To $aSelIndices[0]
		$sName = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 0)
		If $sName = '..' Then ContinueLoop
		$sPath = $aDirPath[$iActiveLV] & $sName
		$sExt = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 1)
		If $sExt <> '<DIR>' Then
			$sPath &= '.' & $sExt
			ShellExecute($sHexEditor, Chr(34) & $sPath & Chr(34), $aDirPath[$iActiveLV])
		Else
			_ShowStatus('Hinweis! Nur bei Dateien möglich.', 1)
		EndIf
	Next
EndFunc   ;==>_RunHexEdit

Func _ShowEditGui()
	Local $aWinPos = WinGetPos($hGui)
	WinMove($hEditGui, '', $aWinPos[0] + $aWinPos[2] / 2 - 320, $aWinPos[1] + 40)
	GUISetState(@SW_SHOW, $hEditGui)
EndFunc   ;==>_ShowEditGui

Func _HideEditGui()
	GUISetState(@SW_HIDE, $hEditGui)
EndFunc   ;==>_HideEditGui

Func _DirListItemOk()
	Local $iSelItem, $sName, $sPath
	$sName = GUICtrlRead($hEditName)
	$sPath = $aDirPath[$iActiveLV]
	If Not FileExists($sPath) Then Return _ShowStatus('Fehler! Der Pfad existiert nicht.', 1)
	$iSelItem = _GUICtrlListView_GetSelectedIndicesNew($hEditLV)
	If $iSelItem = '' Then
		If _NameExists($sName) Then Return _ShowStatus('Fehler! Der Name existiert bereits.', 1)
		ReDim $aDirList[UBound($aDirList) + 1][2]
		$aDirList[0][0] = UBound($aDirList) - 1
		$iSelItem = UBound($aDirList) - 2
		GUICtrlCreateListViewItem($sName & '|' & $sPath, $hEditLV)
	Else
		_GUICtrlListView_SetItemText($hEditLV, $iSelItem, $sName, 0)
		_GUICtrlListView_SetItemText($hEditLV, $iSelItem, $sPath, 1)
	EndIf
	$aDirList[$iSelItem + 1][0] = $sName
	$aDirList[$iSelItem + 1][1] = $sPath
	IniWriteSection($sIniFile, 'DirList', $aDirList)
	GUICtrlSetData($hDirList, '')
	For $i = 1 To $aDirList[0][0]
		GUICtrlSetData($hDirList, $aDirList[$i][0])
	Next
	_GUICtrlListView_SetColumnWidth($hEditLV, 0, 300)
	_GUICtrlListView_SetColumnWidth($hEditLV, 1, 300)
EndFunc   ;==>_DirListItemOk

Func _DirListItemDelete()
	Local $iSelItem
	$iSelItem = _GUICtrlListView_GetSelectedIndicesNew($hEditLV)
	If $iSelItem = '' Then Return _ShowStatus('Fehler! Keine Einträge markiert.', 1)
	_GUICtrlListView_DeleteItemsSelected($hEditLV)
	_ArrayDelete($aDirList, $iSelItem + 1)
	$aDirList[0][0] = UBound($aDirList) - 1
	IniWriteSection($sIniFile, 'DirList', $aDirList)
	GUICtrlSetData($hEditName, '')
	GUICtrlSetData($hEditPath, '')
	GUICtrlSetData($hDirList, '')
	For $i = 1 To $aDirList[0][0]
		GUICtrlSetData($hDirList, $aDirList[$i][0])
	Next
	_GUICtrlListView_SetColumnWidth($hEditLV, 0, 300)
	_GUICtrlListView_SetColumnWidth($hEditLV, 1, 300)
EndFunc   ;==>_DirListItemDelete

Func _OpenDirList()
	Switch @GUI_CtrlId
		Case $ahDirList[0]
			ControlFocus($hGui, '', $ahLV[0])
		Case $ahDirList[1]
			ControlFocus($hGui, '', $ahLV[1])
	EndSwitch
	Local $aWinPos, $aCtrlPos, $iListHeight = 300
	$aWinPos = WinGetPos($hGui)
	$aCtrlPos = ControlGetPos($hGui, '', @GUI_CtrlId)
	If ($aDirList[0][0] * 18) < 300 Then $iListHeight = $aDirList[0][0] * 18
	WinMove($hDirListGui, '', $aWinPos[0] + $aCtrlPos[0] + 8, $aWinPos[1] + $aCtrlPos[1] + 72, 240, $iListHeight)
	GUISetState(@SW_SHOW, $hDirListGui)
EndFunc   ;==>_OpenDirList

Func _SelectDir()
	If $aDirList[0][0] = 0 Then Return
	GUISetState(@SW_HIDE, $hDirListGui)
	Local $sName = GUICtrlRead($hDirList)
	For $i = 1 To $aDirList[0][0]
		If $sName = $aDirList[$i][0] Then ExitLoop
	Next
	GUICtrlSetData($ahPath[$iActiveLV], $aDirList[$i][1])
	$aDirPath[$iActiveLV] = $aDirList[$i][1]
	_MarkLVButton($iActiveLV)
	_CreateListViewItems($ahLV[$iActiveLV], $aDirList[$i][1])
EndFunc   ;==>_SelectDir

Func _AddDirToFav()
	Local $sPath = $aDirPath[$iActiveLV], $sName, $sDefault, $sMsg, $aWinPos
	$sDefault = StringRegExpReplace($sPath, '.+\\(.+)\\', '$1')
	$sMsg = 'Unter welchem Namen soll das Verzeichnis gespeichert werden?'
	$aWinPos = WinGetPos($hGui)
	Do
		$sName = InputBox($sTitle, $sMsg, $sDefault, '', 260, 140, $aWinPos[0] + $aWinPos[2] / 2 - 130, $aWinPos[1] + 50, 0, $hGui)
		If @error Then Return
	Until Not _NameExists($sName)
	ReDim $aDirList[UBound($aDirList) + 1][2]
	$aDirList[UBound($aDirList) - 1][0] = $sName
	$aDirList[UBound($aDirList) - 1][1] = $sPath
	$aDirList[0][0] = UBound($aDirList) - 1
	IniWriteSection($sIniFile, 'DirList', $aDirList)
	GUICtrlSetData($hDirList, '')
	_GUICtrlListView_DeleteAllItems($hEditLV)
	For $i = 1 To $aDirList[0][0]
		GUICtrlSetData($hDirList, $aDirList[$i][0])
		GUICtrlCreateListViewItem($aDirList[$i][0] & '|' & $aDirList[$i][1], $hEditLV)
	Next
	_GUICtrlListView_SetColumnWidth($hEditLV, 0, 300)
	_GUICtrlListView_SetColumnWidth($hEditLV, 1, 300)
EndFunc   ;==>_AddDirToFav

Func _NameExists(ByRef $sName)
	If $aDirList[0][0] = 0 Then Return False
	For $i = 1 To $aDirList[0][0]
		If $sName = $aDirList[$i][0] Then Return True
	Next
	Return False
EndFunc   ;==>_NameExists

Func _CreateContextMenu(ByRef $hListView, $iCount)
	$ahContextMenu[$iCount] = GUICtrlCreateContextMenu($hListView)
	GUICtrlCreateMenuItem('Umbenennen', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_Rename')
	GUICtrlCreateMenuItem('Datum ändern', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_ChangeDate')
	GUICtrlCreateMenuItem('Attribute ändern', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_ChangeAttr')
	GUICtrlCreateMenuItem('Verknüpfung erstellen', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_CreateShortcut')
	GUICtrlCreateMenuItem('', $ahContextMenu[$iCount])
	GUICtrlCreateMenuItem('Alles markieren', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_MarkAll')
	GUICtrlCreateMenuItem('Nichts markieren', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_MarkNothing')
	GUICtrlCreateMenuItem('Alle Verzeichnisse markieren', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_MarkDirs')
	GUICtrlCreateMenuItem('Größe der markierten Verzeichnisse einlesen', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_ReadMarkDirSize')
	GUICtrlCreateMenuItem('Größe aller Verzeichnisse einlesen', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_ReadAllDirSize')
	GUICtrlCreateMenuItem('Alle Dateien markieren', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_MarkFiles')
	GUICtrlCreateMenuItem('Alle Dateien mit der gleichen Endung markieren', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_MarkSameExt')
	GUICtrlCreateMenuItem('', $ahContextMenu[$iCount])
	GUICtrlCreateMenuItem('Die markierten Einträge mit 7z packen', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_Pack7z')
	GUICtrlCreateMenuItem('Die markierten ZIP/7z-Archive entpacken', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_UnPack7z')
	GUICtrlCreateMenuItem('', $ahContextMenu[$iCount])
	GUICtrlCreateMenuItem('Eigenschaften', $ahContextMenu[$iCount])
	GUICtrlSetOnEvent(-1, '_FileProperties')
EndFunc   ;==>_CreateContextMenu

Func _Pack7z()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $iBakLV
	Local $aIndex, $aWinPos, $aControlPos, $sMsg, $sDefault, $sOutArchive, $sName, $sPath, $sExt, $rc, $line
	$aIndex = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	If $aIndex[0] = 0 Then Return _ShowStatus('Fehler! Keine Einträge markiert.', 1)
	$aWinPos = WinGetPos($hGui)
	$aControlPos = ControlGetPos($hGui, '', $ahLV[1 - $iActiveLV])
	$sMsg = ' - Bitte Archivnamen eingeben (Endung: ".7z" oder: ".zip"):'
	$sDefault = _GUICtrlListView_GetItemText($hwndLV, $aIndex[1], 0) & '.7z'
	$iBakLV = $iActiveLV
	$sOutArchive = FileSaveDialog($sTitle & $sMsg, $aDirPath[1 - $iActiveLV], 'Archiv (*.7z; *.zip)', 0, $sDefault, $hGui)
	If @error Then Return
	ControlFocus($hGui, '', $ahLV[$iBakLV])
	If Not StringRegExp($sOutArchive, '.+\.7z|.+\.zip') Then $sOutArchive &= '.7z'
	_ShowStatus('Archiv wird erstellt. Bitte warten...', 0)
	ToolTip('Archiv wird erstellt. Bitte warten...', $aWinPos[0] + $aControlPos[0] + 60, $aWinPos[1] + $aControlPos[1] + 90, $sTitle, 1, 1)
	For $i = 1 To $aIndex[0]
		$sName = _GUICtrlListView_GetItemText($hwndLV, $aIndex[$i], 0)
		If $sName = '..' Then ContinueLoop
		$sPath = $aDirPath[$iActiveLV] & $sName
		$sExt = _GUICtrlListView_GetItemText($hwndLV, $aIndex[$i], 1)
		If $sExt <> '<DIR>' Then $sPath &= '.' & $sExt
		$rc = RunWait(@ComSpec & ' /c ' & $s7zexe & ' a "' & $sOutArchive & '" "' & $sPath & '"', @ScriptDir, @SW_HIDE)
		If $rc <> 0 Then
			_CreateListViewItems($ahLV[1 - $iActiveLV], $aDirPath[1 - $iActiveLV])
			_ShowStatus('Fehler! Beim packen ist ein Fehler aufgetreten (Exitcode = ' & $rc & '). Funktion abgebrochen!', 1)
			ToolTip('')
			Return
		EndIf
		GUICtrlSetData($hProgress, 100 / $aIndex[0] * $i)
	Next
	_CreateListViewItems($ahLV[1 - $iActiveLV], $aDirPath[1 - $iActiveLV])
	_ShowStatus('Fertig.', 0)
	ToolTip('')
	GUICtrlSetData($hProgress, 100)
EndFunc   ;==>_Pack7z

Func _UnPack7z()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $aIndex, $aWinPos, $aControlPos, $sMsg, $sDefault, $sOutArchive, $sName, $sPath, $sExt, $rc, $line
	$aIndex = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	If $aIndex[0] = 0 Then Return _ShowStatus('Fehler! Keine Einträge markiert.', 1)
	$aWinPos = WinGetPos($hGui)
	$aControlPos = ControlGetPos($hGui, '', $ahLV[1 - $iActiveLV])
	_ShowStatus('Markierte Archive werden entpackt. Bitte warten...', 0)
	ToolTip('Markierte Archive werden entpackt. Bitte warten...', $aWinPos[0] + $aControlPos[0] + 60, $aWinPos[1] + $aControlPos[1] + 90, $sTitle, 1, 1)
	For $i = 1 To $aIndex[0]
		$sExt = _GUICtrlListView_GetItemText($hwndLV, $aIndex[$i], 1)
		If $sExt = '7z' Or $sExt = 'zip' Then
			$sName = _GUICtrlListView_GetItemText($hwndLV, $aIndex[$i], 0)
			If $sName = '..' Then ContinueLoop
			$sPath = $aDirPath[$iActiveLV] & $sName & '.' & $sExt
			$rc = RunWait(@ComSpec & ' /c ' & $s7zexe & ' x -o"' & $aDirPath[1 - $iActiveLV] & '" "' & $sPath & '"', @ScriptDir, @SW_HIDE)
			If $rc <> 0 Then
				_CreateListViewItems($ahLV[1 - $iActiveLV], $aDirPath[1 - $iActiveLV])
				_ShowStatus('Fehler! Beim entpacken ist ein Fehler aufgetreten (Exitcode = ' & $rc & '). Funktion abgebrochen!', 1)
				ToolTip('')
				Return
			EndIf
			GUICtrlSetData($hProgress, 100 / $aIndex[0] * $i)
		EndIf
	Next
	_CreateListViewItems($ahLV[1 - $iActiveLV], $aDirPath[1 - $iActiveLV])
	_ShowStatus('Fertig.', 0)
	ToolTip('')
	GUICtrlSetData($hProgress, 100)
EndFunc   ;==>_UnPack7z

Func _FileProperties()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $aIndex, $sName, $sPath, $sExt
	$aIndex = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	If $aIndex[0] = 0 Then Return _ShowStatus('Fehler! Keine Einträge markiert.', 1)
	For $i = 1 To $aIndex[0]
		$sName = _GUICtrlListView_GetItemText($hwndLV, $aIndex[$i], 0)
		If $sName = '..' Then ContinueLoop
		$sPath = $aDirPath[$iActiveLV] & $sName
		$sExt = _GUICtrlListView_GetItemText($hwndLV, $aIndex[$i], 1)
		If $sExt <> '<DIR>' Then $sPath &= '.' & $sExt
		$oShellApp.namespace(0).parsename($sPath).invokeverb('Properties') ; Thanks Ascend4nt (www.autoitscript.com)
	Next
EndFunc   ;==>_FileProperties

Func _DriveProperties()
	Local $sPath
	Switch @GUI_CtrlId
		Case $ahDriveIcon[0]
			$sPath = StringLeft($aDirPath[0], 2)
		Case $ahDriveIcon[1]
			$sPath = StringLeft($aDirPath[1], 2)
		Case Else
			$sPath = GUICtrlRead(@GUI_CtrlId - 2, 1)
	EndSwitch
	$sPath = _AddTrailingBackslash($sPath)
	If $sPath = '' Or $sPath = '\\' Then Return _ShowStatus('Keine Laufwerks-Informationen verfügbar!', 1)
	$oShellApp.namespace(0).parsename($sPath).invokeverb('Properties') ; Thanks Ascend4nt (www.autoitscript.com)
EndFunc   ;==>_DriveProperties

Func _DeActivateButtons()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $iCount = _GUICtrlListView_GetSelectedCount($hwndLV)
	If $iCount = 0 Or ($iCount = 1 And _GUICtrlListView_GetItemText($hwndLV, 0, 0) = '..' And _GUICtrlListView_GetItemSelected($hwndLV, 0)) Then
		If BitAND(GUICtrlGetState($hRunHexEdit), $GUI_ENABLE) Then
			For $iCtrlID = $hRunHexEdit To $hDelete
				GUICtrlSetState($iCtrlID, $GUI_DISABLE)
			Next
		EndIf
	Else
		If BitAND(GUICtrlGetState($hRunHexEdit), $GUI_DISABLE) Then
			For $iCtrlID = $hRunHexEdit To $hDelete
				GUICtrlSetState($iCtrlID, $GUI_ENABLE)
			Next
		EndIf
	EndIf
	If GUICtrlRead($hEditName) & '|' & GUICtrlRead($hEditPath) <> _GUICtrlListView_GetItemTextString($hEditLV) Then
		If BitAND(GUICtrlGetState($hEditOk), $GUI_DISABLE) Then GUICtrlSetState($hEditOk, $GUI_ENABLE)
	Else
		If BitAND(GUICtrlGetState($hEditOk), $GUI_ENABLE) Then GUICtrlSetState($hEditOk, $GUI_DISABLE)
	EndIf
EndFunc   ;==>_DeActivateButtons

Func _ClearLVHeaderFlags()
	Local $hListView = GUICtrlGetHandle($ahLV[$iActiveLV])
	For $i = 0 To 4
		_GUICtrlHeader_SetItemFlags(_GUICtrlListView_GetHeader($hListView), $i, 0)
	Next
EndFunc   ;==>_ClearLVHeaderFlags

Func _SortLV()
	Local Static $iDescending = False, $iLastCol = 0
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $iCol = GUICtrlGetState(@GUI_CtrlId), $iStart = 0, $aFormat[2] = [8, 4]
	If $iCol = $iLastCol Then
		$iDescending = Not $iDescending
	Else
		$iDescending = False
	EndIf
	_GUICtrlListView_SetItemSelected($hwndLV, -1, False)
	_GUICtrlHeader_SetItemFlags(_GUICtrlListView_GetHeader($hwndLV), $iLastCol, 0)
	_GUICtrlHeader_SetItemFlags(_GUICtrlListView_GetHeader($hwndLV), $iCol, $aFormat[$iDescending])
	$iLastCol = $iCol
	Local $iDirs = StringRegExpReplace(GUICtrlRead($ahInfo[$iActiveLV]), '(\d+) Verzeichnis.+', '$1')
	Local $iFiles = StringRegExpReplace(GUICtrlRead($ahInfo[$iActiveLV]), '.+?(\d+) Datei.+', '$1')
	Local $aPattern[4] = ['(\d{2}).(\d{2}).(\d{4})  (\d{2}):(\d{2}):(\d{2})', '$3$2$1$4$5$6', '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})', '$3.$2.$1  $4:$5:$6']
	If _GUICtrlListView_GetItemText($hwndLV, 0, 0) = '..' Then $iStart = 1
	If $iDirs > 0 Then
		Local $aDirs[$iDirs][5]
		For $i = $iStart To $iDirs - 1 + $iStart
			For $j = 0 To 4
				$aDirs[$i - $iStart][$j] = _GUICtrlListView_GetItemText($hwndLV, $i, $j)
				Switch $j
					Case 2
						If $aDirs[$i - $iStart][$j] <> '-' Then $aDirs[$i - $iStart][$j] = Number(StringReplace($aDirs[$i - $iStart][$j], '.', ''))
					Case 3
						$aDirs[$i - $iStart][$j] = StringRegExpReplace($aDirs[$i - $iStart][$j], $aPattern[0], $aPattern[1])
				EndSwitch
			Next
		Next
		_ArraySort($aDirs, $iDescending, 0, 0, $iCol)
		For $i = $iStart To $iDirs - 1 + $iStart
			For $j = 0 To 4
				Switch $j
					Case 2
						If $aDirs[$i - $iStart][$j] <> '-' Then $aDirs[$i - $iStart][$j] = _StringAddThousandsSep($aDirs[$i - $iStart][$j])
					Case 3
						$aDirs[$i - $iStart][$j] = StringRegExpReplace($aDirs[$i - $iStart][$j], $aPattern[2], $aPattern[3])
				EndSwitch
				_GUICtrlListView_SetItemText($hwndLV, $i, $aDirs[$i - $iStart][$j], $j)
			Next
		Next
		$iStart += $iDirs
	EndIf
	If $iFiles > 0 Then
		Local $aFiles[$iFiles][6]
		For $i = $iStart To $iFiles - 1 + $iStart
			For $j = 0 To 4
				$aFiles[$i - $iStart][$j] = _GUICtrlListView_GetItemText($hwndLV, $i, $j)
				Switch $j
					Case 2
						$aFiles[$i - $iStart][$j] = Number(StringReplace($aFiles[$i - $iStart][$j], '.', ''))
					Case 3
						$aFiles[$i - $iStart][$j] = StringRegExpReplace($aFiles[$i - $iStart][$j], $aPattern[0], $aPattern[1])
				EndSwitch
			Next
			$aFiles[$i - $iStart][5] = _GUICtrlListView_GetItemImage($hwndLV, $i)
		Next
		_ArraySort($aFiles, $iDescending, 0, 0, $iCol)
		For $i = $iStart To $iFiles - 1 + $iStart
			For $j = 0 To 4
				Switch $j
					Case 2
						$aFiles[$i - $iStart][$j] = _StringAddThousandsSep($aFiles[$i - $iStart][$j])
					Case 3
						$aFiles[$i - $iStart][$j] = StringRegExpReplace($aFiles[$i - $iStart][$j], $aPattern[2], $aPattern[3])
				EndSwitch
				_GUICtrlListView_SetItemText($hwndLV, $i, $aFiles[$i - $iStart][$j], $j)
			Next
			_GUICtrlListView_SetItemImage($hwndLV, $i, $aFiles[$i - $iStart][5])
		Next
	EndIf
EndFunc   ;==>_SortLV

Func _MarkAll()
	ControlFocus($hGui, '', $ahLV[$iActiveLV])
	_GUICtrlListView_SetItemSelected($ahLV[$iActiveLV], -1, True)
	If _GUICtrlListView_GetItemText($ahLV[$iActiveLV], 0, 0) = '..' Then _GUICtrlListView_SetItemSelected($ahLV[$iActiveLV], 0, False)
	_ShowStatus('Fertig.', 0)
EndFunc   ;==>_MarkAll

Func _MarkNothing()
	ControlFocus($hGui, '', $ahLV[$iActiveLV])
	_GUICtrlListView_SetItemSelected($ahLV[$iActiveLV], -1, False)
	_ShowStatus('Fertig.', 0)
EndFunc   ;==>_MarkNothing

Func _MarkDirs()
	ControlFocus($hGui, '', $ahLV[$iActiveLV])
	For $i = 0 To _GUICtrlListView_GetItemCount($ahLV[$iActiveLV]) - 1
		If _GUICtrlListView_GetItemText($ahLV[$iActiveLV], $i, 0) = '..' Then ContinueLoop
		_GUICtrlListView_SetItemSelected($ahLV[$iActiveLV], $i, _GUICtrlListView_GetItemText($ahLV[$iActiveLV], $i, 1) = '<DIR>')
	Next
	_ShowStatus('Fertig.', 0)
EndFunc   ;==>_MarkDirs

Func _MarkFiles()
	ControlFocus($hGui, '', $ahLV[$iActiveLV])
	For $i = 0 To _GUICtrlListView_GetItemCount($ahLV[$iActiveLV]) - 1
		If _GUICtrlListView_GetItemText($ahLV[$iActiveLV], $i, 0) = '..' Then ContinueLoop
		_GUICtrlListView_SetItemSelected($ahLV[$iActiveLV], $i, _GUICtrlListView_GetItemText($ahLV[$iActiveLV], $i, 1) <> '<DIR>')
	Next
	_ShowStatus('Fertig.', 0)
EndFunc   ;==>_MarkFiles

Func _MarkSameExt()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $aSelIndices = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	If $aSelIndices[0] = 0 Then Return _ShowStatus('Fehler! Keine Einträge markiert.', 1)
	For $i = 0 To _GUICtrlListView_GetItemCount($hwndLV) - 1
		For $j = 1 To $aSelIndices[0]
			If $i = $aSelIndices[$j] Then ContinueLoop
			If _GUICtrlListView_GetItemText($hwndLV, $i, 1) = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$j], 1) Then
				_GUICtrlListView_SetItemSelected($hwndLV, $i, True)
				ExitLoop
			EndIf
		Next
	Next
	_ShowStatus('Fertig.', 0)
EndFunc   ;==>_MarkSameExt

Func _ReadMarkDirSize()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $aSelIndices
	$aSelIndices = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	_CheckSelArray($hwndLV, $aSelIndices)
	If Not IsArray($aSelIndices) Or $aSelIndices[0] = 0 Then Return _ShowStatus('Fehler! Keine Einträge markiert.', 1)
	Local $sPath, $sName, $iSize
	$sPath = $aDirPath[$iActiveLV]
	For $i = 1 To $aSelIndices[0]
		If $fCancel Then
			$fCancel = False
			If BitAND(WinGetState($hGui), 8) Then Return _ShowStatus('Funktion abgebrochen.', 1)
		EndIf
		If _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 1) = '<DIR>' Then
			$sName = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 0)
			_ShowStatus('Lese Verzeichnis: "' & $sName & '"', 0)
			$iSize = DirGetSize($sPath & $sName)
			If Not @error Then _GUICtrlListView_SetItemText($hwndLV, $aSelIndices[$i], _StringAddThousandsSep($iSize), 2)
		EndIf
		GUICtrlSetData($hProgress, 100 / $aSelIndices[0] * $i)
	Next
	_ShowStatus('Fertig.', 0)
	Sleep(500)
	GUICtrlSetData($hProgress, 0)
EndFunc   ;==>_ReadMarkDirSize

Func _ReadAllDirSize()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $iCount = _GUICtrlListView_GetItemCount($hwndLV), $sPath, $sName, $iSize
	If $iCount = 0 Then Return
	$sPath = $aDirPath[$iActiveLV]
	For $i = 0 To $iCount - 1
		If $fCancel Then
			$fCancel = False
			If BitAND(WinGetState($hGui), 8) Then Return _ShowStatus('Funktion abgebrochen.', 1)
		EndIf
		If _GUICtrlListView_GetItemText($hwndLV, $i, 1) = '<DIR>' Then
			$sName = _GUICtrlListView_GetItemText($hwndLV, $i, 0)
			_GUICtrlStatusBar_SetIcon($hStatus, 0, $aStatusIcons[0])
			_GUICtrlStatusBar_SetText($hStatus, 'Lese Verzeichnis: "' & $sName & '"')
			$iSize = DirGetSize($sPath & _GUICtrlListView_GetItemText($hwndLV, $i, 0))
			If Not @error Then _GUICtrlListView_SetItemText($hwndLV, $i, _StringAddThousandsSep($iSize), 2)
		EndIf
		GUICtrlSetData($hProgress, 100 / $iCount * ($i + 1))
	Next
	_ShowStatus('Fertig.', 0)
	Sleep(500)
	GUICtrlSetData($hProgress, 0)
EndFunc   ;==>_ReadAllDirSize

Func _CheckSelArray(ByRef $hwndLV, ByRef $aSelIndices)
	If $aSelIndices[0] = 0 Then Return
	If _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[1], 0) = '..' Then
		_ArrayDelete($aSelIndices, 1)
		$aSelIndices[0] = UBound($aSelIndices) - 1
	EndIf
EndFunc   ;==>_CheckSelArray

Func _ChangeDate()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $aSelIndices
	$aSelIndices = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	_CheckSelArray($hwndLV, $aSelIndices)
	If Not IsArray($aSelIndices) Or $aSelIndices[0] = 0 Then Return _ShowStatus('Fehler! Keine Einträge markiert.', 1)
	Local $aOption[3] = [1, 0, 2]
	Local $sPath, $sName, $sExt, $sMsg, $aOrigTime, $aNewTime[3], $fRecursive, $iIndex
	$sPath = $aDirPath[$iActiveLV]
	$aOrigTime = _ChangeDateSetData($hwndLV, $aSelIndices[1], $sPath)
	GUISetState(@SW_LOCK, $hGui)
	Opt('GUIOnEventMode', 0)
	GUICtrlSetState($hFTGRecursiv, $GUI_UNCHECKED)
	Local $aWinPos = WinGetPos($hGui)
	WinMove($hFileTimeGui, '', $aWinPos[0] + $aWinPos[2] / 2 - 235, $aWinPos[1] + 150)
	GUISetState(@SW_SHOW, $hFileTimeGui)
	While True
		$sMsg = GUIGetMsg()
		Switch $sMsg
			Case $GUI_EVENT_CLOSE, $hFTGCancel
				ExitLoop
			Case $ahFileDate[0][2], $ahFileDate[1][2], $ahFileDate[2][2]
				Local $iIndex = ($sMsg - $ahFileDate[0][2]) / 5
				Local $aFileTime[6] = [@YEAR, @MON, @MDAY, @HOUR, @MIN, @SEC]
				_ChangeDateSetTime($aFileTime, $iIndex)
			Case $ahFileDate[0][3], $ahFileDate[1][3], $ahFileDate[2][3]
				Local $iIndex = ($sMsg - $ahFileDate[0][3]) / 5
				Local $aFileTime[6]
				For $i = 0 To 5
					$aFileTime[$i] = $aOrigTime[$iIndex][$i]
				Next
				_ChangeDateSetTime($aFileTime, $iIndex)
			Case $hFTGAccept
				GUISetState(@SW_LOCK, $hFileTimeGui)
				$fRecursive = Number(BitAND(GUICtrlRead($hFTGRecursiv), $GUI_CHECKED) = $GUI_CHECKED)
				For $i = 0 To 2
					$aNewTime[$i] = StringRegExpReplace(GUICtrlRead($ahFileDate[$i][0]), '(\d{2}).(\d{2}).(\d{4})', '$3$2$1')
					$aNewTime[$i] &= StringRegExpReplace(GUICtrlRead($ahFileDate[$i][1]), '(\d{2}):(\d{2}):(\d{2})', '$1$2$3')
				Next
				For $i = 1 To $aSelIndices[0]
					$sName = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 0)
					$sExt = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 1)
					If $sExt <> '' Then $sExt = '.' & $sExt
					Switch $sExt
						Case '.<DIR>'
							For $j = 0 To 2
								FileSetTime($sPath & $sName, $aNewTime[$j], $aOption[$j], $fRecursive)
							Next
						Case Else
							For $j = 0 To 2
								FileSetTime($sPath & $sName & $sExt, $aNewTime[$j], $aOption[$j])
							Next
					EndSwitch
				Next
				_CreateListViewItems($ahLV[$iActiveLV], $sPath)
				GUISetState(@SW_UNLOCK, $hFileTimeGui)
				ExitLoop
		EndSwitch
	WEnd
	GUISetState(@SW_HIDE, $hFileTimeGui)
	GUISetState(@SW_UNLOCK, $hGui)
	Opt('GUIOnEventMode', 1)
	_ShowStatus('Fertig.', 0)
EndFunc   ;==>_ChangeDate

Func _ChangeDateSetData(ByRef $hwndLV, ByRef $iIndex, ByRef $sPath)
	Local $aFileTime, $aOrigTime[3][6], $sName, $sExt, $aOption[3] = [1, 0, 2]
	$sName = _GUICtrlListView_GetItemText($hwndLV, $iIndex, 0)
	$sExt = _GUICtrlListView_GetItemText($hwndLV, $iIndex, 1)
	If $sExt <> '' And $sExt <> '<DIR>' Then $sExt = '.' & $sExt
	If $sExt = '<DIR>' Then
		$sExt = ''
		GUICtrlSetState($hFTGRecursiv, $GUI_ENABLE)
		GUICtrlSetData($hFTGFilename, $sPath & $sName & '\')
	Else
		GUICtrlSetState($hFTGRecursiv, $GUI_DISABLE)
		GUICtrlSetData($hFTGFilename, $sPath & $sName & $sExt)
	EndIf
	For $i = 0 To 2
		$aFileTime = FileGetTime($sPath & $sName & $sExt, $aOption[$i])
		_ChangeDateSetTime($aFileTime, $i)
		For $j = 0 To 5
			$aOrigTime[$i][$j] = $aFileTime[$j]
		Next
	Next
	Return $aOrigTime
EndFunc   ;==>_ChangeDateSetData

Func _ChangeDateSetTime(ByRef $aFileTime, $i)
	$ahFileDate[$i][5] = StringFormat('%s/%s/%s', $aFileTime[0], $aFileTime[1], $aFileTime[2])
	$ahFileDate[$i][6] = StringFormat('%s/%s/%s %s:%s:%s', $aFileTime[0], $aFileTime[1], $aFileTime[2], $aFileTime[3], $aFileTime[4], $aFileTime[5])
	GUICtrlSetData($ahFileDate[$i][0], $ahFileDate[$i][5])
	GUICtrlSetData($ahFileDate[$i][1], $ahFileDate[$i][6])
EndFunc   ;==>_ChangeDateSetTime

Func _ChangeAttr()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $aSelIndices
	$aSelIndices = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	_CheckSelArray($hwndLV, $aSelIndices)
	If Not IsArray($aSelIndices) Or $aSelIndices[0] = 0 Then Return _ShowStatus('Fehler! Keine Einträge markiert.', 1)
	Local $sPath, $sName, $sExt, $sNewAttr, $fRecursive
	$sPath = $aDirPath[$iActiveLV]
	GUISetState(@SW_LOCK, $hGui)
	Opt('GUIOnEventMode', 0)
	For $i = 0 To 3
		GUICtrlSetState($ahAttr[$i], $GUI_INDETERMINATE)
	Next
	GUICtrlSetState($hRecursiv, $GUI_UNCHECKED)
	Local $aWinPos = WinGetPos($hGui)
	WinMove($hAttrGui, '', $aWinPos[0] + $aWinPos[2] / 2 - 185, $aWinPos[1] + 150)
	GUISetState(@SW_SHOW, $hAttrGui)
	While True
		Switch GUIGetMsg()
			Case $GUI_EVENT_CLOSE, $hAttrCancel
				ExitLoop
			Case $hAttrAccept
				GUISetState(@SW_LOCK, $hAttrGui)
				$sNewAttr = _ReadAttr()
				$fRecursive = Number(BitAND(GUICtrlRead($hRecursiv), $GUI_CHECKED) = $GUI_CHECKED)
				For $i = 1 To $aSelIndices[0]
					$sName = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 0)
					If $sName = '..' Then ContinueLoop
					$sExt = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 1)
					If $sExt <> '' Then $sExt = '.' & $sExt
					Switch $sExt
						Case '.<DIR>'
							FileSetAttrib($sPath & $sName, $sNewAttr, $fRecursive)
						Case Else
							FileSetAttrib($sPath & $sName & $sExt, $sNewAttr)
					EndSwitch
				Next
				_CreateListViewItems($ahLV[$iActiveLV], $sPath)
				GUISetState(@SW_UNLOCK, $hAttrGui)
				ExitLoop
		EndSwitch
	WEnd
	GUISetState(@SW_HIDE, $hAttrGui)
	GUISetState(@SW_UNLOCK, $hGui)
	Opt('GUIOnEventMode', 1)
	_ShowStatus('Fertig.', 0)
EndFunc   ;==>_ChangeAttr

Func _ReadAttr()
	Local $sNewAttr, $sAttr = 'RASH'
	For $i = 0 To 3
		Switch GUICtrlRead($ahAttr[$i])
			Case $GUI_CHECKED
				$sNewAttr &= '+' & StringMid($sAttr, $i + 1, 1)
			Case $GUI_UNCHECKED
				$sNewAttr &= '-' & StringMid($sAttr, $i + 1, 1)
		EndSwitch
	Next
	Return $sNewAttr
EndFunc   ;==>_ReadAttr

Func _CreateShortcut()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $aSelIndices
	$aSelIndices = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	_CheckSelArray($hwndLV, $aSelIndices)
	If Not IsArray($aSelIndices) Or $aSelIndices[0] = 0 Then Return _ShowStatus('Fehler! Keine Einträge markiert.', 1)
	Local $sPath, $sName, $sExt, $sTmp
	$sPath = $aDirPath[$iActiveLV]
	If Not FileExists($sPath) Then Return _ShowStatus('Fehler! Der Pfad existiert nicht.', 1)
	For $i = 1 To $aSelIndices[0]
		$sName = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 0)
		If $sName = '..' Then ContinueLoop
		$sExt = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 1)
		If $sExt <> '' Then $sExt = '.' & $sExt
		Switch $sExt
			Case '.<DIR>'
				FileCreateShortcut($sPath & $sName, $sPath & $sName & '.lnk')
			Case Else
				FileCreateShortcut($sPath & $sName & $sExt, $sPath & $sName & '.lnk', $sPath)
		EndSwitch
	Next
	_CreateListViewItems($ahLV[$iActiveLV], $sPath)
	_ShowStatus('Fertig.', 0)
EndFunc   ;==>_CreateShortcut

Func _Rename()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $aSelIndices
	$aSelIndices = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	_CheckSelArray($hwndLV, $aSelIndices)
	If Not IsArray($aSelIndices) Or $aSelIndices[0] = 0 Then Return _ShowStatus('Fehler! Keine Einträge markiert.', 1)
	Local $sPath, $sName, $sExt, $sTmp
	$sPath = $aDirPath[$iActiveLV]
	If Not FileExists($sPath) Then Return _ShowStatus('Fehler! Der Pfad existiert nicht.', 1)
	Local $aWinPos = WinGetPos($hGui)
	For $i = 1 To $aSelIndices[0]
		$sName = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 0)
		If $sName = '..' Then ContinueLoop
		$sExt = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 1)
		If $sExt <> '' Then $sExt = '.' & $sExt
		Switch $sExt
			Case '.<DIR>'
				$sTmp = InputBox($sTitle, 'Verzeichnis umbenennen', $sName, '', 320, 135, $aWinPos[0] + $aWinPos[2] / 2 - 160, $aWinPos[1] + 150, 0, $hGui)
				If @error Then Return
				If $sTmp == $sName Then ContinueLoop
				If DirMove($sPath & $sName, $sPath & $sTmp) Then
					_LogWrite('Dir "' & $sPath & $sName & '" renamed to "' & $sPath & $sTmp & '"')
					_ShowStatus('Verzeichnis umbenannt.', 0)
				Else
					_ShowStatus('Fehler! Verzeichnis konnte nicht umbenannt werden.', 1)
				EndIf
			Case Else
				$sTmp = InputBox($sTitle, 'Datei umbenennen', $sName & $sExt, '', 320, 135, $aWinPos[0] + $aWinPos[2] / 2 - 160, $aWinPos[1] + 150, 0, $hGui)
				If @error Then Return
				If $sTmp == $sName & $sExt Then ContinueLoop
				If FileMove($sPath & $sName & $sExt, $sPath & $sTmp) Then
					_LogWrite('File "' & $sPath & $sName & $sExt & '" renamed to "' & $sPath & $sTmp & '"')
					_ShowStatus('Datei umbenannt.', 0)
				Else
					_ShowStatus('Fehler! Datei konnte nicht umbenannt werden.', 1)
				EndIf
		EndSwitch
	Next
	_CreateListViewItems($ahLV[$iActiveLV], $sPath)
	Sleep(2000)
	_ShowStatus('Fertig.', 0)
EndFunc   ;==>_Rename

Func _Cancel()
	$fCancel = True
EndFunc   ;==>_Cancel

Func _CopyMoveSelItems()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $aSelIndices
	$aSelIndices = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	_CheckSelArray($hwndLV, $aSelIndices)
	If Not IsArray($aSelIndices) Or $aSelIndices[0] = 0 Then Return _ShowStatus('Fehler! Keine Einträge markiert.', 1)
	Local $sSourcePath, $sDestPath, $sName, $sExt, $sCopyFiles, $aCopyFiles, $aWinPos, $aDirSize, $sNewDir
	$sSourcePath = $aDirPath[$iActiveLV]
	If Not FileExists($sSourcePath) Then Return _ShowStatus('Fehler! Der Quellpfad existiert nicht.', 1)
	$sDestPath = $aDirPath[1 - $iActiveLV]
	If Not FileExists($sDestPath) Then Return _ShowStatus('Fehler! Der Zielpfad existiert nicht.', 1)
	Switch @GUI_CtrlId
		Case $hCopy
			Local $aMsg[2] = ['Kopiervorgang abgebrochen.', 'Kopiere']
		Case $hMove
			Local $aMsg[2] = ['Verschiebevorgang abgebrochen.', 'Verschiebe']
	EndSwitch
	_ShowStatus('Erstelle Liste der Dateien. Bitte warten!', 0)
	$iCopySize = 0
	$iCopyTransferred = 0
	GUICtrlSetData($hProgress, 0)
	For $i = 1 To $aSelIndices[0]
		$sName = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 0)
		If $sName = '..' Then ContinueLoop
		$sExt = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 1)
		If $sExt <> '' Then $sExt = '.' & $sExt
		Switch $sExt
			Case '.<DIR>'
				$sCopyFiles &= $sSourcePath & $sName & '\' & @CR
				$sCopyFiles &= _RecursiveFileListToArray($sSourcePath & $sName, 0, 0)
			Case Else
				$iCopySize += FileGetSize($sSourcePath & $sName & $sExt)
				$sCopyFiles &= $sSourcePath & $sName & $sExt & @CR
		EndSwitch
		GUICtrlSetData($hProgress, 100 / $aSelIndices[0] * $i)
	Next
	_ShowStatus($aMsg[1] & ' Dateien...', 0)
	$aCopyFiles = StringSplit(StringTrimRight($sCopyFiles, 1), @CR)
	$aWinPos = WinGetPos($hGui)
	WinMove($hCopyGui, '', $aWinPos[0] + $aWinPos[2] / 2 - 352, $aWinPos[1] + 160)
	GUICtrlSetData($ahCopyInfo[2], $aMsg[1] & '...')
	GUICtrlSetData($ahCopyInfo[3], '')
	For $i = 0 To 1
		GUICtrlSetData($ahCopyInfo[$i], '')
		GUICtrlSetData($ahCopyProgressFile[$i], 0 & _Iif($i = 0, '%', ''))
		GUICtrlSetData($ahCopyProgressAll[$i], 0 & _Iif($i = 0, '%', ''))
	Next
	GUISetState(@SW_SHOW, $hCopyGui)
	Opt('GUIOnEventMode', 0)
	Local $fSkipAll = False, $fOverwriteAll = False, $sDelDir, $sDestName
	$iCopyTimer = TimerInit()
	For $i = 1 To $aCopyFiles[0]
		$aCopyFiles[$i] = StringReplace($aCopyFiles[$i], $sSourcePath, '')
		If StringRight($aCopyFiles[$i], 1) = '\' Then
			$aDirSize = DirGetSize($sSourcePath & $aCopyFiles[$i], 3)
			If $aDirSize[1] = 0 And $aDirSize[2] = 0 Then ; If directory is empty, then create it in destination dir
				If DirCreate($sDestPath & $aCopyFiles[$i]) And @GUI_CtrlId = $hMove Then DirRemove($sSourcePath & $aCopyFiles[$i])
			EndIf
			ContinueLoop
		EndIf
		GUICtrlSetData($ahCopyInfo[0], '"' & $aCopyFiles[$i] & '"')
		GUICtrlSetTip($ahCopyInfo[0], $aCopyFiles[$i])
		GUICtrlSetData($ahCopyInfo[1], '"' & $sDestPath & '"')
		GUICtrlSetTip($ahCopyInfo[1], $sDestPath)
		$sDestName = $aCopyFiles[$i]
		If FileExists($sDestPath & $aCopyFiles[$i]) Then
			GUICtrlSetData($hCopyFileExists, $sDestPath & $aCopyFiles[$i])
			If $fSkipAll Then ContinueLoop
			If Not $fOverwriteAll Then
				$aWinPos = WinGetPos($hCopyGui)
				WinMove($hExistsGui, '', $aWinPos[0] + $aWinPos[2] / 2 - 285, $aWinPos[1] + 120)
				GUISetState(@SW_SHOW, $hExistsGui)
				_PlayDefaultSystemSound('SystemExclamation')
				While True
					Switch GUIGetMsg()
						Case $GUI_EVENT_CLOSE, $hExistsCancel
							GUISetState(@SW_HIDE, $hExistsGui)
							GUISetState(@SW_HIDE, $hCopyGui)
							If @GUI_CtrlId = $hMove Then _CreateListViewItems($ahLV[$iActiveLV], $sSourcePath)
							_CreateListViewItems($ahLV[1 - $iActiveLV], $sDestPath)
							GUICtrlSetData($hProgress, 0)
							_ShowStatus($aMsg[0], 1)
							Opt('GUIOnEventMode', 1)
							Return
						Case $hExistsRename
							Do
								$sDestName = InputBox('Datei umbenennen', 'Bitte neuen Dateinamen eingeben:', $aCopyFiles[$i], '', 320, 140, $aWinPos[0] + $aWinPos[2] / 2 - 160, $aWinPos[1] + 150, 0, $hExistsGui)
								If @error Then ContinueLoop 2
							Until Not FileExists($sDestPath & $sDestName)
							ExitLoop
						Case $hExistsSkip
							GUISetState(@SW_HIDE, $hExistsGui)
							ContinueLoop 2
						Case $hExistsSkipAll
							GUISetState(@SW_HIDE, $hExistsGui)
							$fSkipAll = True
							ContinueLoop 2
						Case $hExistsOverwrite
							ExitLoop
						Case $hExistsOverwriteAll
							$fOverwriteAll = True
							ExitLoop
					EndSwitch
				WEnd
				GUISetState(@SW_HIDE, $hExistsGui)
			EndIf
		EndIf
		Switch @GUI_CtrlId
			Case $hCopy
				_FileProgressCopy($sSourcePath & $aCopyFiles[$i], $sDestPath & $sDestName)
				If Not @error Then
					_LogWrite('File "' & $sSourcePath & $aCopyFiles[$i] & '" copied to "' & $sDestPath & $sDestName & '"')
				Else
					GUISetState(@SW_HIDE, $hCopyGui)
					_CreateListViewItems($ahLV[1 - $iActiveLV], $sDestPath)
					GUICtrlSetData($hProgress, 0)
					_ShowStatus($aMsg[0], 1)
					Opt('GUIOnEventMode', 1)
					Return
				EndIf
			Case $hMove
				If StringLeft($sSourcePath, 2) = StringLeft($sDestPath, 2) Then
					If FileMove($sSourcePath & $aCopyFiles[$i], $sDestPath & $sDestName, 9) Then _
							_LogWrite('File "' & $sSourcePath & $aCopyFiles[$i] & '" moved to "' & $sDestPath & $sDestName & '"')
				Else
					_FileProgressCopy($sSourcePath & $aCopyFiles[$i], $sDestPath & $sDestName)
					If Not @error Then
						If FileDelete($sSourcePath & $aCopyFiles[$i]) Then _
								_LogWrite('File "' & $sSourcePath & $aCopyFiles[$i] & '" moved to "' & $sDestPath & $sDestName & '"')
					Else
						GUISetState(@SW_HIDE, $hCopyGui)
						_CreateListViewItems($ahLV[$iActiveLV], $sSourcePath)
						_CreateListViewItems($ahLV[1 - $iActiveLV], $sDestPath)
						GUICtrlSetData($hProgress, 0)
						_ShowStatus($aMsg[0], 1)
						Opt('GUIOnEventMode', 1)
						Return
					EndIf
				EndIf
				$sDelDir = StringLeft($aCopyFiles[$i], StringInStr($aCopyFiles[$i], '\'))
				If $sDelDir <> '' Then
					$aDirSize = DirGetSize($sSourcePath & $sDelDir, 1)
					If $aDirSize[1] = 0 Then DirRemove($sSourcePath & $sDelDir, 1)
				EndIf
		EndSwitch
	Next
	GUISetState(@SW_HIDE, $hCopyGui)
	If @GUI_CtrlId = $hMove Then _CreateListViewItems($ahLV[$iActiveLV], $sSourcePath)
	_CreateListViewItems($ahLV[1 - $iActiveLV], $sDestPath)
	GUICtrlSetData($hProgress, 0)
	_ShowStatus('Fertig', 0)
	Opt('GUIOnEventMode', 1)
EndFunc   ;==>_CopyMoveSelItems

Func _FileProgressCopy($sSourceFile, $sDestFile)
	Local $hSource, $hDest, $sMsg, $sBuffer, $iBufferSize, $iTimer, $iPercent, $iFileSize, $iBytesTransferred = 0, $iRet
	If FileGetSize($sSourceFile) < 16777216 Then ; bei Dateien kleiner als 16 MByte
		$iBufferSize = 524288 ; 512 KByte Buffer verwenden
	Else ; sonst (> 16 MByte)
		$iBufferSize = 8388608 ; 8192 KByte Buffer verwenden
	EndIf
	$hSource = FileOpen($sSourceFile, 16)
	If $hSource = -1 Then Return SetError(1, 0, 0)
	$hDest = FileOpen($sDestFile, 26)
	If $hDest = -1 Then Return SetError(2, 0, 0)
	$iFileSize = FileGetSize($sSourceFile)
	$iTimer = TimerInit()
	Do
		$sMsg = GUIGetMsg()
		If $fCancel Or $sMsg = $hCopyCancel Or $sMsg = $GUI_EVENT_CLOSE Then
			$fCancel = False
			If BitAND(WinGetState($hCopyGui), 8) Then
				FileClose($hSource)
				FileClose($hDest)
				FileDelete($sDestFile)
				Return SetError(3, 0, 0)
			EndIf
		EndIf
		$sBuffer = FileRead($hSource, $iBufferSize)
		$iBytesTransferred += @extended
		$iCopyTransferred += @extended
		If @error Then ExitLoop
		$iRet = FileWrite($hDest, $sBuffer)
		If TimerDiff($iTimer) > 250 Then
			$iTimer = TimerInit()
			_ShowProgress($iFileSize, $iBytesTransferred, $iCopySize, $iCopyTransferred)
		EndIf
	Until $iRet = 0
	_ShowProgress($iFileSize, $iBytesTransferred, $iCopySize, $iCopyTransferred)
	FileClose($hDest)
	FileClose($hSource)
	Return SetError(0, 0, 1)
EndFunc   ;==>_FileProgressCopy

Func _ShowProgress($iFileSize, $iBytesTransferred, $iCopySize, $iCopyTransferred)
	Local $iPercent, $iMBps, $iEndTime
	$iPercent = Int(100 / $iCopySize * $iCopyTransferred)
	GUICtrlSetData($ahCopyProgressAll[0], $iPercent & '%')
	GUICtrlSetData($ahCopyProgressAll[1], $iPercent)
	If TimerDiff($iCopyTimer) < 500 Then Return
	$iPercent = Int(100 / $iFileSize * $iBytesTransferred)
	GUICtrlSetData($ahCopyProgressFile[0], $iPercent & '%')
	GUICtrlSetData($ahCopyProgressFile[1], $iPercent)
	$iMBps = ($iCopyTransferred / TimerDiff($iCopyTimer) * 1000) / 1048576
	$iEndTime = ($iCopySize - $iCopyTransferred) / ($iMBps * 1048576)
	GUICtrlSetData($ahCopyInfo[3], StringFormat('%.2f MB/s,  Restzeit (ca.): %d s', $iMBps, $iEndTime))
EndFunc   ;==>_ShowProgress

Func _Delete()
	Local $hwndLV = GUICtrlGetHandle($ahLV[$iActiveLV]), $aSelIndices
	$aSelIndices = _GUICtrlListView_GetSelectedIndicesNew($hwndLV, True)
	_CheckSelArray($hwndLV, $aSelIndices)
	If Not IsArray($aSelIndices) Or $aSelIndices[0] = 0 Then Return _ShowStatus('Fehler! Keine Einträge markiert.', 1)
	Local $sPath, $sName, $sExt
	If MsgBox(4 + 48 + 256, $sTitle, 'Sollen die markierten Verzeichnisse und Dateien' & @CR & 'wirklich von der Festplatte gelöscht werden?', 0, $hGui) = 7 Then
		Return _ShowStatus('Funktion abgebrochen.', 1)
	Else
		$sPath = $aDirPath[$iActiveLV]
		If Not FileExists($sPath) Then Return _ShowStatus('Fehler! Der Pfad existiert nicht.', 1)
		_ShowStatus('Lösche markierte Dateien und Verzeichnisse. Bitte warten!', 0)
		For $i = 1 To $aSelIndices[0]
			If $fCancel Then
				$fCancel = False
				If BitAND(WinGetState($hGui), 8) Then
					_ShowStatus('Löschvorgang abgebrochen.', 1)
					_CreateListViewItems($ahLV[$iActiveLV], $sPath)
					Return
				EndIf
			EndIf
			$sName = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 0)
			If $sName = '..' Then ContinueLoop
			$sExt = _GUICtrlListView_GetItemText($hwndLV, $aSelIndices[$i], 1)
			If $sExt <> '' Then $sExt = '.' & $sExt
			Switch $sExt
				Case '.<DIR>'
					If DirRemove($sPath & $sName, 1) Then _LogWrite('Delete DIR "' & $sPath & $sName & '"')
				Case Else
					If FileDelete($sPath & $sName & $sExt) Then _LogWrite('Delete FILE "' & $sPath & $sName & $sExt & '"')
			EndSwitch
			GUICtrlSetData($hProgress, 100 / $aSelIndices[0] * $i)
		Next
		_CreateListViewItems($ahLV[$iActiveLV], $sPath)
		_ShowStatus('Fertig.', 0)
		Sleep(500)
		GUICtrlSetData($hProgress, 0)
	EndIf
EndFunc   ;==>_Delete

Func _SwitchLogfile()
	$fLogfile = Not $fLogfile
	Switch $fLogfile
		Case True
			GUICtrlSetState($hLogfile, $GUI_CHECKED)
		Case False
			GUICtrlSetState($hLogfile, $GUI_UNCHECKED)
	EndSwitch
	IniWrite($sIniFile, 'Config', 'Logfile', $fLogfile)
EndFunc   ;==>_SwitchLogfile

Func _SwitchShowDrives()
	$fShowDrives = Not $fShowDrives
	Switch $fShowDrives
		Case True
			GUICtrlSetState($hShowDrives, $GUI_CHECKED)
		Case False
			GUICtrlSetState($hShowDrives, $GUI_UNCHECKED)
	EndSwitch
	IniWrite($sIniFile, 'Config', 'ShowDrives', $fShowDrives)
	_CreateDriveButtons(True)
	_MarkLVButton(0)
	_MarkLVButton(1)
EndFunc   ;==>_SwitchShowDrives

Func _SwitchHidden()
	$fShowHidden = Not $fShowHidden
	Switch $fShowHidden
		Case True
			GUICtrlSetState($hShowHidden, $GUI_CHECKED)
		Case False
			GUICtrlSetState($hShowHidden, $GUI_UNCHECKED)
	EndSwitch
	IniWrite($sIniFile, 'Config', 'ShowHidden', $fShowHidden)
	_CreateListViewItems($ahLV[0], $aDirPath[0])
	_CreateListViewItems($ahLV[1], $aDirPath[1])
EndFunc   ;==>_SwitchHidden

Func _SwitchLargeIcons()
	$fLargeIcons = Not $fLargeIcons
	Switch $fLargeIcons
		Case True
			GUICtrlSetState($hLargeIcons, $GUI_CHECKED)
		Case False
			GUICtrlSetState($hLargeIcons, $GUI_UNCHECKED)
	EndSwitch
	IniWrite($sIniFile, 'Config', 'LargeIcons', $fLargeIcons)
	_GUICtrlListView_SetImageList($ahLV[0], _GUIImageList_GetSystemImageList($fLargeIcons), 1)
	GUICtrlSetFont($ahLV[0], 9 + Number($fLargeIcons), 400, 0, 'Tahoma', 5)
	_GUICtrlListView_SetImageList($ahLV[1], _GUIImageList_GetSystemImageList($fLargeIcons), 1)
	GUICtrlSetFont($ahLV[1], 9 + Number($fLargeIcons), 400, 0, 'Tahoma', 5)
EndFunc   ;==>_SwitchLargeIcons

Func _SwitchGridLines()
	$fGridLines = Not $fGridLines
	Switch $fGridLines
		Case True
			GUICtrlSetState($hGridLines, $GUI_CHECKED)
			_GUICtrlListView_SetExtendedListViewStyle($ahLV[0], $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
			_GUICtrlListView_SetExtendedListViewStyle($ahLV[1], $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
		Case False
			GUICtrlSetState($hGridLines, $GUI_UNCHECKED)
			_GUICtrlListView_SetExtendedListViewStyle($ahLV[0], 0, $LVS_EX_GRIDLINES)
			_GUICtrlListView_SetExtendedListViewStyle($ahLV[1], 0, $LVS_EX_GRIDLINES)
	EndSwitch
	IniWrite($sIniFile, 'Config', 'GridLines', $fGridLines)
EndFunc   ;==>_SwitchGridLines

Func _LogWrite($sLine)
	If $fLogfile Then FileWriteLine($sLogfile, StringFormat('%02i.%02i.%04i %02i:%02i:%02i   %s', @MDAY, @MON, @YEAR, @HOUR, @MIN, @SEC, $sLine))
EndFunc   ;==>_LogWrite

Func _LVActUp()
	Local $sPath = StringRegExpReplace($aDirPath[$iActiveLV], '(.+\\).+\\', '$1')
	If Not FileExists($sPath) Then Return _ShowStatus('Pfad existiert nicht!', 1)
	_ClearLVHeaderFlags()
	$aDirPath[$iActiveLV] = $sPath
	ControlFocus($hGui, '', $ahLV[$iActiveLV])
	GUICtrlSetData($ahPath[$iActiveLV], $sPath)
	_CreateListViewItems($ahLV[$iActiveLV], $sPath)
	StringReplace($aDirPath[$iActiveLV], '\', '')
	Local $iLastItem = @extended + 1
	_GUICtrlListView_EnsureVisible(GUICtrlGetHandle($ahLV[$iActiveLV]), $aLastTopIndex[$iActiveLV][$iLastItem][0])
	_GUICtrlListView_SetItemSelected($ahLV[$iActiveLV], $aLastTopIndex[$iActiveLV][$iLastItem][1], True, True)
EndFunc   ;==>_LVActUp

Func _LVLeftUp()
	Local $sPath = StringRegExpReplace($aDirPath[0], '(.+\\).+\\', '$1')
	If Not FileExists($sPath) Then Return _ShowStatus('Pfad existiert nicht!', 1)
	_ClearLVHeaderFlags()
	$aDirPath[0] = $sPath
	ControlFocus($hGui, '', $ahLV[0])
	GUICtrlSetData($ahPath[0], $sPath)
	_CreateListViewItems($ahLV[0], $sPath)
	StringReplace($aDirPath[0], '\', '')
	Local $iLastItem = @extended + 1
	_GUICtrlListView_EnsureVisible(GUICtrlGetHandle($ahLV[0]), $aLastTopIndex[0][$iLastItem][0])
	_GUICtrlListView_SetItemSelected($ahLV[0], $aLastTopIndex[0][$iLastItem][1], True, True)
EndFunc   ;==>_LVLeftUp

Func _LVRightUp()
	Local $sPath = StringRegExpReplace($aDirPath[1], '(.+\\).+\\', '$1')
	If Not FileExists($sPath) Then Return _ShowStatus('Pfad existiert nicht!', 1)
	_ClearLVHeaderFlags()
	$aDirPath[1] = $sPath
	ControlFocus($hGui, '', $ahLV[1])
	GUICtrlSetData($ahPath[1], $sPath)
	_CreateListViewItems($ahLV[1], $sPath)
	StringReplace($aDirPath[1], '\', '')
	Local $iLastItem = @extended + 1
	_GUICtrlListView_EnsureVisible(GUICtrlGetHandle($ahLV[1]), $aLastTopIndex[1][$iLastItem][0])
	_GUICtrlListView_SetItemSelected($ahLV[1], $aLastTopIndex[1][$iLastItem][1], True, True)
EndFunc   ;==>_LVRightUp

Func _ReloadLeftLV()
	_ClearLVHeaderFlags()
	ControlFocus($hGui, '', $ahLV[0])
	_CreateListViewItems($ahLV[0], $aDirPath[0])
EndFunc   ;==>_ReloadLeftLV

Func _ReloadRightLV()
	_ClearLVHeaderFlags()
	ControlFocus($hGui, '', $ahLV[1])
	_CreateListViewItems($ahLV[1], $aDirPath[1])
EndFunc   ;==>_ReloadRightLV

Func _ReadPath()
	Local $sPath = _AddTrailingBackslash(GUICtrlRead($ahPath[$iActiveLV]))
	;Consolewrite($sPath& @CRLF)
	If Not FileExists($sPath) Then
		GUICtrlSetData($ahPath[$iActiveLV], $aDirPath[$iActiveLV])
		Return _ShowStatus('Fehler! Pfad existiert nicht.', 1)
	EndIf
						If DriveStatus(StringLeft($sPath,3)) = 'READY' Then
		GUICtrlSetData($ahPath[$iActiveLV], $aDirPath[$iActiveLV])
		Return _ShowStatus('Zugriff verweigert!', 1)
	EndIf
	GUICtrlSetData($ahPath[$iActiveLV], $sPath)
	$aDirPath[$iActiveLV] = $sPath
	_MarkLVButton($iActiveLV)
	_CreateListViewItems($ahLV[$iActiveLV], $aDirPath[$iActiveLV])
EndFunc   ;==>_ReadPath

Func _NewFile()
	Local $sPath, $sFilename, $hFile, $aWinPos = WinGetPos($hGui)
	$sPath = $aDirPath[$iActiveLV]
	If Not FileExists($sPath) Then Return _ShowStatus('Fehler! Pfad existiert nicht.', 1)
	$sFilename = InputBox('Neue Datei', 'Bitte Dateinamen eingeben:', 'neu.txt', '', 270, 130, $aWinPos[0] + $aWinPos[2] / 2 - 135, $aWinPos[1] + 150, 0, $hGui)
	If @error Then
		_GUICtrlStatusBar_SetIcon($hStatus, 0, $aStatusIcons[1])
		_GUICtrlStatusBar_SetText($hStatus, 'Funktion abgebrochen.')
		Return
	EndIf
	_ClearLVHeaderFlags()
	$sFilename = _GetUniqueFileName($sPath & $sFilename)
	$hFile = FileOpen($sFilename, 2)
	If $hFile <> -1 Then
		FileClose($hFile)
		_CreateListViewItems($ahLV[$iActiveLV], $sPath)
		_ShowStatus('Die Datei "' & $sFilename & '" wurde erstellt.', 0)
	Else
		_ShowStatus('Fehler! Datei konnte nicht erstellt werden.', 1)
	EndIf
EndFunc   ;==>_NewFile

Func _NewDir()
	Local $sPath, $sFilename, $hFile, $aWinPos = WinGetPos($hGui)
	$sPath = $aDirPath[$iActiveLV]
	If Not FileExists($sPath) Then Return _ShowStatus('Fehler! Pfad existiert nicht.', 1)
	While True
		$sFilename = InputBox('Neues Verzeichnis', 'Bitte Verzeichnisnamen eingeben:', 'neu', '', 270, 130, $aWinPos[0] + $aWinPos[2] / 2 - 135, $aWinPos[1] + 150, 0, $hGui)
		If @error Then
			_GUICtrlStatusBar_SetIcon($hStatus, 0, $aStatusIcons[1])
			_GUICtrlStatusBar_SetText($hStatus, 'Funktion abgebrochen.')
			Return
		EndIf
		If Not FileExists($sPath & $sFilename) Then ExitLoop
		_PlayDefaultSystemSound('SystemHand')
		_GUICtrlStatusBar_SetIcon($hStatus, 0, $aStatusIcons[1])
		_GUICtrlStatusBar_SetText($hStatus, 'Fehler! Ein Verzeichnis mit diesem Namen existiert bereits.')
	WEnd
	_ClearLVHeaderFlags()
	If DirCreate($sPath & $sFilename) Then
		_CreateListViewItems($ahLV[$iActiveLV], $sPath)
		_ShowStatus('Das Verzeichnis "' & $sPath & $sFilename & '" wurde erstellt.', 0)
	Else
		_ShowStatus('Fehler! Verzeichnis konnte nicht erstellt werden.', 1)
	EndIf
EndFunc   ;==>_NewDir

Func _MarkLVButton($iSide)
	For $i = 1 To $aDrives[0]
		If StringLeft($aDirPath[$iSide], 2) = GUICtrlRead($ahDriveButtons[$i - 1][$iSide]) Then
			_GUICtrlButton_SetState($ahDriveButtons[$i - 1][$iSide], True)
		Else
			_GUICtrlButton_SetState($ahDriveButtons[$i - 1][$iSide], False)
		EndIf
	Next
EndFunc   ;==>_MarkLVButton

Func _ReadDriveLeft()
	Local $sPath = GUICtrlRead(@GUI_CtrlId, 1)
	If $sPath = '\\' Then
		$sPath = FileSelectFolder('Netzwerkpfad auswählen', '::{208D2C60-3AEA-1069-A2D7-08002B30309D}', 2, '::{208D2C60-3AEA-1069-A2D7-08002B30309D}', $hGui)
		If @error Then Return
	EndIf
	If DriveStatus(StringLeft($sPath,3)) <> 'READY' Then Return _ShowStatus('Fehler! Laufwerk nicht bereit.', 1)
	For $i = 1 To $aDrives[0]
		_GUICtrlButton_SetState($ahDriveButtons[$i - 1][0], False)
	Next
	GUICtrlSetState(@GUI_CtrlId, $GUI_DISABLE)
	_GUICtrlButton_SetState(@GUI_CtrlId)
	GUICtrlSetState(@GUI_CtrlId, $GUI_ENABLE)
	$sPath = _AddTrailingBackslash($sPath)
	$aDirPath[0] = $sPath
	_ClearLVHeaderFlags()
	GUICtrlSetState($ahLV[0], $GUI_FOCUS)
	GUICtrlSetData($ahPath[0], $sPath)
	_CreateListViewItems($ahLV[0], $sPath)
	StringReplace($sPath, '\', '')
	$aLastTopIndex[0][@extended][0] = 0
	$aLastTopIndex[0][@extended][1] = 0
EndFunc   ;==>_ReadDriveLeft

Func _ReadDriveRight()
	Local $sPath = GUICtrlRead(@GUI_CtrlId, 1)
	If $sPath = '\\' Then
		$sPath = FileSelectFolder('Netzwerkpfad auswählen', '::{208D2C60-3AEA-1069-A2D7-08002B30309D}', 2, '::{208D2C60-3AEA-1069-A2D7-08002B30309D}', $hGui)
		If @error Then Return
	EndIf
	If DriveStatus(StringLeft($sPath,3)) <> 'READY' Then Return _ShowStatus('Fehler! Laufwerk nicht bereit.', 1)
	For $i = 1 To $aDrives[0]
		_GUICtrlButton_SetState($ahDriveButtons[$i - 1][1], False)
	Next
	GUICtrlSetState(@GUI_CtrlId, $GUI_DISABLE)
	_GUICtrlButton_SetState(@GUI_CtrlId)
	GUICtrlSetState(@GUI_CtrlId, $GUI_ENABLE)
	$sPath = _AddTrailingBackslash($sPath)
	$aDirPath[1] = $sPath
	_ClearLVHeaderFlags()
	GUICtrlSetState($ahLV[1], $GUI_FOCUS)
	GUICtrlSetData($ahPath[1], $sPath)
	_CreateListViewItems($ahLV[1], $sPath)
	StringReplace($sPath, '\', '')
	$aLastTopIndex[1][@extended][0] = 0
	$aLastTopIndex[1][@extended][1] = 0
EndFunc   ;==>_ReadDriveRight

Func _CreateListViewItems(ByRef $hListView, $sPath)
	Local $sDriveIcon, $aDirs, $aFiles, $iIndex, $aDate, $sDate, $sAttr, $iSize, $sName, $sExt, $iDirSize = 0, $sInfo, $sDrive, $sLabel, $iDirsCount = 0, $iFilesCount = 0
	If Not FileExists($sPath) Then Return _ShowStatus('Fehler! Pfad existiert nicht.', 1)
	If DriveStatus(StringLeft($sPath,3)) <> 'READY' Then Return _ShowStatus('Fehler! Laufwerk nicht bereit.', 1)
	_GUICtrlStatusBar_SetIcon($hStatus, 0, $aStatusIcons[0])
	_GUICtrlStatusBar_SetText($hStatus, 'Lese Verzeichnis. Bitte warten!')
;~ 	ToolTip('Lese Verzeichnis. Bitte warten!', Default, Default, $sTitle, 1, 1)
;~ 	_GUICtrlListView_BeginUpdate(GUICtrlGetHandle($hListView))
	_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView))
	If StringLen($sPath) > 3 Then $iIndex = _GUICtrlListView_AddItem($hListView, '..', $UP_ICON_INDEX, _GUICtrlListView_GetItemCount($hListView) + 9999) + 1
	$aDirs = _FileListToArray($sPath, '*', 2)
	If Not @error Then
		Local $aItems[$aDirs[0]][6]
		For $i = 1 To $aDirs[0]
			If Not _IsReparsePoint($sPath & $aDirs[$i]) Then
				$aDate = FileGetTime($sPath & $aDirs[$i], 0, 0)
				If IsArray($aDate) Then
					$sDate = $aDate[2] & '.' & $aDate[1] & '.' & $aDate[0] & ' ' & $aDate[3] & ':' & $aDate[4] & ':' & $aDate[5]
				Else
					$sDate = '00.00.0000 00:00:00'
				EndIf
				$sAttr = StringRegExpReplace(FileGetAttrib($sPath & $aDirs[$i]), '[NDOCT]', '')
				If Not $fShowHidden And StringInStr($sAttr, 'H') Then ContinueLoop
				$aItems[$iDirsCount][0] = $FOLDER_ICON_INDEX
				$aItems[$iDirsCount][1] = $aDirs[$i]
				$aItems[$iDirsCount][2] = '<DIR>'
				$aItems[$iDirsCount][3] = '-'
				$aItems[$iDirsCount][4] = $sDate
				$aItems[$iDirsCount][5] = $sAttr
				$iDirsCount += 1
			EndIf
		Next
		If $iDirsCount > 0 Then
			ReDim $aItems[$iDirsCount][6]
			_GUICtrlListView_SetItemCount($hListView, $iDirsCount)
			_GUICtrlListView_AddArrayEx($hListView, $aItems)
		EndIf
	EndIf
	$aFiles = _FileListToArray($sPath, '*', 1)
	If Not @error Then
		Local $aItems[$aFiles[0]][6]
		_GUICtrlListView_SetItemCount($hListView, $iDirsCount + $aFiles[0])
		For $i = 1 To $aFiles[0]
			$sAttr = StringRegExpReplace(FileGetAttrib($sPath & $aFiles[$i]), '[NDOCT]', '')
			If Not $fShowHidden And StringInStr($sAttr, 'H') Then ContinueLoop
			$aDate = FileGetTime($sPath & $aFiles[$i], 0, 0)
			$sDate = $aDate[2] & '.' & $aDate[1] & '.' & $aDate[0] & ' ' & $aDate[3] & ':' & $aDate[4] & ':' & $aDate[5]
			$iSize = FileGetSize($sPath & $aFiles[$i])
			$iDirSize += $iSize
			$sName = StringRegExpReplace($aFiles[$i], '(.*)\..*', '$1')
			$sExt = StringRegExpReplace($aFiles[$i], '.*\.(.*)', '$1')
			If $sExt = $aFiles[$i] Then $sExt = ''
			$aItems[$iFilesCount][0] = _GUIImageList_GetFileIconIndex($sPath & $aFiles[$i], $fLargeIcons)
			$aItems[$iFilesCount][1] = $sName
			$aItems[$iFilesCount][2] = $sExt
			$aItems[$iFilesCount][3] = _StringAddThousandsSep($iSize)
			$aItems[$iFilesCount][4] = $sDate
			$aItems[$iFilesCount][5] = $sAttr
			$iFilesCount += 1
		Next
		If $iFilesCount > 0 Then
			ReDim $aItems[$iFilesCount][6]
			_GUICtrlListView_AddArrayEx($hListView, $aItems)
		EndIf
	EndIf
	$sInfo = ' ' & $iDirsCount & ' Verzeichnis' & _Iif($iDirsCount <> 1, 'se, ', ', ')
	$sInfo &= $iFilesCount & ' Datei' & _Iif($iFilesCount <> 1, 'en (', ' (')
	$sInfo &= _ByteAutoSize($iDirSize) & ')'
	$sDrive = StringLeft($sPath, 2)
	$sLabel = ' [' & DriveGetLabel($sDrive) & ']  '
	Switch DriveGetType($sDrive)
		Case 'Removable'
			$sDriveIcon = 'removable.ico'
			If $sDrive = 'A:' Or $sDrive = 'B:' Then $sDriveIcon = 'floppy.ico'
		Case 'Fixed'
			$sDriveIcon = 'hdd.ico'
		Case 'CDROM'
			$sDriveIcon = 'cdrom.ico'
		Case 'Network'
			$sDriveIcon = 'network.ico'
			$sLabel = ' [IP=' & TCPNameToIP(StringRegExpReplace($sPath, '\\\\(.+?)\\.*', '$1')) & ']  '
		Case 'Unknown'
			$sDriveIcon = 'unknown.ico'
	EndSwitch
	$sLabel &= _ByteAutoSize(DriveSpaceTotal($sDrive) * 2 ^ 20) & ' (' & _ByteAutoSize(DriveSpaceFree($sDrive) * 2 ^ 20) & ' frei)'
	Switch $hListView
		Case $ahLV[0]
			GUICtrlSetImage($ahDriveIcon[0], $sIconDir & $sDriveIcon, -1, 1)
			GUICtrlSetData($ahLabel[0], $sLabel)
			GUICtrlSetData($ahInfo[0], $sInfo)
			_ChangeToolTip($sPath, 0)
		Case $ahLV[1]
			GUICtrlSetImage($ahDriveIcon[1], $sIconDir & $sDriveIcon, -1, 1)
			GUICtrlSetData($ahLabel[1], $sLabel)
			GUICtrlSetData($ahInfo[1], $sInfo)
			_ChangeToolTip($sPath, 1)
	EndSwitch
;~ 	_GUICtrlListView_EndUpdate(GUICtrlGetHandle($hListView))
;~ 	ToolTip('')
	_ShowStatus('Fertig.', 0)
EndFunc   ;==>_CreateListViewItems

; Bei dieser Version von _GUICtrlListView_AddArray kann man auch den Image-Index angeben
Func _GUICtrlListView_AddArrayEx($hWnd, ByRef $aItems)
	Local $fUnicode, $tItem, $pItem, $tBuffer, $pBuffer, $iLastItem
	$fUnicode = _GUICtrlListView_GetUnicodeFormat($hWnd)
	$tItem = DllStructCreate($tagLVITEM)
	$pItem = DllStructGetPtr($tItem)
	If $fUnicode Then
		$tBuffer = DllStructCreate('wchar Text[4096]')
	Else
		$tBuffer = DllStructCreate('char Text[4096]')
	EndIf
	$pBuffer = DllStructGetPtr($tBuffer)
	DllStructSetData($tItem, 'Mask', BitOR($LVIF_TEXT, $LVIF_IMAGE)) ; <- $LVIF_IMAGE hinzugefügt
	DllStructSetData($tItem, 'Text', $pBuffer)
	DllStructSetData($tItem, 'TextMax', 4096)
	$iLastItem = _GUICtrlListView_GetItemCount($hWnd)
	For $i = 0 To UBound($aItems) - 1
		DllStructSetData($tItem, 'Item', $i + $iLastItem)
		DllStructSetData($tItem, 'SubItem', 0)
		DllStructSetData($tItem, 'Image', $aItems[$i][0]) ; <- Den Image-Index als Element 0 im Array
		DllStructSetData($tBuffer, 'Text', $aItems[$i][1])
		If $fUnicode Then
			GUICtrlSendMsg($hWnd, $LVM_INSERTITEMW, 0, $pItem)
		Else
			GUICtrlSendMsg($hWnd, $LVM_INSERTITEMA, 0, $pItem)
		EndIf
		For $j = 2 To UBound($aItems, 2) - 1
			DllStructSetData($tItem, 'SubItem', $j - 1)
			DllStructSetData($tBuffer, 'Text', $aItems[$i][$j])
			If $fUnicode Then
				GUICtrlSendMsg($hWnd, $LVM_SETITEMW, 0, $pItem)
			Else
				GUICtrlSendMsg($hWnd, $LVM_SETITEMA, 0, $pItem)
			EndIf
		Next
	Next
	$tItem = 0
	$tBuffer = 0
EndFunc   ;==>_GUICtrlListView_AddArrayEx

Func _ChangeToolTip($sPath, $iButton)
	Local $sToolTip, $sLabel, $sFileSystem, $sSerial
	$sPath = StringRegExpReplace($sPath, '(.\:\\|\\\\.+?\\).*', '$1')
	$sLabel = DriveGetLabel($sPath)
	If StringLeft($sPath, 2) = '\\' Then $sLabel = 'IP=' & TCPNameToIP(StringRegExpReplace($sPath, '\\\\(.+?)\\.*', '$1'))
	$sFileSystem = DriveGetFileSystem($sPath)
	$sSerial = DriveGetSerial($sPath)
	$sToolTip = StringFormat('LaufwerksInfo:\t%s  [%s]\nDateisystem:\t%s\nSeriennummer:\t%s', StringUpper($sPath), $sLabel, $sFileSystem, $sSerial)
	GUICtrlSetTip($ahDriveIcon[$iButton], $sToolTip)
EndFunc   ;==>_ChangeToolTip

Func _ConfigDrives()
	Local $hConfigDrivesGui, $vDrives, $sMsg, $iNoDrives, $sDrive, $ahDriveLetter[26], $hDriveOk, $hDriveCancel, $aMsg
	$hConfigDrivesGui = GUICreate($sTitle & ' - Laufwerke konfigurieren', 640, 245, -1, -1, BitOR($WS_POPUPWINDOW, $WS_CAPTION), Default, $hGui)
	GUISetFont(10, 400, 0, 'Verdana', $hConfigDrivesGui, 5)
	GUISetBkColor(0xC8C8C8)
	GUISetIcon($sIconDir & 'program.ico', 0, $hConfigDrivesGui)
	$iNoDrives = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoDrives')
	$vDrives = DriveGetDrive('ALL')
	$vDrives = _ArrayToString($vDrives, '|', 1)
	GUICtrlCreateIcon('shell32.dll', -78, 10, 15, 32, 32)
	$sMsg = 'Achtung! Diese Einstellungen werden für den aktiven Benutzer in die Registry eingetragen und wirken sich auch auf den Explorer aus.\n'
	$sMsg &= 'Für die Änderung wird "RegWrite.exe" aufgerufen (AdminRechte erforderlich).'
	GUICtrlCreateLabel(StringFormat($sMsg), 55, 10, 560, 60)
	GUICtrlCreateGroup('Laufwerke verstecken (Haken gesetzt = verstecken)', 10, 80, 620, 120)
	GUICtrlSetFont(-1, 9)
	For $i = 0 To 25
		$sDrive = Chr(65 + $i) & ':'
		$ahDriveLetter[$i] = GUICtrlCreateCheckbox($sDrive, 40 + Mod($i, 9) * 65, 110 + Int($i / 9) * 25, 45, 20)
		If Not StringInStr($vDrives, $sDrive) Then
			GUICtrlSetState(-1, $GUI_DISABLE)
			GUICtrlSetFont(-1, 12, 400, 0, 'Verdana', 5)
		Else
			GUICtrlSetFont(-1, 12, 600, 0, 'Verdana', 5)
		EndIf
		If BitAND($iNoDrives, 2 ^ $i) Then GUICtrlSetState(-1, $GUI_CHECKED)
	Next
	GUICtrlCreateGroup('', -99, -99, 1, 1)
	$hDriveOk = GUICtrlCreateButton('Ok', 480, 210, 60, 25)
	GUICtrlSetFont(-1, 10, 400, 0, 'Arial', 5)
	$hDriveCancel = GUICtrlCreateButton('Abbrechen', 550, 210, 80, 25)
	GUICtrlSetFont(-1, 10, 400, 0, 'Arial', 5)
	GUISetState(@SW_SHOW, $hConfigDrivesGui)
	Opt('GUIOnEventMode', 0)
	While True
		$aMsg = GUIGetMsg(True)
		Switch $aMsg[1]
			Case $hConfigDrivesGui
				Switch $aMsg[0]
					Case $GUI_EVENT_CLOSE, $hDriveCancel
						ExitLoop
					Case $hDriveOk
						$iNoDrives = 0
						For $i = 0 To 25
							If BitAND(GUICtrlGetState($ahDriveLetter[$i]), $GUI_ENABLE) And _
									BitAND(GUICtrlRead($ahDriveLetter[$i]), $GUI_CHECKED) Then $iNoDrives += 2 ^ $i
						Next
						; Im folgenden RegKey/Value sind die Laufwerksbuchstaben verzeichnet, die im Explorer ausgeblendet werden.
						; Dabei steht Bit0 für Laufwerk "a:", Bit1 für "b:" usw.
						; Ist das jeweilige Bit gesetzt, wird es ausgeblendet.
						ShellExecuteWait($sScriptDir & 'tools\RegWrite.exe', 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer|NoDrives|' & $iNoDrives)
						Sleep(500)
						_CreateDriveButtons(True)
						_MarkLVButton(0)
						_MarkLVButton(1)
						ExitLoop
				EndSwitch
		EndSwitch
	WEnd
	GUIDelete($hConfigDrivesGui)
	Opt('GUIOnEventMode', 1)
EndFunc   ;==>_ConfigDrives

Func _CreateDriveButtons($fDelete = False)
	Local $aPos = WinGetPos($hGui), $sDriveIcon, $sTmpContext, $sDrive, $sDriveIcon, $iNoDrives
	If $fDelete Then
		For $i = 0 To UBound($ahDriveButtons) - 1
			GUICtrlDelete($ahDriveButtons[$i][0])
			GUICtrlDelete($ahDriveButtons[$i][1])
		Next
		WinSetTrans($hGui, '', 0)
		GUIRegisterMsg($WM_GETMINMAXINFO, '')
		WinMove($hGui, '', $aPos[0], $aPos[1], 716, 502)
		GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO')
	EndIf
	$aDrives = DriveGetDrive('ALL')
	ReDim $aDrives[UBound($aDrives) + 1]
	$aDrives[UBound($aDrives) - 1] = '\\'
	$aDrives[0] = UBound($aDrives) - 1
	Global $ahDriveButtons[$aDrives[0]][2]
	GUISwitch($hGui)
	GUIStartGroup()
	If Not $fShowDrives Then
		; Im folgenden RegKey/Value sind die Laufwerksbuchstaben verzeichnet, die im Explorer ausgeblendet werden.
		; Dabei steht Bit0 für Laufwerk "a:", Bit1 für "b:" usw.
		; Ist das jeweilige Bit gesetzt, wird es ausgeblendet.
		$iNoDrives = RegRead('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoDrives')
		For $i = $aDrives[0] To 1 Step -1
			If BitAND($iNoDrives, 2 ^ (Asc(StringLeft($aDrives[$i], 1)) - 97)) Then _ArrayDelete($aDrives, $i)
		Next
		$aDrives[0] = UBound($aDrives) - 1
	EndIf
	For $i = 1 To $aDrives[0]
		$sDrive = StringUpper($aDrives[$i])
		$ahDriveButtons[$i - 1][0] = GUICtrlCreateButton($sDrive, 2 + ($i - 1) * 26, 51, 26, 29)
		GUICtrlSetFont(-1, 9)
		GUICtrlSetOnEvent(-1, '_ReadDriveLeft')
		GUICtrlSetResizing(-1, $GUI_DOCKHEIGHT + $GUI_DOCKTOP)
		Switch DriveGetType($sDrive)
			Case 'Removable'
				$sDriveIcon = 'removable.ico'
				If $sDrive = 'A:' Or $sDrive = 'B:' Then $sDriveIcon = 'floppy.ico'
			Case 'Fixed'
				$sDriveIcon = 'hdd.ico'
			Case 'CDROM'
				$sDriveIcon = 'cdrom.ico'
			Case 'Network'
				$sDriveIcon = 'workgroup.ico'
			Case 'Unknown'
				$sDriveIcon = 'unknown.ico'
		EndSwitch
		GUICtrlSetImage(-1, $sIconDir & $sDriveIcon, 0, 0)
		$sTmpContext = GUICtrlCreateContextMenu($ahDriveButtons[$i - 1][0])
		GUICtrlCreateMenuItem('Eigenschaften', $sTmpContext)
		GUICtrlSetOnEvent(-1, '_DriveProperties')
	Next
	GUIStartGroup()
	For $i = 1 To $aDrives[0]
		$sDrive = StringUpper($aDrives[$i])
		$ahDriveButtons[$i - 1][1] = GUICtrlCreateButton($sDrive, 350 + ($i - 1) * 26, 51, 26, 29)
		GUICtrlSetFont(-1, 9)
		GUICtrlSetOnEvent(-1, '_ReadDriveRight')
		GUICtrlSetResizing(-1, $GUI_DOCKHEIGHT + $GUI_DOCKTOP)
		Switch DriveGetType($sDrive)
			Case 'Removable'
				$sDriveIcon = 'removable.ico'
				If $sDrive = 'A:' Or $sDrive = 'B:' Then $sDriveIcon = 'floppy.ico'
			Case 'Fixed'
				$sDriveIcon = 'hdd.ico'
			Case 'CDROM'
				$sDriveIcon = 'cdrom.ico'
			Case 'Network'
				$sDriveIcon = 'workgroup.ico'
			Case 'Unknown'
				$sDriveIcon = 'unknown.ico'
		EndSwitch
		GUICtrlSetImage(-1, $sIconDir & $sDriveIcon, 0, 0)
		$sTmpContext = GUICtrlCreateContextMenu($ahDriveButtons[$i - 1][1])
		GUICtrlCreateMenuItem('Eigenschaften', $sTmpContext)
		GUICtrlSetOnEvent(-1, '_DriveProperties')
	Next
	If $fDelete Then
		WinMove($hGui, '', $aPos[0], $aPos[1], $aPos[2], $aPos[3])
		WinSetTrans($hGui, '', 255)
	EndIf
EndFunc   ;==>_CreateDriveButtons

Func _PreviewSetState()
	Local $aWinPos, $aControlPos
	$aWinPos = WinGetPos($hGui)
	$aControlPos = ControlGetPos($hGui, '', $ahLV[1 - $iActiveLV])
	$iPreviewMaxDim = $aControlPos[3]
	If $aControlPos[2] < $aControlPos[3] Then $iPreviewMaxDim = $aControlPos[2]
	$fPreviewShow = Not $fPreviewShow
	If $fPreviewShow Then
		$hPreviewBitmap = 0
		_GUICtrlStatusBar_SetIcon($hPreviewStatus, 0, $aStatusIcons[0])
		_GUICtrlStatusBar_SetText($hPreviewStatus, 'Zum anzeigen der Bildes bitte Bilddatei anklicken.')
		WinMove($hPreviewGui, '', $aWinPos[0] + $aControlPos[0] + 12, $aWinPos[1] + $aControlPos[1] + 14, $iPreviewMaxDim + 6, $iPreviewMaxDim + 26)
		$hPreviewGraphic = _GDIPlus_GraphicsCreateFromHWND($hPreviewGui)
		WinMove($hPreviewGui, '', $aWinPos[0] + $aControlPos[0] + 12, $aWinPos[1] + $aControlPos[1] + 14, $iPreviewMaxDim + 6, $iPreviewMaxDim + 50)
		GUISetState(@SW_SHOW, $hPreviewGui)
	Else
		GUISetState(@SW_HIDE, $hPreviewGui)
	EndIf
	WinActivate($hGui)
EndFunc   ;==>_PreviewSetState

Func _PreviewLoadImage($sImgFile)
	$hPreviewBitmap = _GDIPlus_BitmapCreateFromFile($sImgFile)
	If $hPreviewBitmap = 0 Then
		_GDIPlus_GraphicsFillRect($hPreviewGraphic, 0, 0, $iPreviewMaxDim, $iPreviewMaxDim)
		_GUICtrlStatusBar_SetIcon($hPreviewStatus, 0, $aStatusIcons[1])
		_GUICtrlStatusBar_SetText($hPreviewStatus, 'Fehler! Das Bild konnte nicht geladen werden.')
		Return
	EndIf
	$iPreviewAngle = 0
	$sPreviewFilename = StringRegExpReplace($sImgFile, '.+\\(.+)', '$1')
	_PreviewShowImage()
EndFunc   ;==>_PreviewLoadImage

Func _PreviewShowImage()
	Local $iVector, $aPixelFormat
	If $iPreviewAngle <> 0 Then _GDIplus_ImageRotateFlip($hPreviewBitmap, $iPreviewAngle)
	$iPreviewWidth = _GDIPlus_ImageGetWidth($hPreviewBitmap)
	$iPreviewHeight = _GDIPlus_ImageGetHeight($hPreviewBitmap)
	$aPixelFormat = _GDIPlus_ImageGetPixelFormat($hPreviewBitmap)
	_GUICtrlStatusBar_SetIcon($hPreviewStatus, 0, $aStatusIcons[0])
	_GUICtrlStatusBar_SetText($hPreviewStatus, StringFormat('%s  (%s x %s, %s)', $sPreviewFilename, $iPreviewWidth, $iPreviewHeight, $aPixelFormat[1]))
	If $iPreviewWidth > $iPreviewMaxDim Or $iPreviewHeight > $iPreviewMaxDim Then
		$iVector = $iPreviewWidth / $iPreviewHeight
		If $iVector > 1 Then
			$iPreviewWidth = $iPreviewMaxDim
			$iPreviewHeight = Int($iPreviewWidth / $iVector)
		Else
			$iPreviewHeight = $iPreviewMaxDim
			$iPreviewWidth = Int($iPreviewHeight * $iVector)
		EndIf
	EndIf
	_GDIPlus_GraphicsFillRect($hPreviewGraphic, 0, 0, $iPreviewMaxDim, $iPreviewMaxDim)
	_GDIPlus_GraphicsDrawImageRect($hPreviewGraphic, $hPreviewBitmap, ($iPreviewMaxDim - $iPreviewWidth) / 2, ($iPreviewMaxDim - $iPreviewHeight) / 2, $iPreviewWidth, $iPreviewHeight)
EndFunc   ;==>_PreviewShowImage

Func _RotateRight()
	$iPreviewAngle = 1
	_PreviewShowImage()
EndFunc   ;==>_RotateRight

Func _RotateLeft()
	$iPreviewAngle = 3
	_PreviewShowImage()
EndFunc   ;==>_RotateLeft

Func _EnterKey()
	Local $iSelect, $sExt, $sText, $sPath, $aItemRect
	$iSelect = _GUICtrlListView_GetSelectionMark($ahLV[$iActiveLV])
	If $iSelect > -1 Then
		$sExt = _GUICtrlListView_GetItemText($ahLV[$iActiveLV], $iSelect, 1)
		If $sExt <> '' Then $sExt = '.' & $sExt
		$sText = _GUICtrlListView_GetItemText($ahLV[$iActiveLV], $iSelect, 0)
		Switch $sText
			Case ''
				; nothing
			Case '..'
				$sPath = StringRegExpReplace($aDirPath[$iActiveLV], '(.+\\).+\\', '$1')
				If Not FileExists($sPath) Then Return _ShowStatus('Pfad existiert nicht!', 1)
				GUICtrlSetData($ahPath[$iActiveLV], $sPath)
				$aDirPath[$iActiveLV] = $sPath
				_ClearLVHeaderFlags()
				_CreateListViewItems($ahLV[$iActiveLV], $sPath)
				StringReplace($aDirPath[$iActiveLV], '\', '')
				Local $iLastItem = @extended + 1
				_GUICtrlListView_EnsureVisible(GUICtrlGetHandle($ahLV[$iActiveLV]), $aLastTopIndex[$iActiveLV][$iLastItem][0])
				_GUICtrlListView_SetItemSelected($ahLV[$iActiveLV], $aLastTopIndex[$iActiveLV][$iLastItem][1], True, True)
			Case Else
				$sPath = $aDirPath[$iActiveLV] & $sText
				Switch $sExt
					Case '.<DIR>'
						$sPath &= '\'
						If DriveStatus(StringLeft($sPath,3)) = 'READY' Then
							StringReplace($aDirPath[$iActiveLV], '\', '')
							Local $iLastItem = @extended + 1
							$aLastTopIndex[$iActiveLV][$iLastItem][0] = _GUICtrlListView_GetTopIndex($ahLV[$iActiveLV]) + _GUICtrlListView_GetCounterPage($ahLV[$iActiveLV]) - 1
							$aLastTopIndex[$iActiveLV][$iLastItem][1] = $iSelect
							GUICtrlSetData($ahPath[$iActiveLV], $sPath)
							$aDirPath[$iActiveLV] = $sPath
							_ClearLVHeaderFlags()
							_CreateListViewItems($ahLV[$iActiveLV], $sPath)
						Else
							_ShowStatus('Zugriff verweigert!', 1)
							;Consolewrite($sPath&@CRLF)
						EndIf
						_GUICtrlListView_SetItemSelected($ahLV[$iActiveLV], 0, True, True)
					Case Else
						ShellExecute($sPath & $sExt, '', $aDirPath[$iActiveLV])
				EndSwitch
		EndSwitch
	EndIf
EndFunc   ;==>_EnterKey

Func WM_PAINT($hWnd, $Msg, $wParam, $lParam)
	If $hWnd = $hPreviewGui Then
		_GDIPlus_GraphicsFillRect($hPreviewGraphic, 0, 0, $iPreviewMaxDim, $iPreviewMaxDim)
		_GDIPlus_GraphicsDrawImageRect($hPreviewGraphic, $hPreviewBitmap, ($iPreviewMaxDim - $iPreviewWidth) / 2, ($iPreviewMaxDim - $iPreviewHeight) / 2, $iPreviewWidth, $iPreviewHeight)
	EndIf
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func WM_DEVICECHANGE($hWnd, $iMsg, $iwParam, $ilParam)
	#forceref $iMsg, $ilParam
	Local Const $DBT_DEVICEARRIVAL = 0x8000, $DBT_DEVICEREMOVECOMPLETE = 0x8004
	If $hWnd = $hGui And ($iwParam = $DBT_DEVICEARRIVAL Or $iwParam = $DBT_DEVICEREMOVECOMPLETE) Then _CreateDriveButtons(True)
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_DEVICECHANGE

Func WM_MOVE($hWnd, $iMsg, $iwParam, $ilParam)
	#forceref $iMsg, $iwParam, $ilParam
	If $hWnd = $hGui Then
		GUISetState(@SW_HIDE, $hDirListGui)
		Local $aPos = WinGetPos($hGui)
		If $aPos[0] <> -32000 And $aPos[1] <> -32000 Then
			IniWrite($sIniFile, 'Config', 'X', $aPos[0])
			IniWrite($sIniFile, 'Config', 'Y', $aPos[1])
		EndIf
	EndIf
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOVE

Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
	#forceref $iMsg, $iwParam, $ilParam
	Local Const $SIZE_MAXIMIZED = 2
	Switch $hWnd
		Case $hGui
			GUISetState(@SW_HIDE, $hDirListGui)
			If BitAND($iwParam, $SIZE_MAXIMIZED) Then
				$fMaximized = True
			Else
				Local $aPos = WinGetPos($hGui)
				If $aPos[0] <> -32000 And $aPos[1] <> -32000 Then
					IniWrite($sIniFile, 'Config', 'X', $aPos[0])
					IniWrite($sIniFile, 'Config', 'Y', $aPos[1])
					IniWrite($sIniFile, 'Config', 'Width', $aPos[2])
					IniWrite($sIniFile, 'Config', 'Height', $aPos[3])
				EndIf
				$fMaximized = False
			EndIf
			IniWrite($sIniFile, 'Config', 'Maximized', $fMaximized)
			_GUICtrlStatusBar_Resize($hStatus)
		Case $hPreviewGui
			_GUICtrlStatusBar_Resize($hPreviewStatus)
	EndSwitch
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

Func WM_GETMINMAXINFO($hWnd, $iMsg, $iwParam, $ilParam)
	#forceref $iMsg, $iwParam
	Local $minmaxinfo
	If $hWnd = $hGui Then
		$minmaxinfo = DllStructCreate('int;int;int;int;int;int;int;int;int;int', $ilParam)
		Switch @OSVersion
			Case 'WIN_7', 'WIN_VISTA', 'WIN_2008', 'WIN_2003', 'WIN_81', 'WIN_8'
				DllStructSetData($minmaxinfo, 7, 996)
			Case Else
				DllStructSetData($minmaxinfo, 7, 716)
		EndSwitch
		DllStructSetData($minmaxinfo, 8, 540)
	EndIf
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_GETMINMAXINFO

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
	#forceref $hWnd, $iMsg
	Local $hWndFrom = $ilParam
	Local $iCode = _WinAPI_HiWord($iwParam)
	Local $hWndEdit1 = GUICtrlGetHandle($ahPath[0])
	Local $hWndEdit2 = GUICtrlGetHandle($ahPath[1])
	Switch $iCode
		Case $EN_SETFOCUS
			GUISetState(@SW_HIDE, $hDirListGui)
			Switch $hWndFrom
				Case $hWndEdit1
					$iActiveLV = 0
					GUICtrlSetBkColor($ahPath[0], $aColorActive[0])
					GUICtrlSetColor($ahPath[0], $aColorActive[1])
					GUICtrlSetBkColor($ahPath[1], $aColorInactive[0])
					GUICtrlSetColor($ahPath[1], $aColorInactive[1])
				Case $hWndEdit2
					$iActiveLV = 1
					GUICtrlSetBkColor($ahPath[1], $aColorActive[0])
					GUICtrlSetColor($ahPath[1], $aColorActive[1])
					GUICtrlSetBkColor($ahPath[0], $aColorInactive[0])
					GUICtrlSetColor($ahPath[0], $aColorInactive[1])
			EndSwitch
	EndSwitch
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
	#forceref $hWnd, $iMsg, $iwParam
	Local $tNMHDR, $hWndFrom, $tInfo, $iItem, $sText, $sPath, $sExt, $aItemRect
	Local Const $tagNMITEMACTIVATE64 = "hwnd hWndFrom;uint_ptr IDFrom;INT_ptr Code;int Index;int SubItem;int NewState;int OldState;" & _
			"int Changed;int X;int Y;int lParam;int KeyFlags" ; als Alternative für 64 Bit Support, Danke progandy!
	$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
	$hWndFrom = HWnd(DllStructGetData($tNMHDR, 'hWndFrom'))
	Switch $hWndFrom
		Case GUICtrlGetHandle($hEditLV)
			Switch DllStructGetData($tNMHDR, 'Code')
				Case $NM_CLICK
					$tInfo = DllStructCreate($tagNMITEMACTIVATE64, $ilParam)
					$iItem = DllStructGetData($tInfo, 'Index')
					GUICtrlSetData($hEditName, _GUICtrlListView_GetItemText($hEditLV, $iItem, 0))
					GUICtrlSetData($hEditPath, _GUICtrlListView_GetItemText($hEditLV, $iItem, 1))
			EndSwitch
		Case _GUICtrlListView_GetHeader($ahLV[0])
			Switch DllStructGetData($tNMHDR, 'Code')
				Case -310 ; $HDN_BEGINDRAG
					$fTabSelect = True
				Case -321 ; $HDN_ITEMCHANGEDW
					_CheckLVColWidth(0)
				Case $NM_RELEASEDCAPTURE
					If $fTabSelect Then
						$fTabSelect = False
						_SetLVColOrder(0)
					EndIf
			EndSwitch
		Case _GUICtrlListView_GetHeader($ahLV[1])
			Switch DllStructGetData($tNMHDR, 'Code')
				Case -310 ; $HDN_BEGINDRAG
					$fTabSelect = True
				Case -321 ; $HDN_ITEMCHANGEDW
					_CheckLVColWidth(1)
				Case $NM_RELEASEDCAPTURE
					If $fTabSelect Then
						$fTabSelect = False
						_SetLVColOrder(1)
					EndIf
			EndSwitch
		Case GUICtrlGetHandle($ahLV[0])
			Switch DllStructGetData($tNMHDR, 'Code')
				Case $LVN_KEYDOWN
					_NotifyKeyDown($ahLV[0], $ilParam)
				Case $NM_CLICK
					If $fPreviewShow Then
						$tInfo = DllStructCreate($tagNMITEMACTIVATE64, $ilParam)
						$iItem = DllStructGetData($tInfo, 'Index')
						$sExt = _GUICtrlListView_GetItemText($ahLV[0], $iItem, 1)
						If StringInStr($sPreviewExt, $sExt) Then
							_PreviewLoadImage($aDirPath[0] & _GUICtrlListView_GetItemText($ahLV[0], $iItem, 0) & '.' & $sExt)
						Else
							$hPreviewBitmap = 0
							_GUICtrlStatusBar_SetIcon($hPreviewStatus, 0, $aStatusIcons[0])
							_GUICtrlStatusBar_SetText($hPreviewStatus, 'Vorschau nicht möglich!')
							_GDIPlus_GraphicsFillRect($hPreviewGraphic, 0, 0, $iPreviewMaxDim, $iPreviewMaxDim)
						EndIf
					EndIf
				Case $NM_DBLCLK
					$tInfo = DllStructCreate($tagNMITEMACTIVATE64, $ilParam)
					$iItem = DllStructGetData($tInfo, 'Index')
					$sText = _GUICtrlListView_GetItemText($ahLV[0], $iItem, 0)
					Switch $sText
						Case ''
							; nothing
						Case '..'
							$sPath = StringRegExpReplace($aDirPath[0], '(.+\\).+\\', '$1')
							If Not FileExists($sPath) Then Return _ShowStatus('Pfad existiert nicht!', 1)
							GUICtrlSetData($ahPath[0], $sPath)
							$aDirPath[0] = $sPath
							_ClearLVHeaderFlags()
							_CreateListViewItems($ahLV[0], $sPath)
							StringReplace($aDirPath[0], '\', '')
							Local $iLastItem = @extended + 1
							_GUICtrlListView_EnsureVisible(GUICtrlGetHandle($ahLV[0]), $aLastTopIndex[0][$iLastItem][0])
							_GUICtrlListView_SetItemSelected($ahLV[0], $aLastTopIndex[0][$iLastItem][1], True, True)
						Case Else
							$sExt = _GUICtrlListView_GetItemText($ahLV[0], $iItem, 1)
							If $sExt <> '' Then $sExt = '.' & $sExt
							$sPath = $aDirPath[0] & $sText
							Switch $sExt
								Case '.lnk'
									Local $aShortcut = FileGetShortcut($sPath & $sExt)
									If Not @error Then
										If StringInStr(FileGetAttrib($aShortcut[0]), 'D') Then
											$sPath = $aShortcut[0] & '\'
						If DriveStatus(StringLeft($sPath,3)) = 'READY' Then
												StringReplace($sPath, '\', '')
												Local $iLastItem = @extended
												$aLastTopIndex[0][$iLastItem][0] = _GUICtrlListView_GetTopIndex($ahLV[0]) + _GUICtrlListView_GetCounterPage($ahLV[0]) - 1
												$aLastTopIndex[0][$iLastItem][1] = $iItem
												GUICtrlSetData($ahPath[0], $sPath)
												$aDirPath[0] = $sPath
												_ClearLVHeaderFlags()
												_CreateListViewItems($ahLV[0], $sPath)
												_MarkLVButton(0)
											Else
												_ShowStatus('Zugriff verweigert!', 1)
							;Consolewrite($sPath&@CRLF)
											EndIf
										Else
											ShellExecute($aShortcut[0], $aShortcut[2], $aShortcut[1])
										EndIf
									EndIf
								Case '.<DIR>'
									;Consolewrite($sPath&@CRLF)
									$sPath &= '\'
						If DriveStatus(StringLeft($sPath,3)) = 'READY' Then
										StringReplace($sPath, '\', '')
										Local $iLastItem = @extended
										$aLastTopIndex[0][$iLastItem][0] = _GUICtrlListView_GetTopIndex($ahLV[0]) + _GUICtrlListView_GetCounterPage($ahLV[0]) - 1
										$aLastTopIndex[0][$iLastItem][1] = $iItem
										GUICtrlSetData($ahPath[0], $sPath)
										$aDirPath[0] = $sPath
										_ClearLVHeaderFlags()
										_CreateListViewItems($ahLV[0], $sPath)
									Else
										_ShowStatus('Zugriff verweigert!', 1)
									EndIf
								Case Else
									ShellExecute($sPath & $sExt, '', $aDirPath[0])
							EndSwitch
					EndSwitch
				Case $NM_SETFOCUS
					GUISetState(@SW_HIDE, $hDirListGui)
					$iActiveLV = 0
					GUICtrlSetBkColor($ahPath[0], $aColorActive[0])
					GUICtrlSetColor($ahPath[0], $aColorActive[1])
					GUICtrlSetBkColor($ahPath[1], $aColorInactive[0])
					GUICtrlSetColor($ahPath[1], $aColorInactive[1])
			EndSwitch
		Case GUICtrlGetHandle($ahLV[1])
			Switch DllStructGetData($tNMHDR, 'Code')
				Case $LVN_KEYDOWN
					_NotifyKeyDown($ahLV[1], $ilParam)
				Case $NM_CLICK
					If $fPreviewShow Then
						$tInfo = DllStructCreate($tagNMITEMACTIVATE64, $ilParam)
						$iItem = DllStructGetData($tInfo, 'Index')
						$sExt = _GUICtrlListView_GetItemText($ahLV[1], $iItem, 1)
						If StringInStr($sPreviewExt, $sExt) Then
							_PreviewLoadImage($aDirPath[1] & _GUICtrlListView_GetItemText($ahLV[1], $iItem, 0) & '.' & $sExt)
						Else
							$hPreviewBitmap = 0
							_GUICtrlStatusBar_SetIcon($hPreviewStatus, 0, $aStatusIcons[0])
							_GUICtrlStatusBar_SetText($hPreviewStatus, 'Vorschau nicht möglich!')
							_GDIPlus_GraphicsFillRect($hPreviewGraphic, 0, 0, $iPreviewMaxDim, $iPreviewMaxDim)
						EndIf
					EndIf
				Case $NM_DBLCLK
					$tInfo = DllStructCreate($tagNMITEMACTIVATE64, $ilParam)
					$iItem = DllStructGetData($tInfo, 'Index')
					$sText = _GUICtrlListView_GetItemText($ahLV[1], $iItem, 0)
					Switch $sText
						Case ''
							; nothing
						Case '..'
							$sPath = StringRegExpReplace($aDirPath[1], '(.+\\).+\\', '$1')
							If Not FileExists($sPath) Then Return _ShowStatus('Pfad existiert nicht!', 1)
							GUICtrlSetData($ahPath[1], $sPath)
							$aDirPath[1] = $sPath
							_ClearLVHeaderFlags()
							_CreateListViewItems($ahLV[1], $sPath)
							StringReplace($aDirPath[1], '\', '')
							Local $iLastItem = @extended + 1
							_GUICtrlListView_EnsureVisible(GUICtrlGetHandle($ahLV[1]), $aLastTopIndex[1][$iLastItem][0])
							_GUICtrlListView_SetItemSelected($ahLV[1], $aLastTopIndex[1][$iLastItem][1], True, True)
						Case Else
							$sExt = _GUICtrlListView_GetItemText($ahLV[1], $iItem, 1)
							If $sExt <> '' Then $sExt = '.' & $sExt
							$sPath = $aDirPath[1] & $sText
							Switch $sExt
								Case '.lnk'
									Local $aShortcut = FileGetShortcut($sPath & $sExt)
									If Not @error Then
										If StringInStr(FileGetAttrib($aShortcut[0]), 'D') Then
											$sPath = $aShortcut[0] & '\'
						If DriveStatus(StringLeft($sPath,3)) = 'READY' Then
												StringReplace($sPath, '\', '')
												Local $iLastItem = @extended
												$aLastTopIndex[1][$iLastItem][0] = _GUICtrlListView_GetTopIndex($ahLV[1]) + _GUICtrlListView_GetCounterPage($ahLV[1]) - 1
												$aLastTopIndex[1][$iLastItem][1] = $iItem
												GUICtrlSetData($ahPath[1], $sPath)
												$aDirPath[1] = $sPath
												_ClearLVHeaderFlags()
												_CreateListViewItems($ahLV[1], $sPath)
												_MarkLVButton(1)
											Else
												_ShowStatus('Zugriff verweigert!', 1)
							;Consolewrite($sPath&@CRLF)
											EndIf
										Else
											ShellExecute($aShortcut[0], $aShortcut[2], $aShortcut[1])
										EndIf
									EndIf
								Case '.<DIR>'
									$sPath &= '\'
						If DriveStatus(StringLeft($sPath,3)) = 'READY' Then
										StringReplace($sPath, '\', '')
										Local $iLastItem = @extended
										$aLastTopIndex[1][$iLastItem][0] = _GUICtrlListView_GetTopIndex($ahLV[1]) + _GUICtrlListView_GetCounterPage($ahLV[1]) - 1
										$aLastTopIndex[1][$iLastItem][1] = $iItem
										GUICtrlSetData($ahPath[1], $sPath)
										$aDirPath[1] = $sPath
										_ClearLVHeaderFlags()
										_CreateListViewItems($ahLV[1], $sPath)
									Else
										_ShowStatus('Zugriff verweigert!', 1)
							;Consolewrite($sPath&@CRLF)
									EndIf
								Case Else
									ShellExecute($sPath & $sExt, '', $aDirPath[1])
							EndSwitch
					EndSwitch
				Case $NM_SETFOCUS
					GUISetState(@SW_HIDE, $hDirListGui)
					$iActiveLV = 1
					GUICtrlSetBkColor($ahPath[1], $aColorActive[0])
					GUICtrlSetColor($ahPath[1], $aColorActive[1])
					GUICtrlSetBkColor($ahPath[0], $aColorInactive[0])
					GUICtrlSetColor($ahPath[0], $aColorInactive[1])
			EndSwitch
	EndSwitch
	$tNMHDR = ''
	$tInfo = ''
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _GUICtrlListView_GetFocusedItem(ByRef $hListView)
	Local $iCount = _GUICtrlListView_GetItemCount($hListView)
	For $i = 0 To $iCount - 1
		If _GUICtrlListView_GetItemState($hListView, $i, $LVIS_FOCUSED) Then Return SetError(0, 0, $i)
	Next
	Return SetError(1, 0, -1)
EndFunc   ;==>_GUICtrlListView_GetFocusedItem

Func _NotifyKeyDown($hListView, $ilParam)
	Local $tInfo, $iItem, $sExt
	$tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam)
	$hListView = GUICtrlGetHandle($hListView)
	Switch DllStructGetData($tInfo, 'VKey')
		Case 40 ; down
			$iItem = _GUICtrlListView_GetFocusedItem($hListView) + 1
		Case 38 ; up
			$iItem = _GUICtrlListView_GetFocusedItem($hListView) - 1
		Case Else
			Return
	EndSwitch
	If $iItem > _GUICtrlListView_GetItemCount($hListView) - 1 Then Return
	If $fPreviewShow And $iItem >= 0 Then
		$sExt = _GUICtrlListView_GetItemText($hListView, $iItem, 1)
		If StringInStr($sPreviewExt, $sExt) Then
			_PreviewLoadImage($aDirPath[$iActiveLV] & _GUICtrlListView_GetItemText($hListView, $iItem, 0) & '.' & $sExt)
		Else
			$hPreviewBitmap = 0
			_GUICtrlStatusBar_SetIcon($hPreviewStatus, 0, $aStatusIcons[0])
			_GUICtrlStatusBar_SetText($hPreviewStatus, 'Vorschau nicht möglich!')
			_GDIPlus_GraphicsFillRect($hPreviewGraphic, 0, 0, $iPreviewMaxDim, $iPreviewMaxDim)
		EndIf
	EndIf
EndFunc   ;==>_NotifyKeyDown

Func _SetLVColOrder($iLV)
	ConsoleWrite('_SetLVColOrder'&@CRLF)
	Local $aOrder = _GUICtrlListView_GetColumnOrderArray($ahLV[$iLV])
	_GUICtrlListView_SetColumnOrderArray($ahLV[1 - $iLV], $aOrder)
	_GUICtrlListView_RedrawItems($ahLV[1 - $iLV], 0, _GUICtrlListView_GetItemCount($ahLV[1 - $iLV]))
	_ArrayDelete($aOrder, 0)
	$sColOrder = _ArrayToString($aOrder)
EndFunc   ;==>_SetLVColOrder

Func _CheckLVColWidth($iLV)
	For $i = 0 To 4
		_GUICtrlListView_SetColumnWidth($ahLV[1 - $iLV], $i, _GUICtrlListView_GetColumnWidth($ahLV[$iLV], $i))
	Next
EndFunc   ;==>_CheckLVColWidth

Func _Thanks()
	Local $sMsg = 'Mein Dank geht an:\n\n'
	$sMsg &= '- Jonathan Bennett & AutoIt Team\n\tfür die Programmiersprache "AutoIt"\n'
	$sMsg &= '- Gun-Food und Peethebee\n\tfür das tolle Forum "www.autoit.de"\n'
	$sMsg &= '- funkey (www.autoit.de)\n\tfür die Funktion "_PlayDefaultSystemSound"\n'
	$sMsg &= '- progandy (www.autoit.de) für die Funktionen: \n\t"_IsReparsePoint"\n\t"_WinAPI_SHGetFileInfo"\n\t"_GUIImageList_GetSystemImageList"\n\t"_GUIImageList_GetFileIconIndex"\n\t"_GDIplus_ImageRotateFlip"\n'
	$sMsg &= '- Kleiner (www.autoit.de)\n\tfür die Funktion "_WinAPI_CryptBinaryToString"\n'
	$sMsg &= '- Raupi (www.autoit.de)\n\tfür die Verbesserungsvorschläge und Fehlerbeseitigungen\n'
	$sMsg &= '\nUnd an all diejenigen, die fleissig testen und Fehler melden.\n\n'
	$sMsg &= 'Vielen Dank euch allen!\n'
	MsgBox(0, $sTitle & '   -   Danksagungen', StringFormat($sMsg, $sVersion, $sDate), 0, $hGui)
EndFunc   ;==>_Thanks

Func _ProgInfo()
	Local $sMsg = 'Version:\t%s\nDatum:\t%s\nAutor:\tOscar (www.autoit.de)\nEMail:\tOscar@elektronik-kurs.de\n\n'
	$sMsg &= 'Rechtliches:\n'
	$sMsg &= '- Dieses Programm darf, zeitlich unbegrenzt, kostenlos genutzt werden!\n'
	$sMsg &= '- Eine evtl. Weitergabe muss kostenlos, vollständig und unverändert erfolgen!\n'
	$sMsg &= '- Änderungen am Programm dürfen nur durch den Autor vorgenommen werden!\n'
	MsgBox(0, $sTitle & '   -   Programm-Informationen', StringFormat($sMsg, $sVersion, $sDate), 0, $hGui)
EndFunc   ;==>_ProgInfo

;===============================================================================
; Function Name:   _RecursiveFileListToArray($sPath[, $iFlag][, $iFormat][, $iRecursion][, $sDelim])
; Description::    gibt Verzeichnisse (rekursiv) und/oder Dateien zurück
; Parameter(s):    $sPath = Startverzeichnis
;                  $iFlag = Auswahl
;                           0 = Dateien & Verzeichnisse
;                           1 = nur Dateien
;                           2 = nur Verzeichnisse
;                  $iFormat = Rückgabeformat
;                             0 = String
;                             1 = Array mit [0] = Anzahl
;                             2 = Nullbasiertes Array
;                  $iRecursion = Verzeichnisse rekursiv durchsuchen
;                                0 = Nein
;                                1 = Ja
;                  $sDelim = Trennzeichen für die String-Rückgabe
; Requirement(s):  AutoIt 3.3.0.0
; Return Value(s): Array/String mit den gefundenen Dateien/Verzeichnissen
; Author(s):       Oscar (www.autoit.de)
;                  Anregungen von: bernd670 (www.autoit.de)
;===============================================================================
Func _RecursiveFileListToArray($sPath, $iFlag = 0, $iFormat = 1, $iRecursion = 1, $sDelim = @CR)
	Local $hSearch, $sFile, $sReturn = ''
	If StringRight($sPath, 1) <> '\' Then $sPath &= '\'
	$hSearch = FileFindFirstFile($sPath & '*.*')
	If @error Or $hSearch = -1 Then Return SetError(1, 0, $sReturn)
	While True
		$sFile = FileFindNextFile($hSearch)
		If @error Then ExitLoop
		If @extended And Not _IsReparsePoint($sPath & $sFile) Then
			If ($iFlag = 0 Or $iFlag = 2) Then $sReturn &= $sPath & $sFile & '\' & $sDelim
			If $iRecursion Then $sReturn &= _RecursiveFileListToArray($sPath & $sFile & '\', $iFlag, 0)
			ContinueLoop
		EndIf
		If ($iFlag = 0 Or $iFlag = 1) Then
			$iCopySize += FileGetSize($sPath & $sFile)
			$sReturn &= $sPath & $sFile & $sDelim
		EndIf
	WEnd
	FileClose($hSearch)
	If $iFormat And $sReturn = '' Then Return StringSplit($sReturn, '', $iFormat)
	If $iFormat Then Return StringSplit(StringTrimRight($sReturn, StringLen($sDelim)), $sDelim, $iFormat)
	Return $sReturn
EndFunc   ;==>_RecursiveFileListToArray

;===============================================================================
; Function Name:   _ByteAutoSize($iSize[, $iRound][, $iFormat][, $bThousands])
; Description::    Gibt einen Bytewert in einer bestimmten Einheit zurück
; Parameter(s):    $iSize = Größe in Byte übergeben
;                  $iRound = Anzahl der Nachkommastellen (0...8)
;                  $iFormat = bestimmt den Rückgabewert
;                     0 = Automatisch (je nach übergebenen Wert)
;                     1 = in Byte
;                     2 = in KByte
;                     3 = in MByte
;                     4 = in GByte
;                  $bThousands = Rückgabe mit Tausendertrennzeichen (True/False)
; Requirement(s):  #include <String.au3>
; Author(s):       Oscar (www.autoit.de)
;===============================================================================
Func _ByteAutoSize($iSize, $iRound = 2, $iFormat = 0, $bThousands = True)
	Local $aSize[4] = [' Byte', ' KByte', ' MByte', ' GByte'], $sReturn
	If $iFormat < 0 Or $iFormat > 4 Then $iFormat = 0
	If $iRound < 0 Or $iRound > 8 Then $iRound = 2
	If Not IsBool($bThousands) Then $bThousands = False
	$iSize = Abs($iSize)
	If $iFormat = 0 Then
		For $i = 30 To 0 Step -10
			If $iSize > (2 ^ $i) Then
				$iFormat = $i / 10 + 1
				ExitLoop
			EndIf
		Next
	EndIf
	If $iFormat = 0 Then $iFormat = 1
	$sReturn = StringFormat('%.' & $iRound & 'f', Round($iSize / (2 ^ (($iFormat - 1) * 10)), $iRound))
	If $bThousands Then $sReturn = _StringAddThousandsSep($sReturn, '.', ',')
	Return $sReturn & $aSize[$iFormat - 1]
EndFunc   ;==>_ByteAutoSize

;===============================================================================
; Function Name:   _GetUniqueFileName($sPath)
; Description::    Wenn der Dateiname bereits existiert wird ein Zähler
;                  in Form von: "_(1)" an den Dateinamen angehängt.
; Parameter(s):    $sPath = kompletter Pfad der Datei
; Requirement(s):  -
; Return Value(s): bei Erfolg = der (neue) Dateiname
;                  bei Fehler wird @error = 1 (Pfad falsch angegeben)
; Author(s):       Oscar (www.autoit.de)
;===============================================================================
Func _GetUniqueFileName($sPath)
	Local $aPath, $sNumber = '', $iCount = 0
	$aPath = StringRegExp($sPath, '(.+\\)(.+?)(?:_\(\d*\))*(\..+)', 3)
	If @error Then Return SetError(1, 0, 0)
	While FileExists($aPath[0] & $aPath[1] & $sNumber & $aPath[2])
		$iCount += 1
		$sNumber = '_(' & $iCount & ')'
	WEnd
	Return $aPath[0] & $aPath[1] & $sNumber & $aPath[2]
EndFunc   ;==>_GetUniqueFileName


#cs
	***** Ab hier Funktionen von anderen Usern *****
#ce

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlListView_GetSelectedIndicesNew
; Description ...: Retrieve indices of selected item(s)
; Syntax.........: _GUICtrlListView_GetSelectedIndicesNew($hWnd, $fArray = False)
; Parameters ....: $hWnd        - Handle to the control
;                  $fArray      - Return string or Array
;                  |True - Returns array
;                  |False - Returns pipe "|" delimited string
; Return values .: Success      - Selected indices Based on $fArray:
;                  +Array       - With the following format
;                  |[0] - Number of Items in array (n)
;                  |[1] - First item index
;                  |[2] - Second item index
;                  |[n] - Last item index
;                  |String      - With the following format
;                  |"0|1|2|n"
;                  Failure      - Based on $fArray
;                  |Array       - With the following format
;                  |[0] - Number of Items in array (0)
;                  |String      - Empty ("")
; Author ........: Gary Frost (gafrost)
; Modified.......: Oscar (www.autoit.de)
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _GUICtrlListView_GetSelectedIndicesNew($hWnd, $fArray = False)
	Local $Debug_LV =False																;<===========
	;If $Debug_LV Then __UDF_ValidateClassName($hWnd, $__LISTVIEWCONSTANT_ClassName)	;<===========

	Local $sIndices, $iRet, $iCount = _GUICtrlListView_GetItemCount($hWnd)
	For $iItem = 0 To $iCount
		If IsHWnd($hWnd) Then
			$iRet = _SendMessage($hWnd, $LVM_GETITEMSTATE, $iItem, $LVIS_SELECTED)
		Else
			$iRet = GUICtrlSendMsg($hWnd, $LVM_GETITEMSTATE, $iItem, $LVIS_SELECTED)
		EndIf
		If $iRet Then $sIndices &= $iItem & '|'
	Next
	If $fArray Then Return StringSplit(StringTrimRight($sIndices, 1), '|')
	Return StringTrimRight($sIndices, 1)
EndFunc   ;==>_GUICtrlListView_GetSelectedIndicesNew

#comments-start <===========================
;===============================================================================
; Function Name:   _GDIplus_ImageRotateFlip
; Description::    Rotates or flips an Image
; Parameter(s):    $hImage         - GDIPlus image handle
;                  $RotateFlipType - RotateFlip action to perform
; Requirement(s):  GDIplus
; Return Value(s): Success: 1
;                  Error: 0 and @error <> 0
; Author(s):       Prog@ndy
;===============================================================================
Func _GDIplus_ImageRotateFlip($hImage, $RotateFlipType)
	Local $ret = DllCall($ghGDIPDll, "int", "GdipImageRotateFlip", "hwnd", $hImage, "dword", $RotateFlipType)
	If @error Then Return SetError(1, 0, 0)
	Return SetError($ret[0], 0, $ret[0] = 0)
EndFunc   ;==>_GDIplus_ImageRotateFlip
#comments-end	<==========================

; Author: progandy (www.autoit.de)
Func _IsReparsePoint($FLS)
	Local Static $K32 = DllOpen('kernel32.dll')	;<====================
	Dim $DA = DllCall($K32, 'dword', 'GetFileAttributesW', 'wstr', $FLS)
	If @error Then Return SetError(1, @error, False)
	Return BitAND($DA[0], 1024) = 1024
EndFunc   ;==>_IsReparsePoint

; Author: progandy (www.autoit.de)
Func _GUIImageList_GetSystemImageList($bLargeIcons = False)
	Local $dwFlags, $hIml, $FileInfo = DllStructCreate($tagSHFILEINFO)
	$dwFlags = BitOR($SHGFI_USEFILEATTRIBUTES, $SHGFI_SYSICONINDEX)
	If Not ($bLargeIcons) Then
		$dwFlags = BitOR($dwFlags, $SHGFI_SMALLICON)
	EndIf
;~    '// Load the image list - use an arbitrary file extension for the
;~    '// call to SHGetFileInfo (we don't want to touch the disk, so use
;~    '// FILE_ATTRIBUTE_NORMAL && SHGFI_USEFILEATTRIBUTES).
	$hIml = _WinAPI_SHGetFileInfo(".txt", $FILE_ATTRIBUTE_NORMAL, _
			DllStructGetPtr($FileInfo), DllStructGetSize($FileInfo), $dwFlags)
	Return $hIml
EndFunc   ;==>_GUIImageList_GetSystemImageList

; Author: progandy (www.autoit.de)
Func _WinAPI_SHGetFileInfo($pszPath, $dwFileAttributes, $psfi, $cbFileInfo, $uFlags)
	Local $return = DllCall("shell32.dll", "dword_ptr", "SHGetFileInfo", "str", $pszPath, "DWORD", $dwFileAttributes, "ptr", $psfi, "UINT", $cbFileInfo, "UINT", $uFlags)
	If @error Then Return SetError(@error, 0, 0)
	Return $return[0]
EndFunc   ;==>_WinAPI_SHGetFileInfo

; Author: progandy (www.autoit.de)
Func _GUIImageList_GetFileIconIndex($sFileSpec, $bLargeIcons = False, $bForceLoadFromDisk = False)
	Local $dwFlags, $FileInfo = DllStructCreate($tagSHFILEINFO)
	$dwFlags = $SHGFI_SYSICONINDEX
	If $bLargeIcons Then
		$dwFlags = BitOR($dwFlags, $SHGFI_LARGEICON)
	Else
		$dwFlags = BitOR($dwFlags, $SHGFI_SMALLICON)
	EndIf
;~ ' We choose whether to access the disk or not. If you don't
;~ ' hit the disk, you may get the wrong icon if the icon is
;~ ' not cached. But the speed is very good!
	If Not $bForceLoadFromDisk Then $dwFlags = BitOR($dwFlags, $SHGFI_USEFILEATTRIBUTES)
;~ ' sFileSpec can be any file. You can specify a
;~ ' file that does not exist and still get the
;~ ' icon, for example sFileSpec = "C:\PANTS.DOC"
	Local $lR = _WinAPI_SHGetFileInfo( _
			$sFileSpec, $FILE_ATTRIBUTE_NORMAL, DllStructGetPtr($FileInfo), DllStructGetSize($FileInfo), _
			$dwFlags _
			)
	If ($lR = 0) Then
		Return SetError(1, 0, -1)
	Else
		Return DllStructGetData($FileInfo, "iIcon")
	EndIf
EndFunc   ;==>_GUIImageList_GetFileIconIndex

; #FUNCTION# ====================================================================================================================
; Name...........:    _PlayDefaultSystemSound()
; Description ...:    Spielt einen Systemklang, welcher in der Registry definiert ist.
; Syntax.........:    _PlayDefaultSystemSound($sSoundName, $iWait = 0)
; Parameters ....:    $sSoundName                - Name des SystemSound's
;                    | Default                   - Standardton Warnsignal / Default Beep
;                    | CriticalBatteryAlarm      - Alarm bei kritischem Batteriestand / when battery is critical
;                    | DeviceConnect            - Geräteanschluß / when a device is connect
;                    | DeviceDisconnect          - Gerätetrennung / when a device is disconnect
;                    | DeviceFail                - Geräteanschluß fehlgeschlagen / when a deviceconnect is fail
;                    | LowBatteryAlarm           - Alarm bei niedrigem Batteriestand / when battery is low
;                    | MailBeep                  - Posteingangsbenachrichtigung / when email is received
;                    | SystemAsterisk            - Stern / Asterisk
;                    | SystemExclamation         - Hinweis / when windows shows a warning
;                    | SystemExit                - Windows beenden / when Windows shuts down
;                    | SystemHand                - Kritischer Abbruch / when a critical stop occurs
;                    | SystemNotification        - Sprechblase / when a critical stop occurs
;                    | SystemStart               - Windows starten / when Windows starts up
;                    | WindowsLogoff             - beim Windows abmelden / when logging off Windows
;                    | WindowsLogon              - beim Windows anmelden / when logging on Windows
;                    | EmptyRecycleBin           - Löschen des Papierkorbs / when recycle bin is emptied
;                    | Navigating                - Browser Klick / navigating in browser

;                     $iWait                     - Warten bis SoundPlay beendet? (0 = nein / 1 = ja)
; Return values .:    -----
; Author ........:    funkey (AutoIt.de)
; ===============================================================================================================================
Func _PlayDefaultSystemSound($sSoundName, $iWait = 0) ; funkey
	Local $sKey = 'HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default'
	If $sSoundName = 'EmptyRecycleBin' Or $sSoundName = 'Navigating' Then $sKey = 'HKEY_CURRENT_USER\AppEvents\Schemes\Apps\Explorer'
	Local $sFile = StringReplace(RegRead($sKey & '\' & $sSoundName & '\.Default', ''), '%SystemRoot%', @WindowsDir)
	If $sFile = "" Then
		SoundPlay(StringReplace(RegRead($sKey & '\.Default\.Default', ''), '%SystemRoot%', @WindowsDir), $iWait)
	Else
		SoundPlay($sFile, $iWait)
	EndIf
EndFunc   ;==>_PlayDefaultSystemSound

; #FUNCTION# ====================================================================================================================
; Name...........: _StringAddThousandsSep
; Description ...: Returns the original numbered string with the Thousands delimiter inserted.
; Syntax.........: _StringAddThousandsSep($sString[, $sThousands = -1[, $sDecimal = -1]])
; Parameters ....: $sString    - The string to be converted.
;                  $sThousands - Optional: The Thousands delimiter
;                  $sDecimal   - Optional: The decimal delimiter
; Return values .: Success - The string with Thousands delimiter added.
; Author ........: SmOke_N (orignal _StringAddComma
; Modified.......: Valik (complete re-write, new function name)
; ===============================================================================================================================
Func _StringAddThousandsSep($sString, $sThousands = -1, $sDecimal = -1)
	If $sString = '-' Then Return $sString ; This Line is only for FileCommander
	Local $sResult = "" ; Force string
	Local $rKey = "HKCU\Control Panel\International"
	If $sDecimal = -1 Then $sDecimal = RegRead($rKey, "sDecimal")
	If $sThousands = -1 Then $sThousands = RegRead($rKey, "sThousand")
	Local $aNumber = StringRegExp($sString, "(\D?\d+)\D?(\d*)", 1) ; This one works for negatives.
	If UBound($aNumber) = 2 Then
		Local $sLeft = $aNumber[0]
		While StringLen($sLeft)
			$sResult = $sThousands & StringRight($sLeft, 3) & $sResult
			$sLeft = StringTrimRight($sLeft, 3)
		WEnd
		$sResult = StringTrimLeft($sResult, StringLen($sThousands)) ; Strip leading thousands separator
		If $aNumber[1] <> "" Then $sResult &= $sDecimal & $aNumber[1]
	EndIf
	Return $sResult
EndFunc   ;==>_StringAddThousandsSep

Func _Iif($test,$result1,$result2)
	;$i = 0, '%', ''
	if $test Then
		return $result1
	Else
		Return $result2
	EndIf
EndFunc