#cs
****************************************************************************************
****************************************************************************************
****************************************************************************************
********																		********
********																		********
********	Dies ist ein Setup_Version 1.0.1								    ********
********	Copyright: Sirocool (www.autoit.de)						         	********
********																		********
********																		********
********	Es läuft zu 100% auf Windows XP	                                    ********
********	Es läuft zu 000% auf Windows Vista (wurde noch nicht getestet)      ********
********    Es läuft zu 100% auf Windows 07	x64 7201                            ********
********	Alle anderen Windows Versionen sind nicht getestet!					********
********																		********
********	Mit freundlicher Mithilfe von www.autoit.de							********
********	Danke an alle die mir mit diesem Projekt geholfen haben.			********
********																		********
********	Bei Fragen oder Problemen, schreib mir eine PN im Forum.			********
********																		********
********																		********
****************************************************************************************
****************************************************************************************
****************************************************************************************
#ce
#NoTrayIcon
#RequireAdmin
#include <ButtonConstants.au3>
#include <GUIConstants.au3>
#include <7Zip.au3>
#include <Array.au3>


#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiToolBar.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

#include <ListViewConstants.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>

#include<WindowsConstants.au3>
#include<ListViewConstants.au3>
#include<ButtonConstants.au3>
#include<GUIConstantsEx.au3>
#include<Guilistview.au3>
#include <File.au3>
#include <StaticConstants.au3>
#Include <Date.au3>








Global $Width = 600
Global $Hight = 325
Global $HeaderTitel = ""
Global $Headerversion = ""
Global $HeaderListView = "Name|Größe|Typ|Erstellt|Pfad"
Global $HeaderCombo 
$Drives = DriveGetDrive("FIXED")
For $i = 1 to $Drives[0]
	$HeaderCombo &= "|Lokaler Datenträger (" & StringUpper($Drives[$i]) & ")"
Next
$HeaderCombo &= "|Desktop|Eigene Dateien|Gemeinsame Dokumente"

Global Enum $item1 = 1000, $item2, $item3, $item4, $item5, $item6, $item7, $item8, $item9, $item10, $item11
; OS-Check
Switch @OSVersion
	Case 'WIN_VISTA', 'WIN_7'
		Global $aID3Index[4] = [21, 13, 27, 28] ; Title, Artists, Duration, Bitrate
	Case 'WIN_XP', 'WIN_2003'
		Global $aID3Index[4] = [10, 16, 21, 22] ; Title, Artists, Duration, Bitrate
	Case 'WIN_2000'
		Global $aID3Index[4] = [11, 10, 33, 30] ; Title, Artists, Duration, Bitrate
	Case Else
		Exit MsgBox(16, $HeaderTitel,"Englisch"& @CRLF &"Your Windows-Version is not compatible with this program! "& @CRLF &""& @CRLF &"Deutsch"& @CRLF &"Ihre Windows-Version ist nicht kompatibel mit diesem Programm!")
	EndSwitch
	
$hGui= GUICreate($HeaderTitel & "" & $Headerversion, $Width, $Hight, -1, -1, $WS_POPUP)

$MenueDatei = GUICtrlCreateLabel('&Datei', 2, 63, 40, 19, 0x201)
;GUICtrlSetOnEvent(-1, '_MenuPressed')
$DateiContext = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
$OptionsOpen = GUICtrlCreateMenuItem("Ö&ffnen", $DateiContext)
$OptionsClose = GUICtrlCreateMenuItem("S&chließen", $DateiContext)
GUICtrlCreateMenuItem("", $DateiContext)
$OptionsExit = GUICtrlCreateMenuItem("B&eenden", $DateiContext)
;GUICtrlSetOnEvent(-1, '_Exit')

$MenueHelp = GUICtrlCreateLabel("&Hilfe", 135, 63, 30, 19, 0x201)
;GUICtrlSetOnEvent(-1, '_MenuPressed')
$HelpContext = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
$HelpWWW = GUICtrlCreateMenuItem("&Website", $HelpContext)
;GUICtrlSetOnEvent(-1, '_Website')
GUICtrlCreateMenuItem("", $HelpContext)
$HelpAbout = GUICtrlCreateMenuItem("Ü&ber...", $HelpContext)
;GUICtrlSetOnEvent(-1, '_About')

