#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


Dim $CPGLBOX[30],$check[30]


Func _cpgl()
$CPGL = GUICreate("磁盘管理", 198, 248, -1, -1, -1, -1, $window)
GUISetBkColor(0xEFF0F2)
$CPGLtap_1 = GUICtrlCreateTab(8, 8, 177, 201)
$CPGLtap_1_1 = GUICtrlCreateTabItem("隐藏磁盘")
$CPGLBOX[0] = GUICtrlCreateCheckbox("A", 24, 40, 33, 17)
$CPGLBOX[1] = GUICtrlCreateCheckbox("B", 24, 64, 33, 17)
$CPGLBOX[2] = GUICtrlCreateCheckbox("C", 24, 88, 33, 17)
$CPGLBOX[3] = GUICtrlCreateCheckbox("D", 24, 112, 33, 17)
$CPGLBOX[4] = GUICtrlCreateCheckbox("E", 24, 136, 33, 17)
$CPGLBOX[5] = GUICtrlCreateCheckbox("F", 24, 160, 33, 17)
$CPGLBOX[6] = GUICtrlCreateCheckbox("G", 24, 184, 33, 17)
$CPGLBOX[7] = GUICtrlCreateCheckbox("H", 64, 40, 33, 17)
$CPGLBOX[8] = GUICtrlCreateCheckbox("I", 64, 64, 33, 17)
$CPGLBOX[9] = GUICtrlCreateCheckbox("J", 64, 88, 33, 17)
$CPGLBOX[10] = GUICtrlCreateCheckbox("K", 64, 112, 33, 17)
$CPGLBOX[11] = GUICtrlCreateCheckbox("L", 64, 136, 33, 17)
$CPGLBOX[12] = GUICtrlCreateCheckbox("M", 64, 160, 33, 17)
$CPGLBOX[13] = GUICtrlCreateCheckbox("N", 64, 184, 33, 17)
$CPGLBOX[14] = GUICtrlCreateCheckbox("O", 104, 40, 33, 17)
$CPGLBOX[15] = GUICtrlCreateCheckbox("P", 104, 64, 33, 17)
$CPGLBOX[16] = GUICtrlCreateCheckbox("Q", 104, 88, 33, 17)
$CPGLBOX[17] = GUICtrlCreateCheckbox("R", 104, 112, 33, 17)
$CPGLBOX[18] = GUICtrlCreateCheckbox("S", 104, 136, 33, 17)
$CPGLBOX[19] = GUICtrlCreateCheckbox("T", 104, 160, 33, 17)
$CPGLBOX[20] = GUICtrlCreateCheckbox("U", 144, 40, 33, 17)
$CPGLBOX[21] = GUICtrlCreateCheckbox("V", 144, 64, 33, 17)
$CPGLBOX[22] = GUICtrlCreateCheckbox("W", 144, 88, 33, 17)
$CPGLBOX[23] = GUICtrlCreateCheckbox("X", 144, 112, 33, 17)
$CPGLBOX[24] = GUICtrlCreateCheckbox("Y", 144, 136, 33, 17)
$CPGLBOX[25] = GUICtrlCreateCheckbox("Z", 144, 160, 33, 17)
$CPGLbel_1 = GUICtrlCreateLabel("全选", 104, 184, 28, 17)
GUICtrlSetCursor (-1, 0)
$CPGLbel_2 = GUICtrlCreateLabel("/", 136, 184, 9, 17)
$CPGLbel_3 = GUICtrlCreateLabel("取消", 144, 184, 28, 17)
GUICtrlSetCursor (-1, 0)
$CPGLtap_1_2 = GUICtrlCreateTabItem("禁止访问")
$check[0] = GUICtrlCreateCheckbox("A", 24, 40, 33, 17)
$check[1] = GUICtrlCreateCheckbox("B", 24, 64, 33, 17)
$check[2] = GUICtrlCreateCheckbox("C", 24, 88, 33, 17)
$check[3] = GUICtrlCreateCheckbox("D", 24, 112, 33, 17)
$check[4] = GUICtrlCreateCheckbox("E", 24, 136, 33, 17)
$check[5] = GUICtrlCreateCheckbox("F", 24, 160, 33, 17)
$check[6] = GUICtrlCreateCheckbox("G", 24, 184, 33, 17)
$check[7] = GUICtrlCreateCheckbox("H", 64, 40, 33, 17)
$check[8] = GUICtrlCreateCheckbox("I", 64, 64, 33, 17)
$check[9] = GUICtrlCreateCheckbox("J", 64, 88, 33, 17)
$check[10] = GUICtrlCreateCheckbox("K", 64, 112, 33, 17)
$check[11] = GUICtrlCreateCheckbox("L", 64, 136, 33, 17)
$check[12] = GUICtrlCreateCheckbox("M", 64, 160, 33, 17)
$check[13] = GUICtrlCreateCheckbox("N", 64, 184, 33, 17)
$check[14] = GUICtrlCreateCheckbox("O", 104, 40, 33, 17)
$check[15] = GUICtrlCreateCheckbox("P", 104, 64, 33, 17)
$check[16] = GUICtrlCreateCheckbox("Q", 104, 88, 33, 17)
$check[17] = GUICtrlCreateCheckbox("R", 104, 112, 33, 17)
$check[18] = GUICtrlCreateCheckbox("S", 104, 136, 33, 17)
$check[19] = GUICtrlCreateCheckbox("T", 104, 160, 33, 17)
$check[20] = GUICtrlCreateCheckbox("U", 144, 40, 33, 17)
$check[21] = GUICtrlCreateCheckbox("V", 144, 64, 33, 17)
$check[22] = GUICtrlCreateCheckbox("W", 144, 88, 33, 17)
$check[23] = GUICtrlCreateCheckbox("X", 144, 112, 33, 17)
$check[24] = GUICtrlCreateCheckbox("Y", 144, 136, 33, 17)
$check[25] = GUICtrlCreateCheckbox("Z", 144, 160, 33, 17)
$CPGLbel_4 = GUICtrlCreateLabel("全选", 104, 184, 28, 17)
GUICtrlSetCursor (-1, 0)
$CPGLbel_5 = GUICtrlCreateLabel("/", 136, 184, 9, 17)
$CPGLbel_6 = GUICtrlCreateLabel("取消", 144, 184, 28, 17)
GUICtrlSetCursor (-1, 0)
GUICtrlCreateTabItem("")
$CPGLBut_1 = GUICtrlCreateButton("确定", 8, 216, 75, 25)
$CPGLBut_2 = GUICtrlCreateButton("马上生效", 112, 216, 75, 25)
GUISetState(@SW_SHOW)


