#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <GuiImageList.au3>
#include <GuiButton.au3>
#Region ### START Koda GUI section ### Form=
Global Const $SHERB_NOCONFIRMATION = 0x01
Global Const $SHERB_NOPROGRESSUI = 0x02
Global Const $SHERB_NOSOUND = 0x04
Global Const $SHERB_NO_UI = BitOR($SHERB_NOCONFIRMATION, $SHERB_NOPROGRESSUI, $SHERB_NOSOUND)
Global Const $FOF_NOCONFIRMATION = 0x0010
Global Const $FOF_NOCONFIRMMKDIR = 0x0200
Global Const $FOF_NOERRORUI = 0x0400
Global Const $FOF_SILENT = 0x0004
Global Const $FOF_NO_UI = BitOR($FOF_NOCONFIRMATION, $FOF_NOCONFIRMMKDIR, $FOF_NOERRORUI, $FOF_SILENT)
Global Const $SHGFI_ICON = 0x00000100
Global Const $SHGFI_SMALLICON = 0x00000001
Global Const $SHGFI_USEFILEATTRIBUTES = 0x00000010
Global Const $tagNOTIFYICONDATA = 'dword Size;hwnd hWnd;uint ID;uint Flags;uint CallbackMessage;ptr hIcon;wchar Tip[128];dword State;dword StateMask;wchar Info[256];uint Version;wchar InfoTitle[64];dword InfoFlags'
Global Const $tagSHFILEINFO = 'ptr hIcon;int iIcon;dword Attributes;wchar DisplayName[260];wchar TypeName[80]'
$Form1 = GUICreate("Form1", 623, 360, 209, 152)
;------------------------------------------------------------------
$Group1 = GUICtrlCreateGroup("", 4, -5, 245, 73);在GUI上创建一个分组(Group)控件
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group1 = GUICtrlCreateGroup("", 250, -5, 245, 73)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;------------------------------------------------------------------
;------------------------------------------------------------------
$menu_A = GUICtrlCreateMenu("菜单1[&O]");创建一个菜单控件
$menu_A1 = GUICtrlCreateMenuItem("关于[&S]", $menu_A)
$menu_B = GUICtrlCreateMenu("菜单2[&T]");创建一个菜单控件
$menu_B1 = GUICtrlCreateMenuItem("Exit[&Esc]", $menu_B)
;-------------------------------------------------------------------
Local $button1
$button1 = GUICtrlCreateButton("刷新", 10, 6, 50, 55, $BS_FLAT);在GUI上创建一个按钮控件
$hImage1 = _GUIImageList_Create(30, 30, 5, 1, 0);创建图像列表控件
_GUIImageList_AddIcon($hImage1, "c:\windows\regedit.exe", 0, True);向图像列表添加图标
_GUICtrlButton_SetImageList($button1, $hImage1, 2);分配一个图像列表到按钮控件 2为图像顶端对齐.
$Button2 = GUICtrlCreateButton("删除", 70, 6, 50, 55, $BS_FLAT)
$hImage2 = _GUIImageList_Create(30, 30, 5, 1, 0)
_GUIImageList_AddIcon($hImage2, "shell32.dll", 131, True)
_GUICtrlButton_SetImageList($Button2, $hImage2, 2)
$Button3 = GUICtrlCreateButton("关于", 130, 6, 50, 55, $BS_FLAT)
$hImage3 = _GUIImageList_Create(30, 30, 5, 1, 0)
_GUIImageList_AddIcon($hImage3, "shell32.dll", 221, True)
_GUICtrlButton_SetImageList($Button3, $hImage3, 2)
$Button4 = GUICtrlCreateButton("退出", 190, 6, 50, 55, $BS_FLAT)
$hImage4 = _GUIImageList_Create(30, 30, 5, 1, 0)
_GUIImageList_AddIcon($hImage4, "shell32.dll", 219, True)
_GUICtrlButton_SetImageList($Button4, $hImage4, 2)
;-------------------------------------------------------------------
$TreeView1 = GUICtrlCreateTreeView(8, 72, 169, 265, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE);在GUI上创建一个 TreeView 控件
$everyone = GUICtrlCreateTreeViewItem("所有启动项", $TreeView1);在$TreeView1中创建一个新的 TreeView 控件项目
$userrun = GUICtrlCreateTreeViewItem("HKEY_CURRENT_USER", $everyone);在$everyone中创建一个新的 TreeView 控件项目
$run1 = GUICtrlCreateTreeViewItem("Run", $userrun)
$runone = GUICtrlCreateTreeViewItem("RunOne", $userrun)
$machinerun = GUICtrlCreateTreeViewItem("HKEY_LOCAL_MACHINE", $everyone)
$run2 = GUICtrlCreateTreeViewItem("Run", $machinerun)
$runone1 = GUICtrlCreateTreeViewItem("RunOne", $machinerun)
$RunOnceEx = GUICtrlCreateTreeViewItem("RunOnceEx", $machinerun)
$RunServices = GUICtrlCreateTreeViewItem("RunServices", $machinerun)
$RunServicesEX = GUICtrlCreateTreeViewItem("RunServicesEX", $machinerun)
GUICtrlSetState($everyone, $GUI_EXPAND);展开$everyone控件
GUICtrlSetState($userrun, $GUI_EXPAND)
GUICtrlSetState($machinerun, $GUI_EXPAND)
GUICtrlSetImage($TreeView1, "regedit.exe", 0);设置指定控件的位图或图标
;-------------------------------------------------------------------------------------
$ListView1 = GUICtrlCreateListView("名称 |路径|信息 ", 184, 72, 433, 265, -1);创建一个$ListView1控件
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES));修改$ListView1信息 添加网格 添加check选择控件
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 250);设置“路径”显示长度
GUICtrlSetImage($ListView1, "shell32.dll", -3);设置指定控件的位图或图标
$hImageList = _GUIImageList_Create(16, 16, 6)
_GUICtrlListView_SetImageList($ListView1, $hImageList, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $everyone
RDreg("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run")
Case $userrun
RDreg("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run")
Case $run1
RDreg("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run")
Case $runone
RDreg("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce")
Case $machinerun
RDreg("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
Case $run2
RDreg("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
Case $runone1
RDreg("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce")
Case $RunOnceEx
RDreg("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx")
Case $RunServices
RDreg("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices")
Case $RunServicesEX
RDreg("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServicesEX")
Case $button1
Case $Button2
Case $Button3
MsgBox(64, '关于', "BY 内蒙赤峰DJ", 5)
Case $Button4
Exit
EndSwitch
WEnd
Func RDreg($run)
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1));删除$ListView1控件中所有信息
Dim $x = 1, $tSHFILEINFO
$i = 1
While 1
$var = RegEnumVal($run, $i)
If @error <> 0 Then ExitLoop
$var2 = RegRead($run, $var)
$p = StringRegExpReplace($var2, '.*"([^"]+)".*', '\1')
If @extended = 0 Then
$p = StringRegExpReplace($var2, '(.+?)\s+\w:.+$', '\1')
If @extended = 0 Then $p = $var2
EndIf
$tSHFILEINFO = _WinAPI_ShellGetFileInfo($p, BitOR($SHGFI_ICON, $SHGFI_SMALLICON, $SHGFI_USEFILEATTRIBUTES))
$hIcon = DllStructGetData($tSHFILEINFO, 'hIcon')
_GUIImageList_ReplaceIcon($hImageList, -1, $hIcon)
_GUICtrlListView_AddItem($ListView1, $var, $x - 1)
_GUICtrlListView_AddSubItem($ListView1, $x - 1, $var2, 1)
If $run = 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run' Then _GUICtrlListView_AddSubItem($ListView1, $x - 1, 'RegUserRun', 2)
If $run = 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce' Then _GUICtrlListView_AddSubItem($ListView1, $x - 1, 'RegUserRunOne', 2)
If $run = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' Then _GUICtrlListView_AddSubItem($ListView1, $x - 1, 'RegMachineRun', 2)
If $run = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce' Then _GUICtrlListView_AddSubItem($ListView1, $x - 1, 'RegMachineRunOne', 2)
If $run = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx' Then _GUICtrlListView_AddSubItem($ListView1, $x - 1, 'RegMachineRunOnceEx', 2)
If $run = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices' Then _GUICtrlListView_AddSubItem($ListView1, $x - 1, 'RegMachineRunServices', 2)
If $run = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServicesEX' Then _GUICtrlListView_AddSubItem($ListView1, $x - 1, 'RegMachineRunServicesEX', 2)
_WinAPI_FreeIcon($hIcon)
$x += 1
$i += 1
WEnd
EndFunc ;==>RDreg
Func _WinAPI_FreeIcon($hIcon)
Local $Ret = DllCall('user32.dll', 'int', 'DestroyIcon', 'ptr', $hIcon)
If (@error) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0)
Return 1
EndFunc ;==>_WinAPI_FreeIcon
Func _WinAPI_ShellGetFileInfo($sPath, $iFlags, $iAttributes = 0x80)
Local $tSHFILEINFO = DllStructCreate($tagSHFILEINFO)
Local $Ret = DllCall('shell32.dll', 'ptr', 'SHGetFileInfoW', 'wstr', $sPath, 'dword', $iAttributes, 'ptr', DllStructGetPtr($tSHFILEINFO), 'int', DllStructGetSize($tSHFILEINFO), 'int', $iFlags)
If @error Then Return SetError(1, 0, 0)
Return SetError(0, $Ret[0], $tSHFILEINFO)
EndFunc ;==>_WinAPI_ShellGetFileInfo
Func del()
EndFunc ;==>del