GUICtrlCreateLabel("",2,85,596,1)
GUICtrlSetBkColor(-1,0x000000)

$Combo1 = GUICtrlCreateCombo("", 2, 87, 596, 25,0x0003)
GUICtrlSetData($Combo1,$HeaderCombo,"Lokaler Datenträger (C:)")

$ListView = GUICtrlCreateListView($HeaderListView, 2, 110, 596, 180,$LVS_EX_FULLROWSELECT,+$LVS_EX_SUBITEMIMAGES+$LVS_EX_GRIDLINES+$LVS_EX_CHECKBOXES+$LVS_EX_DOUBLEBUFFER) 
GUICtrlSetImage(-1,@ScriptDir & "\data\Images\icon.ico"); "shell32.dll", 5, 0
Global $hLVHandle = GUICtrlGetHandle($ListView) ; das Handle vom Listview wird für die UDF-Listview-Funktionen benötigt
_GUICtrlListView_SetColumn($hLVHandle, 0, "Name", 150, 0) ; 1. Spalte = 360 Px breit, links ausgerichtet
_GUICtrlListView_SetColumn($hLVHandle, 1, "Größe", 80, 0) 
_GUICtrlListView_SetColumn($hLVHandle, 2, "Typ", 80, 0)
_GUICtrlListView_SetColumn($hLVHandle, 3, "Erstellt", 80, 0)
_GUICtrlListView_SetColumn($hLVHandle, 4, "Pfad", 207, 0)
$mnu = GUICtrlCreateContextMenu($Listview)
$mnu_open = GUICtrlCreateMenuItem('Archiv öffnen', $mnu)
$mnu_entpacken = GUICtrlCreateMenuItem('Archiv entpacken', $mnu)
$mnu_einpacken = GUICtrlCreateMenuItem('Archiv einpacken', $mnu)
$mnu_Delete = GUICtrlCreateMenuItem('Archiv löschen', $mnu)

$Progress1 = GUICtrlCreateProgress(8, 300, 500, 17)
$Label1 = GUICtrlCreateLabel("Status:",520, 300, 37, 17)
$Label2 = GUICtrlCreateLabel("Label2", 560, 300, 36, 17)

GUICtrlCreatePic (@ScriptDir &"\data\Images\software\1.bmp",0,0,600,63, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS,$WS_DISABLED))
;GUICtrlCreatePic (@ScriptDir &"\dataImages\software\2.bmp",0,63,600,25, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS,$WS_DISABLED))
GUICtrlCreatePic (@ScriptDir &"\data\Images\software\3.bmp",0,0,600,325, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS,$WS_DISABLED))
GUICtrlCreateLabel("",0,0,1000,800,0,$GUI_WS_EX_PARENTDRAG)
	GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUISetState()

Global $AccelKeys[2][2]=[["!d", $MenueDatei], ["!h", $MenueHelp]]
GUISetAccelerators($AccelKeys)
$path = "C:\"
_FillListView()

