Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
- #AutoIt3Wrapper_OutFile=ChkDskGui.exe
- ; #AutoIt3Wrapper_Compile_Both=y
- #AutoIt3Wrapper_OutFile_X64=ChkDskGuiX64.exe
- #AutoIt3Wrapper_UseX64=n
- #AutoIt3Wrapper_icon=ChkDskGui.ico
- #AutoIt3Wrapper_UseUpx=n
- ; #AutoIt3Wrapper_Compression=4
- #AutoIt3Wrapper_Res_Comment=-
- #AutoIt3Wrapper_Res_Description=ChkDskGui.exe
- #AutoIt3Wrapper_Res_Fileversion=0.2.0.0
- #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=n
- #AutoIt3Wrapper_Res_LegalCopyright=AZJIO
- #AutoIt3Wrapper_Res_Language=1033
- #AutoIt3Wrapper_Run_AU3Check=n
- #AutoIt3Wrapper_Res_Field=Version|0.2
- #AutoIt3Wrapper_Res_Field=Build|2013.09.20
- #AutoIt3Wrapper_Res_Field=Coded by|AZJIO
- #AutoIt3Wrapper_Res_Field=CompanyName|AZJIO_Soft
- #AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time%
- #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer%
- #AutoIt3Wrapper_Run_Obfuscator=y
- #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
- ; #Obfuscator_Parameters=/SO
- #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3"
- #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
- ; @AZJIO 2013.09.20 AutoIt3_v3.3.8.1
- #NoTrayIcon
- #include <ComboConstants.au3>
- #include <Constants.au3>
- #include <GUIConstantsEx.au3>
- #include <WindowsConstants.au3>
- #include <Encoding.au3>
- #include <UserGUI.au3>
- Local $Lng[9]
- $Lng[0] = 'Check Disk'
- $Lng[1] = '\F - Fix disk errors'
- $Lng[2] = '\R - Recovering bad sectors'
- $Lng[3] = '\X - Forced dismount volume'
- $Lng[4] = 'Start'
- $Lng[5] = 'Viewing'
- $Lng[6] = 'Error'
- $Lng[7] = 'Not found any disk' & @LF & 'Completion of the program'
- $Lng[8] = 'Gb'
- If @OSLang = 0419 Then
- $Lng[0] = 'ChkDskGui - проверка дисков на ошибки'
- $Lng[1] = '\F - Исправление ошибок на диске'
- $Lng[2] = '\R - Восстановление поврежденных секторов'
- $Lng[3] = '\X - Принудительное отключение тома'
- $Lng[4] = 'Старт'
- $Lng[5] = 'Просмотр'
- $Lng[6] = 'Ошибка'
- $Lng[7] = 'Не найдено ни одного диска' & @LF & 'Завершение программы'
- $Lng[8] = 'Гб'
- EndIf
- If StringLen($Lng[8]) > 2 Then $Lng[8] = StringLeft($Lng[8], 2)
- FileChangeDir(@ScriptDir)
- _GetPath('chkdsk.exe') ; Возможно не нужно, но проверяет и предупреждает в случае, если не найден chkdsk.exe
- If @error Then Exit MsgBox(16 + 262144, $sTitle, $Lng[1] & @LF & $Lng[2])
- Opt("GUIOnEventMode", 1)
- $sp = Chr(1)
- Opt("GUIDataSeparatorChar", $sp)
- $sList = _GetDrv()
- If Not $sList Then Exit MsgBox(4096, $sTitle, $Lng[7])
- $hGUI = GUICreate($Lng[0], 440, 130)
- ; GUISetIcon(@ScriptDir & '\ChkDskGui.ico')
- If Not @Compiled Then GUISetIcon(@ScriptDir & '\ChkDskGui.ico')
- GUISetOnEvent($GUI_EVENT_CLOSE, "_Form1Close")
- $Current=StringRegExp($sList, '(?:\A|\001)([C-Z]: Fixed.*?)(?=\001)', 1)
- If @error Then
- $Current = StringLeft($sList, StringInStr($sList & $sp, $sp) - 1)
- Else
- $Current = $Current[0]
- EndIf
- $iCombo = GUICtrlCreateCombo("", 20, 16, 400, 25, $WS_VSCROLL + $CBS_DROPDOWNLIST)
- GUICtrlSetFont(-1, -1, -1, 0, "Courier New")
- GUICtrlSetData(-1, $sList, $Current)
- GUICtrlSetOnEvent(-1, "_Combo")
- $iCh_ArgF = GUICtrlCreateCheckbox($Lng[1], 20, 45, 280, -1)
- GUICtrlSetState(-1, $GUI_CHECKED)
- GUICtrlSetOnEvent(-1, "_Ch_ArgF")
- $iCh_ArgR = GUICtrlCreateCheckbox($Lng[2], 20, 65, 280, -1)
- GUICtrlSetOnEvent(-1, "_Ch_ArgR")
- $iCh_ArgX = GUICtrlCreateCheckbox($Lng[3], 20, 85, 280, -1)
- GUICtrlSetOnEvent(-1, "_Ch_ArgX")
- GUICtrlSetState(-1, $GUI_CHECKED)
- $iBtnHelp = GUICtrlCreateButton('?', 300, 77, 27, 32)
- ; $iBtnHelp = GUICtrlCreateButton('?', 305, 82, 22, 22)
- GUICtrlSetOnEvent(-1, "_Help")
- GUICtrlSetState(-1, $GUI_FOCUS + $GUI_DEFBUTTON)
- $iBtnStart = GUICtrlCreateButton($Lng[4], 330, 77, 90, 32)
- GUICtrlSetOnEvent(-1, "_Start")
- $iStatusBar = GUICtrlCreateLabel('chkdsk.exe' & _GetComString(), 20, 110, 420, 17)
- GUISetState()
- While 1
- Sleep(10000)
- WEnd
- Func _Combo()
- GUICtrlSetData($iStatusBar, 'chkdsk.exe' & _GetComString())
- EndFunc
- Func _Ch_ArgF()
- If GUICtrlRead($iCh_ArgF) = $GUI_UNCHECKED Then
- GUICtrlSetState($iCh_ArgX, $GUI_UNCHECKED)
- GUICtrlSetState($iCh_ArgR, $GUI_UNCHECKED)
- EndIf
- GUICtrlSetData($iStatusBar, 'chkdsk.exe' & _GetComString())
- EndFunc
- Func _Ch_ArgR()
- GUICtrlSetState($iCh_ArgF, $GUI_CHECKED)
- GUICtrlSetData($iStatusBar, 'chkdsk.exe' & _GetComString())
- EndFunc
- Func _Ch_ArgX()
- If GUICtrlRead($iCh_ArgX) = $GUI_CHECKED Then GUICtrlSetState($iCh_ArgF, $GUI_CHECKED)
- GUICtrlSetData($iStatusBar, 'chkdsk.exe' & _GetComString())
- EndFunc
- Func _Form1Close()
- Exit
- EndFunc
- Func _GetComString()
- Local $sComString, $tmp
- $tmp = StringRegExp(GUICtrlRead($iCombo), '(?i)^.{6}([a-z]:).+', 1)
- If @error Then
- Return SetError(1, 0, $Lng[6])
- Else
- $sComString &= ' ' & $tmp[0]
- EndIf
- If GUICtrlRead($iCh_ArgF) = $GUI_CHECKED Then $sComString &= " /F"
- If GUICtrlRead($iCh_ArgR) = $GUI_CHECKED Then $sComString &= " /R"
- If GUICtrlRead($iCh_ArgX) = $GUI_CHECKED Then $sComString &= " /X"
- Return $sComString
- EndFunc ;==>_GetComString
- Func _Start()
- Local $sComString = _GetComString()
- If @error Then
- GUICtrlSetData($iStatusBar, $Lng[6])
- Return SetError(1, 0, $Lng[6])
- EndIf
- _BtnDisable()
- ; Color 3b
- RunWait(@ComSpec & ' /c (Title Check Disk & @Echo off & Color 1e & cls & chkdsk.exe' & $sComString & ' & set /p Ok=^>^>)')
- _BtnDisable($GUI_ENABLE)
- EndFunc
- Func _Help() ; coded by AZJIO (2013.09.20)
- Local $iPID, $sOut, $tmp
- $iPID = Run('chkdsk.exe /?', @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
- While 1
- $tmp = StdoutRead($iPID)
- If @error Then ExitLoop
- If $tmp Then $sOut &= @CRLF & $tmp
- WEnd
- If $sOut Then
- _Viewing($hGUI, _Encoding_866To1251($sOut))
- EndIf
- EndFunc ;==>_Help
- ; Func _Help()
- ; _BtnDisable()
- ; RunWait(@ComSpec & ' /c (Title Check Disk & @Echo off & Color 1e & cls & chkdsk.exe /? & set /p Ok=^>^>)')
- ; _BtnDisable($GUI_ENABLE)
- ; EndFunc ;==>_Help
- Func _BtnDisable($iState = $GUI_DISABLE)
- GUICtrlSetState($iBtnHelp, $iState)
- GUICtrlSetState($iBtnStart, $iState)
- EndFunc ;==>_Help
- Func _Viewing($hGUI, $sLog) ; coded by AZJIO (2013.09.20)
- Local $hGuiLog, $aRect, $iEdit
- $aRect = _GetChildCoor($hGUI, 560, 330)
- GUISetState(@SW_DISABLE, $hGUI)
- $hGuiLog = GUICreate($Lng[5], $aRect[0], $aRect[1], $aRect[2], $aRect[3], BitOR($WS_OVERLAPPEDWINDOW, $WS_POPUP), -1, $hGUI)
- If Not @Compiled Then GUISetIcon(@ScriptDir & '\ChkDskGui.ico')
- $iEdit = GUICtrlCreateEdit('', 0, 0, $aRect[0], $aRect[1])
- GUISetState(@SW_SHOW, $hGuiLog)
- GUICtrlSetData($iEdit, $sLog)
- Opt("GUIOnEventMode", 0)
- Do
- Until GUIGetMsg() = $GUI_EVENT_CLOSE
- Opt("GUIOnEventMode", 1)
- GUISetState(@SW_ENABLE, $hGUI)
- GUIDelete($hGuiLog)
- EndFunc ;==>_Viewing
- Func _GetDrv()
- Local $sInfo = _ComboListDrive('Fixed')
- $sInfo &= _ComboListDrive('Removable')
- Return StringTrimLeft($sInfo, 1)
- EndFunc
- Func _ComboListDrive($Type) ; coded by AZJIO (2013.01.26)
- Local $aDrive = DriveGetDrive($Type), $list = '', $sString, $sLabel, $aDisc_Partition
- If @error Then Return ''
- If $Type = 'Removable' Then $Type = 'Rem'
- For $i = 1 To $aDrive[0]
- If $aDrive[$i] = 'A:' Then ContinueLoop
- $sLabel = DriveGetLabel($aDrive[$i])
- If StringLen($sLabel) > 15 Then $sLabel = StringLeft($sLabel, 12) & '...'
- $aDisc_Partition = _GetDiskNimberForDrive($aDrive[$i])
- ; If @error Then Local $aDisc_Partition[2] = ['?', '?']
- $sString = StringFormat('%2s:%-2s %-2s %-5s %-15s %-5s ', $aDisc_Partition[0], $aDisc_Partition[1], StringUpper($aDrive[$i]), $Type, $sLabel, _
- DriveGetFileSystem($aDrive[$i])) & _GetSize(DriveSpaceTotal($aDrive[$i])) & ' ' & $Lng[8]
- $list &= $sp & $sString
- Next
- Return $list
- EndFunc ;==>_ComboListDrive
- Func _GetSize($s)
- $s = StringFormat('%.03f', $s / 1024)
- If StringLen($s) > 7 Then $s = StringRegExpReplace(StringTrimRight($s, 4), '(\A\d{1,3}(?=(\d{3})+\z)|\d{3}(?=\d))', '\1 ') & StringRight($s, 4)
- Return StringFormat('%9s', $s) ; 9 терабайт
- EndFunc
- ; http://www.autoitscript.com/forum/topic/91598-get-disk-number-from-drive-letter/?p=659721
- ; Описание ........: Возвращает номер диска и номер раздела в формате n:n (<номер диска>:<номер раздела>)
- ; Параметры:
- ; $sDriveLetter - Буква диска с двоеточием, например C:
- ; Неудачно , возвращает -1, @error:
- ; |1 - Ошибка CreateFile, ваша система очень старая
- ; |2 - Диск не существует
- ; |3 - Неудачный вызов DeviceIoControl
- ; |4 - Не раздела диска
- Func _GetDiskNimberForDrive($sDriveLetter) ; Буква диска
- Local $aDrive[2] = ['?', '?']
- Local $a_hCall = DllCall("kernel32.dll", "hwnd", "CreateFile", _
- "str", "\\.\" & $sDriveLetter, _; Буква диска
- "dword", 0, _
- "dword", 0, _
- "ptr", 0, _
- "dword", 3, _; OPEN_EXISTING
- "dword", 128, _; FILE_ATTRIBUTE_NORMAL
- "ptr", 0)
- If @error Then
- Return SetError(1, 0, $aDrive); Ваша система очень старая. Сделайте что-нибудь.
- EndIf
- If $a_hCall[0] = -1 Then
- Return SetError(2, 0, $aDrive) ; Диск не существует
- EndIf
- Local $hDevice = $a_hCall[0]
- Local $tIOCTL_STORAGE_GET_DEVICE_NUMBER = DllStructCreate("dword DeviceType;" & _
- "dword DeviceNumber;" & _
- "int PartitionNumber")
- Local $a_iCall = DllCall("kernel32.dll", "int", "DeviceIoControl", _
- "hwnd", $hDevice, _
- "dword", 0x2D1080, _; IOCTL_STORAGE_GET_DEVICE_NUMBER
- "ptr", 0, _
- "dword", 0, _
- "ptr", DllStructGetPtr($tIOCTL_STORAGE_GET_DEVICE_NUMBER), _
- "dword", DllStructGetSize($tIOCTL_STORAGE_GET_DEVICE_NUMBER), _
- "dword*", 0, _
- "ptr", 0)
- If @error Or Not $a_hCall[0] Then
- DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hDevice)
- Return SetError(3, 0, $aDrive); неудачный вызов DeviceIoControl
- EndIf
- DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hDevice)
- If DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "DeviceType") = 7 Then; FILE_DEVICE_DISK
- $aDrive[0] = DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "DeviceNumber")
- $aDrive[1] = DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "PartitionNumber")
- Return SetError(0, 0, $aDrive)
- EndIf
- Return SetError(4, 0, $aDrive); Не раздела диска
- EndFunc ;==>_GetDiskNimberForDrive
- Func _GetPath($sFile)
- Local $tmp = _WinAPI_PathFindOnPath($sFile, @ScriptDir)
- If Not @error Then Return $tmp
- ; Теоритически эти пути уже есть в %PATH%, но проверим ещё раз
- If FileExists(@SystemDir & '\' & $sFile) Then
- Return @SystemDir & '\' & $sFile
- ElseIf FileExists(@WindowsDir & '\' & $sFile) Then
- Return @WindowsDir & '\' & $sFile
- EndIf
- Return SetError(1)
- EndFunc ;==>_GetPath
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement