Snippets ( Registry ): Difference between revisions
Jump to navigation
Jump to search
(Edited snippets to conform to template Snippet Header.) |
|||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
__TOC__ | __TOC__ | ||
===== | |||
[[category:Snippets]] | |||
{{Snippet Credit Header}} | |||
== _IsRegistryExist == | |||
{{Snippet Header | |||
| AuthorURL = 35302-guinness | |||
| AuthorName = guinness | |||
}} | |||
<syntaxhighlight lang="autoit"> | <syntaxhighlight lang="autoit"> | ||
Line 13: | Line 22: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===== | [[#top | ReturnToContents]] | ||
== _Reg_GetSID == | |||
{{Snippet Header | |||
| AuthorURL = 52-geosoft | |||
| AuthorName = GEOSoft | |||
}} | |||
<syntaxhighlight lang="autoit"> | <syntaxhighlight lang="autoit"> | ||
Line 35: | Line 51: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===== | [[#top | ReturnToContents]] | ||
== _RegReadEX == | |||
{{Snippet Header | |||
| AuthorURL = 35742-realm | |||
| AuthorName = Realm | |||
}} | |||
<syntaxhighlight lang="autoit"> | <syntaxhighlight lang="autoit"> | ||
Line 47: | Line 70: | ||
Return $var | Return $var | ||
EndFunc | EndFunc | ||
</syntaxhighlight> | |||
[[#top | ReturnToContents]] |
Latest revision as of 17:26, 18 November 2012
_IsRegistryExist
Author: guinness
ConsoleWrite(_IsRegistryExist("HKEY_CURRENT_USER\Control Panel\Desktop", "Test") & @LF) ; False = Doesn't Exist
ConsoleWrite(_IsRegistryExist("HKEY_CURRENT_USER\Control Panel\Desktop", "CaretWidth") & @LF) ; True = Exists
Func _IsRegistryExist($sKeyName, $sValueName)
RegRead($sKeyName, $sValueName)
Return @error = 0
EndFunc ;==>_IsRegistryExist
_Reg_GetSID
Author: GEOSoft
; Returns the SID for the current user.
$sUser = _Reg_GetSID()
If $sUser Then MsgBox(0, "RESULTS", $sUser)
Func _Reg_GetSID()
Local $sKey = "HKU\", $sEntry, $iReg = 1, $sRegEx = "(?i)s-1-5-21-([\d|-]*)"
While 1
$sEntry = RegEnumKey($sKey, $iReg)
If @Error Then ExitLoop
$iReg += 1
If NOT StringRegExp($sEntry, $sRegEx) Then ContinueLoop
Local $aRegExp = StringRegExp($sEntry, $sRegEx, 1)
Return $aRegExp[0]
Wend
Return False
EndFunc;<==> _Reg_GetSID()
_RegReadEX
Author: Realm
; Returns default error message and code if key is missing
ConsoleWrite( 'Program Files Directory= ' & _RegReadEX( 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion', 'ProgramFilesDir', '<Key is not present>') & @LF)
ConsoleWrite( 'Default Return= ' & _RegReadEX( 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion', 'A Missing Key Test', '<Key is not present>') & ' Error= ' & @error & @LF)
Func _RegReadEX($sKeyName, $sValueName, $sDefault)
Local $var = RegRead($sKeyName, $sValueName)
If @error Then Return SetError(@error,0,$sDefault)
Return $var
EndFunc