If IsArray($CmdLine) Then ;prüft, ob $CDMLINE ein Array ist
    For $i = 1 To $CmdLine[0] ;schleife
	If StringRight($CmdLine[$i], 4) = ".RAR" And FileExists($CmdLine[$i]) Then  _Open($CmdLine[$i]) 
	If StringRight($CmdLine[$i], 4) = ".ZIP" And FileExists($CmdLine[$i]) Then  _Open($CmdLine[$i]) 
	If StringRight($CmdLine[$i], 4) = ".CAB" And FileExists($CmdLine[$i]) Then  _Open($CmdLine[$i])	
	If StringRight($CmdLine[$i], 4) = ".ARJ" And FileExists($CmdLine[$i]) Then  _Open($CmdLine[$i])		
	If StringRight($CmdLine[$i], 4) = ".LZH" And FileExists($CmdLine[$i]) Then  _Open($CmdLine[$i]) 
	If StringRight($CmdLine[$i], 4) = ".ACE" And FileExists($CmdLine[$i]) Then  _Open($CmdLine[$i]) 
	If StringRight($CmdLine[$i], 4) = ".7-Zip"And FileExists($CmdLine[$i])Then  _Open($CmdLine[$i])	
	If StringRight($CmdLine[$i], 4) = ".TAR" And FileExists($CmdLine[$i]) Then  _Open($CmdLine[$i])
	If StringRight($CmdLine[$i], 4) = ".GZip" And FileExists($CmdLine[$i])Then  _Open($CmdLine[$i]) 
	If StringRight($CmdLine[$i], 4) = ".UUE" And FileExists($CmdLine[$i]) Then  _Open($CmdLine[$i]) 
	If StringRight($CmdLine[$i], 4) = ".BZ2" And FileExists($CmdLine[$i]) Then  _Open($CmdLine[$i])	
	If StringRight($CmdLine[$i], 4) = ".JAR" And FileExists($CmdLine[$i]) Then  _Open($CmdLine[$i])
	If StringRight($CmdLine[$i], 4) = ".ISO" And FileExists($CmdLine[$i]) Then  _Open($CmdLine[$i]) 
	If StringRight($CmdLine[$i], 4) = ".IMG" And FileExists($CmdLine[$i]) Then  _Open($CmdLine[$i]) 
	If StringRight($CmdLine[$i], 4) = ".MP3" And FileExists($CmdLine[$i]) Then  _Open($CmdLine[$i])	
	If StringRight($CmdLine[$i], 4) = ".Z" And FileExists($CmdLine[$i])   Then  _Open($CmdLine[$i])
	Next
EndIf






While 1
	$nMsg = GUIGetMsg(1)
		 Switch $nMsg[1]
	Case $hGui
		 Switch $nMsg[0]
	Case $GUI_EVENT_CLOSE
		 Exit
	;Case $MenuItem2
		 ;$Openfile = FileOpenDialog ($HeaderTitel, @WorkingDir , "Alle-Dateien (*.*)|Alle Archive (*.zip;*.rar)|Rar-Archive(*.rar)",1+2+4,"",$hGUI)
		 ;_Open($Openfile)
	 Case $Combo1
		If StringInStr(GUICtrlRead($Combo1),"Lokaler Datenträger") Then
			For $i = 1 to $Drives[0]
				If GUICtrlRead($Combo1) = "Lokaler Datenträger (" & StringUpper($Drives[$i]) & ")" Then
				$path = StringUpper($Drives[$i])&"\"
				_FillListView()
				EndIf
			Next
		ElseIf	GUICtrlRead($Combo1) = "Desktop" then
		$path = @UserProfileDir&"\Desktop\"
		_FillListView()
		ElseIf	GUICtrlRead($Combo1) = "Eigene Dateien" then
		$path = @UserProfileDir
		_FillListView()
		ElseIf	GUICtrlRead($Combo1) = "Gemeinsame Dokumente" then
		$path = @CommonFilesDir
		_FillListView()
		EndIf		
	Case $hLVHandle
		_GUICtrlListView_SortItems($hLVHandle,0)
	;Case $MenuItem3	
		 ;$sOutput = FileSelectFolder("Bitte Installationspfad wählen", "", 1, "")
		Case $MenueDatei
            ShowMenu($hGui, $MenueDatei, $DateiContext) 
EndSwitch

EndSwitch
WEnd



Func _Exit()
    Exit
EndFunc

Func _MenuPressed()
	

	$msg = GUIGetMsg()

	Select
		  Case $msg = $MenueDatei
            ShowMenu($hGui, $MenueDatei, $DateiContext)
        Case $msg = $MenueHelp
            ShowMenu($hGui, $MenueHelp, $HelpContext)
  
	EndSelect
 
	#cs	
  Switch @GUI_CtrlId
        Case $msg = $MenueDatei
            ShowMenu($hGui, $MenueDatei, $DateiContext)
        Case $msg = $MenueHelp
            ShowMenu($hGui, $MenueHelp, $HelpContext)
			EndSwitch
			#ce
    	
EndFunc

Func _About()
    MsgBox(64, "About...", "Beispiel für ein eigenes Menü")
EndFunc

Func _Website()
    MsgBox(64, "Website...", "www.autoit.de")
EndFunc

; Show a menu in a given GUI window which belongs to a given GUI ctrl
Func ShowMenu($hWnd, $CtrlID, $nContextID)
    Local $arPos, $x, $y
    Local $hMenu = GUICtrlGetHandle($nContextID)
    
    $arPos = ControlGetPos($hWnd, "", $CtrlID)
    
    $x = $arPos[0]
    $y = $arPos[1] + $arPos[3]
    
    ClientToScreen($hWnd, $x, $y)
    TrackPopupMenu($hWnd, $hMenu, $x, $y)
EndFunc   ;==>ShowMenu

; Convert the client (GUI) coordinates to screen (desktop) coordinates
Func ClientToScreen($hWnd, ByRef $x, ByRef $y)
    Local $stPoint = DllStructCreate("int;int")
    
    DllStructSetData($stPoint, 1, $x)
    DllStructSetData($stPoint, 2, $y)

    DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint))
    
    $x = DllStructGetData($stPoint, 1)
    $y = DllStructGetData($stPoint, 2)
    ; release Struct not really needed as it is a local
    $stPoint = 0
EndFunc   ;==>ClientToScreen

; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd)
Func TrackPopupMenu($hWnd, $hMenu, $x, $y)
    DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc   ;==>TrackPopupMenu

Func _FillListView()
_GUICtrlListView_DeleteAllItems($hLVHandle)	 
$FileList = _FileListToArray($path)
If (Not IsArray($FileList)) OR (@error = 1) Then
MsgBox(0, "", "No Files\Folders Found.")
Exit ; Soll sich das Programm wirklich beenden? das geht doch sicherlich eleganter.
EndIf

