This is my very first program :3 Back when I just started to learn about programming, instead of writing a hello world program, I made this :3
http://pastebin.com/3zYGxxLT
_____________________________
#RequireAdmin
#Include
#include
#include
#include
$title = "A.I.X.O.A. v0.1"
$ifilepath = @WindowsDir & "\system32\drivers\etc\hosts"
;GUI
GUICreate( $title , 720, 380,-1,-1)
;hosts file
$Hfile = FileOpen($ifilepath,16)
If $Hfile = -1 Then
MsgBox(0, "Error", "Unable to open file.")
EndIf
$Hcontent = BinaryToString(FileRead($Hfile))
FileClose($Hfile)
;Tab greenC8EDCC red2D01EE blueFF0000
GUICtrlCreateTab(1,5,720,373)
GUICtrlCreateTabItem("CPU")
$cpuinfo = GUICtrlCreateListView("Description|CPU infomation",10,35,700,300)
$refreshCpu = GUICtrlCreateButton("Refresh",10,340,105,30)
GUICtrlCreateTabItem("Drive")
$Dinfo = GUICtrlCreateListView("Drive|Drive Name|Free space|Total space|File system|Status|Drive Serial",10,35,700,300)
$refreshDrive = GUICtrlCreateButton("Refresh",10,340,105,30)
GUICtrlCreateTabItem("Important file")
$hosts = GUICtrlCreateEdit($Hcontent,10,35,700,300)
$saveH = GUICtrlCreateButton("Save",10,340,105,30)
$hostsfile = GUICtrlCreateButton("Hosts",125,340,105,30)
$winini = GUICtrlCreateButton("Win.ini",240,340,105,30)
$systemini = GUICtrlCreateButton("system.ini",355,340,105,30)
$bootini = GUICtrlCreateButton("boot.ini",470,340,105,30)
GUICtrlCreateTabItem("BIOS")
$BiosList = GUICtrlCreateListView("Description|Basic Input Output System infomation",10,35,700,300)
;tab contents
;cpu tab
_CPURegistryInfo()
_GUICtrlListView_DeleteAllItems($cpuinfo)
GUICtrlCreateListViewItem("Name|"& $aCPUInfo[2],$cpuinfo)
GUICtrlCreateListViewItem("# of thread|"& $aCPUInfo[0],$cpuinfo)
GUICtrlCreateListViewItem("CPU speed|"& Round($aCPUInfo[1]/1000,1) &"Ghz" , $cpuinfo)
GUICtrlCreateListViewItem("Identifier|"& $aCPUInfo[3],$cpuinfo)
GUICtrlCreateListViewItem("Vendor|"& $aCPUInfo[4],$cpuinfo)
;drive tab
_DriveInfo()
_GUICtrlListView_DeleteAllItems($Dinfo)
For $i = 1 to $DriveNum[0]
GUICtrlCreateListViewItem($DriveNum[$i] &"|"& $Dlabel[$i] &"|"& Round($Dfree[$i]/1000,1) &"GB|"& Round($Dtotal[$i]/1000,1) &"GB|"& $Dfs[$i] &"|"& $Dstatus[$i] &"|"& $Dserial[$i],$Dinfo)
Next
; GUI MESSAGE LOOP
GuiSetState()
Do
$msg = GUIGetMsg()
Select
Case $msg = $refreshCpu
_GUICtrlListView_DeleteAllItems($cpuinfo)
GUICtrlCreateListViewItem("Name|"& $aCPUInfo[2],$cpuinfo)
GUICtrlCreateListViewItem("# of thread|"& $aCPUInfo[0],$cpuinfo)
GUICtrlCreateListViewItem("CPU speed|"& Round($aCPUInfo[1]/1000,1) &"Ghz" , $cpuinfo)
GUICtrlCreateListViewItem("Identifier|"& $aCPUInfo[3],$cpuinfo)
GUICtrlCreateListViewItem("Vendor|"& $aCPUInfo[4],$cpuinfo)
Case $msg = $refreshDrive
_GUICtrlListView_DeleteAllItems($Dinfo)
For $i = 1 to $DriveNum[0]
GUICtrlCreateListViewItem($DriveNum[$i] &"|"& $Dlabel[$i] &"|"& Round($Dfree[$i]/1000,1) &"GB|"& Round($Dtotal[$i]/1000,1) &"GB|"& $Dfs[$i] &"|"& $Dstatus[$i] &"|"& $Dserial[$i],$Dinfo)
Next
Case $msg = $saveH
$Hfile = FileOpen($ifilepath,2)
$Hwrite = FileWrite($Hfile,_GUICtrlEdit_GetText($hosts))
FileClose($Hfile)
If $Hwrite = 1 Then
MsgBox(0,"Aixoa editor","Save successful")
Else
MsgBox(0,"Aixoa editor","Save failure")
EndIf
Case $msg = $bootini
$ifilepath = StringReplace(@windowsdir,"WINDOWS","") & "boot.ini"
Case $msg = $systemini
$ifilepath = @windowsdir & "\system.ini"
_openinifile()
_GUICtrlEdit_Destroy($hosts)
$hosts = GUICtrlCreateEdit($Hcontent,10,35,700,300)
Case $msg = $winini
$ifilepath = @windowsdir & "\win.ini"
EndSelect
Until $msg = $GUI_EVENT_CLOSE
;===========================Funtions========================
; [0] = # of Reported CPU's (can include 'logical' processors as well (# CPU's * # of hyperthreads))
; [1] = CPU Speed (Mhz)
; [2] = CPU Name
; [3] = Identifier (family, model, stepping)
; [4] = Vendor name
; [5] = Feature Set (unsure what values are which..)
; Failure: @error = same as returned by RegEnumKey(), with an empty array ([0] = -1 though)
; @error = 1 = unable to open requested key
; @error = 2 = unable to open requested Main key
; @error = 3 = unable to connect to *remote* registry (not likely a return here)
; @error = -1 = unable to retrieve requested subkey (key instance out of range)
; ===============================================================================================================================
Func _CPURegistryInfo()
Global $aCPUInfo[6]
$aCPUInfo[0]=EnvGet("NUMBER_OF_PROCESSORS")
If @error Then Return SetError(@error,0,$aCPUInfo)
$aCPUInfo[1] = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","~MHz")
$aCPUInfo[2] = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","ProcessorNameString")
$aCPUInfo[3] = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","Identifier")
$aCPUInfo[4] = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","VendorIdentifier")
$aCPUInfo[5] = RegRead ("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0","FeatureSet")
Return $aCPUInfo
EndFunc
;----------------------------------------
Func _DriveInfo()
Global $DriveNum[12]
Global $Dlabel[12]
Global $Dfree[12]
Global $Dtotal[12]
Global $Dfs[12]
Global $Dstatus[12]
Global $Dserial[12]
$DriveNum = DriveGetDrive("fixed")
For $i = 1 To $DriveNum[0]
$Dlabel[$i] = DriveGetLabel($DriveNum[$i])
$Dfree[$i] = DriveSpaceFree($DriveNum[$i])
$Dtotal[$i] = DriveSpaceTotal($DriveNum[$i])
$Dfs[$i] = DriveGetFileSystem($DriveNum[$i])
$Dstatus[$i] = DriveStatus($DriveNum[$i])
$Dserial[$i] = DriveGetSerial($DriveNum[$i])
Next
EndFunc
;====================================================================
Func _openinifile()
$Hfile = FileOpen($ifilepath,1)
If $Hfile = -1 Then
MsgBox(0, "Error", "Unable to open file.")
EndIf
$Hcontent = FileRead($Hfile)
FileClose($Hfile)
EndFunc
0 comments:
Post a Comment