BoogY Posted September 4, 2009 Posted September 4, 2009 Hi, I have this code : Func KeyExists() $clee1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control","Permission Required", "REG_DWORD","00000000") $clee2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control","Permission Required", "REG_DWORD","00000001") $reponse = False If ($clee1 = 1) Then $reponse = True Else $reponse = False EndIf Return $reponse EndFunc how can i check if the key exists ? and do an action if its true ? Thanks a lot
99ojo Posted September 4, 2009 Posted September 4, 2009 (edited) Hi, I have this code : Func KeyExists() $clee1 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control","Permission Required", "REG_DWORD","00000000") $clee2 = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control","Permission Required", "REG_DWORD","00000001") $reponse = False If ($clee1 = 1) Then $reponse = True Else $reponse = False EndIf Return $reponse EndFunc how can i check if the key exists ? and do an action if its true ? Thanks a lot Hi, you should have a better look at helpfile: If KeyExists () Then MsgBox (0,"","Key Set") ; or whatever you want Else MsgBox (0,"","Key not Set") ; or whatever you want EndIf Func KeyExists() If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control","Permission Required") <> "" Then $response = True Else $response = False EndIf Return $response EndFunc ;-)) Stefan P.S: Edit Or you want to check if the value of the key is set to 00000001 then: If KeyExists () Then MsgBox (0,"","Key Set to 0x00000001") ; or whatever you want Else MsgBox (0,"","Key not Set or 0x00000000") ; or whatever you want EndIf Func KeyExists() $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control","Permission Required") If $var = 1 Then ; key is there and set to 0x00000001 $response = True Else $response = False ; key is not set or 0x00000000 EndIf Return $response EndFunc Edited September 4, 2009 by 99ojo
Mat Posted September 4, 2009 Posted September 4, 2009 (edited) this is how I would do it. It means the key can exist and be blank, which is sometimes deliberate. Regread ( ... ) If @Error = 1 then ; key does not exist MsgBox (48, "Error", "key does not exist") EndIf However, I should point out that this test: If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control","Permission Required") <> "" Then $response = True Else $response = False EndIf Return $response could very easily be done: Return RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Client Components\Remote Control","Permission Required") <> "" as it treats it as a bool val. The easiest way to see this is by running this code: MsgBox (0, "", 1 <> 2) MDiesel Edited September 4, 2009 by mdiesel AutoIt Project Listing
BoogY Posted September 4, 2009 Author Posted September 4, 2009 Thanks a lot guys i'll give'it a try..
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