While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			GUIDelete($CPGL)
			ExitLoop
		Case $CPGLbel_1
			For $i = 0 To 25
				GUICtrlSetState($CPGLBOX[$i],$GUI_CHECKED)
			Next
		Case $CPGLbel_3
			For $i = 0 To 25
				GUICtrlSetState($CPGLBOX[$i],$GUI_UNCHECKED)
			Next
		Case $CPGLbel_4
			For $i = 0 To 25
				GUICtrlSetState($check[$i],$GUI_CHECKED)
			Next
		Case $CPGLbel_6
			For $i = 0 To 25
				GUICtrlSetState($check[$i],$GUI_UNCHECKED)
			Next
		Case $CPGLBut_1
			$go=0
			For $i = 0 To 25
				If GUICtrlRead($CPGLBOX[$i])= $GUI_CHECKED Then
					$fin=1*BitShift(1,$i*-1)
					$go+=$fin
				Else
					ContinueLoop
				EndIf
			Next
			RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer","NoDrives","REG_DWORD",$go)
			$x = 0
			For $y = 0 To 25
				If GUICtrlRead($check[$y])= $GUI_CHECKED Then
					$fin_1=1*BitShift(1,$y*-1)
					$x+=$fin_1
				Else
					ContinueLoop
				EndIf
			Next
			RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer","NoViewOnDrive","REG_DWORD",$x)
					
		Case $CPGLBut_2
			DllCall("user32.dll","int","SendMessageTimeout","hwnd",65535,"int",26,"int",0,"int",0,"int",0,"int",1000,"str","dwResult")
			_Update_Explorer()

	EndSwitch
WEnd
EndFunc