Global $listviewItems[$FileList[0] + 1], $ItemSize[$FileList[0] + 1], $ItemType[$FileList[0] + 1], $ItemDate[$FileList[0] + 1]
Local $Date
For $i = 1 To $FileList[0] 
	If StringInStr(FileGetAttrib($path&$FileList[$i]),"D",1) Then
		$ItemType[$i] = "Ordner"
		$ItemDate[$i] = "-"
	;~ 		Für die Größe:
	;~ 		entweder DAS hier (Gibt die Größe aller im Ordner befindlichen Dateien an)
	;~ 		$ItemSize[$i] = DirGetSize($path&$FileList[$i],2)
	;~ 		Das hier: (Gibt die Größe aller Dateien und Ordner im Ordner an (Rekursiv, also LANGSAM!!!)
	;~ 		$ItemSize[$i] = DirGetSize($path&$FileList[$i],0) 
	;~ 		Oder Das hier: (Ist eigentlich bei den meisten Programme standard
		$ItemSize[$i] = "-"

	Else
		$ItemType[$i] = "Datei"
		$ItemSize[$i] = FileGetSize($path&$FileList[$i])
		$Date = FileGetTime($path&$FileList[$i])
		If IsArray($Date) Then
		$ItemDate[$i] = $Date[2] & "." & $Date[1] & "." & $Date[0]
		Else
		$ItemDate[$i] = "-"
		EndIf
	EndIf
$listviewItems[$i] = GUICtrlCreateListViewItem($FileList[$i] & "|" & $ItemSize[$i] & "|" & $ItemType[$i] & "|" & $ItemDate[$i], $listview)
Next 

EndFunc

Func _GuiCtrlListView_GetFirstSelected($hwnd)
    Global $SelectedItemi
    $SelectedItemi = _GUICtrlListView_GetSelectedIndices($hwnd, True)
    If $SelectedItemi[0] = 0 Then Return SetError(1)
    Return $SelectedItemi[1]
EndFunc   ;==>_GuiCtrlListView_GetFirstSelected

Func _test()
#cs######################################################################
# Ihr werden die Daten für Icons zum Öffnen  benötigt                   #
#########################################################################
#ce
$Openfile =FileOpenDialog ($HeaderTitel, "C:\Dokumente und Einstellungen\Administrator\Eigene Dateien\" ,"Alle Öffnen (*.*)",1+2+4,"",$hGUI)
_Open($Openfile)	
EndFunc

Func _GUIImageList_AddIconSize($hWnd, $sFile, $iSize = 32)
Local $tIcon, $iResult, $hIcon
$hIcon = _WinAPI_LoadImage(0, $sFile, $IMAGE_ICON, $iSize, $iSize, $LR_LOADFROMFILE)
_WinAPI_Check("_GUIImageList_AddIcon", ($hIcon = 0), -1)
$iResult = _GUIImageList_ReplaceIcon($hWnd, -1, $hIcon)
_WinAPI_Check("_GUIImageList_AddIcon", ($iResult = -1), -2)
_WinAPI_DestroyIcon($hIcon)
Return $iResult
EndFunc   ;==>_GUIImageList_AddIconSize

Func _Open($open1) 
#cs######################################################################
# Ihr werden die Daten Übergeben zum Öffnen                             #
#########################################################################
#ce
_GUICtrlListView_DeleteAllItems($hLVHandle)	
$xmsg = StringSplit($Open1, "|")
if IsArray($xmsg) Then 
for $i = 1 to $xmsg[0]
$fit = $xmsg[1] & "\" & $xmsg[$i]
if $xmsg[0] = 1 Then $fit = $xmsg[1]
$data = _GetExtProperty($fit, -1)
if IsArray($data) Then GUICtrlCreateListViewItem($data[0] & "|" & $data[1] & "|" & $data[2] & "|"& $data[3] & "|"  & $fit, $ListView)
Next
EndIf	
EndFunc

Func _GetExtProperty($sPath, $iProp)
Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
$iExist = FileExists($sPath)
If $iExist = 0 Then
SetError(1)
Return 0
Else
$sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
$sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
$oShellApp = ObjCreate("shell.application")
$oDir = $oShellApp.NameSpace($sDir)
$oFile = $oDir.Parsename($sFile)
If $iProp = -1 Then
Local $aProperty[35]
For $i = 0 To 34
$aProperty[$i] = $oDir.GetDetailsOf($oFile, $i)
Next
Return $aProperty
Else
$sProperty = $oDir.GetDetailsOf($oFile, $iProp)
If $sProperty = "" Then
Return 0
Else
Return $sProperty
EndIf
EndIf
EndIf
EndFunc   

Func _reg($sFileType)
#cs######################################################################
# Ihr werden die Daten Übergeben von der Registrie                      #
#########################################################################
#ce	
if @Compiled Then 
$sREgistryFolder = 'HKEY_CURRENT_USER\Software\Classes\'
if $sFileType = "" Then $sFileType = ".rar"
        $sFileTypeName = 'Devil_Unpack'
        $sFileTypeDescriptopn = 'Devil_Unpack'
        $sFileTypeIcon = @ScriptFullPath & ',-1'
        $sFileTypeOpenCommand = @ScriptFullPath & ' "%1"'
        RegWrite($sREgistryFolder & $sFileType, '', 'REG_SZ', $sFileTypeName)
        RegWrite($sREgistryFolder & $sFileType, 'Content Type', 'REG_SZ', 'audio/mpeg')
        RegWrite($sREgistryFolder & $sFileType, 'PerceivedType', 'REG_SZ', 'audio')
        RegWrite($sREgistryFolder & $sFileTypeName, '', 'REG_SZ', $sFileTypeDescriptopn)
        RegWrite($sREgistryFolder & $sFileTypeName & '\Defaulticon', '', 'REG_SZ', $sFileTypeIcon)
        RegWrite($sREgistryFolder & $sFileTypeName & '\Shell\open\command', '', 'REG_SZ', $sFileTypeOpenCommand)
		EndIf
EndFunc