AZJIO Posted August 13, 2012 Share Posted August 13, 2012 (edited) Setting.7z_Setting.au3 (pastebin.com)Allows you to choose where to save the program settings in the registry or ini file_Setting_Read_Setting_Write_Setting_Delete_Setting_ReadSection_Setting_ReadSectionNames_Setting_WriteSection_Setting_RenameSection_Setting_MigrateIniToReg_Setting_MigrateRegToIniexpandcollapse popup#include <_Setting.au3> #include <Array.au3> $TrReg = 0 $sPath_ini = @ScriptDir&'MySoft.ini' $sKey = 'HKEY_CURRENT_USERSoftwareMySoft' Global $setting[4] If FileExists($sPath_ini) Then $TrReg = 0 _ReadSet($sPath_ini, $TrReg) Else If _Reg_Exists($sKey) Then $TrReg = 1 _ReadSet($sKey, $TrReg) Else If MsgBox(4, 'INI or Registry', 'Save in the INI?') = 6 Then $TrReg = 0 _DefWriteSet($sPath_ini, $TrReg) Else $TrReg = 1 _DefWriteSet($sKey, $TrReg) EndIf EndIf EndIf _ArrayDisplay($setting, 'Array') Func _ReadSet($sPath, $TrReg) $setting[0] = _Setting_Read($sPath, 'section1', 'key1', 'default1', $TrReg) $setting[1] = _Setting_Read($sPath, 'section1', 'key2', 'default2', $TrReg) $setting[2] = _Setting_Read($sPath, 'section2', 'key1', 'default3', $TrReg) $setting[3] = _Setting_Read($sPath, 'section2', 'key2', 'default4', $TrReg) EndFunc Func _DefWriteSet($sPath, $TrReg) _Setting_Write($sPath, 'section1', 'key1', '111', $TrReg) _Setting_Write($sPath, 'section1', 'key2', '22', $TrReg) _Setting_Write($sPath, 'section2', 'key1', '3333', $TrReg) _Setting_Write($sPath, 'section2', 'key2', '4', $TrReg) $setting[0] = '111' $setting[1] = '22' $setting[2] = '3333' $setting[3] = '4' EndFunc Func _Reg_Exists($key) Local $Err = RunWait('reg query "' & $key & '"', '', @SW_HIDE) If $Err = 0 Then Return 1 Else Return 0 EndIf EndFunc[/code] [code='autoit']#include <_Setting.au3> #include <Array.au3> $TrReg = 1 $sPath = 'HKEY_CURRENT_USERSoftwareAutoIt v3' $Array = _Setting_ReadSection($sPath, 'AU3Info', $TrReg) _ArrayDisplay($Array, 'ReadSection')[/code] [code='autoit']#include <_Setting.au3> #include <Array.au3> $TrReg = 1 $sPath = 'HKEY_CURRENT_USERSoftware7-Zip' $Array = _Setting_ReadSectionNames($sPath, $TrReg) _ArrayDisplay($Array, 'SectionNames')[/code] [code='autoit']#include <_Setting.au3> $sPath = @ScriptDir & 'MySoft.ini' $sKey = 'HKEY_CURRENT_USERSoftwareAutoIt v3' _Setting_MigrateRegToIni($sKey, $sPath) Edited February 14, 2013 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
AZJIO Posted September 4, 2012 Author Share Posted September 4, 2012 Update Added _Setting_WriteSection _Setting_RenameSection Taken into account behavior with quotes My other projects or all Link to comment Share on other sites More sharing options...
AZJIO Posted September 5, 2012 Author Share Posted September 5, 2012 Need advice:Want to make $ iReg = 0 first_Setting_ReadSection($sPath, $sSection, $iReg = 0) _Setting_ReadSection($iReg, $sPath, $sSection) My other projects or all Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now