Tigerweld Posted December 28, 2007 Share Posted December 28, 2007 Trying to read a DWord value, but cannot seem to get it right. Can someone tell me what I'm doing wrong? I want to test a value. If the value is 1, then change it to a 2. Should I use Dword, string, or binary value? $var = RegRead("HKLM\SOFTWARE\ALTIRIS\FLAGCHECK" , "FLAG") if $var = "1" Then MsgBox(4096, "Value" , "Value is:" & $var) EndIf Link to comment Share on other sites More sharing options...
MadBoy Posted December 28, 2007 Share Posted December 28, 2007 Trying to read a DWord value, but cannot seem to get it right. Can someone tell me what I'm doing wrong? I want to test a value. If the value is 1, then change it to a 2. Should I use Dword, string, or binary value?$var = RegRead("HKLM\SOFTWARE\ALTIRIS\FLAGCHECK" , "FLAG") if $var = "1" Then MsgBox(4096, "Value" , "Value is:" & $var) EndIfWell what's wrong with it? $var = RegRead("HKLM\SOFTWARE\ALTIRIS\FLAGCHECK" , "FLAG")If @error Then MsgBox(0, "Test - Error", @error)ElseMsgBox(0, "Test", $var)EndIfWhat's the result of that? My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
JustinReno Posted December 28, 2007 Share Posted December 28, 2007 You misread his question. Link to comment Share on other sites More sharing options...
MadBoy Posted December 28, 2007 Share Posted December 28, 2007 You misread his question.Err, correct well here it goes:$var = RegRead("HKLM\SOFTWARE\ALTIRIS\FLAGCHECK" , "FLAG") if $var = "1" Then RegWrite ("HKLM\SOFTWARE\ALTIRIS\FLAGCHECK","FLAG", "REG_DWORD", "2") EndIf My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
Tigerweld Posted December 28, 2007 Author Share Posted December 28, 2007 Well what's wrong with it? $var = RegRead("HKLM\SOFTWARE\ALTIRIS\FLAGCHECK" , "FLAG")If @error Then MsgBox(0, "Test - Error", @error)ElseMsgBox(0, "Test", $var)EndIfWhat's the result of that?No matter the value, I get the msgbox. What type of reg value should I use to test for numbers? Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 29, 2007 Share Posted December 29, 2007 You don't specify the type on a RegRead() only on RegWrite, and the returned value will depend on the type read. You get an integer back for REG_DWORD, and a string back for everything else. For example: $sRegKey = "HKCU\SOFTWARE\AutoIt v3\Temp" _RegTypeTest("REG_BINARY", Binary("0xFEDCBA9876543210")) _RegTypeTest("REG_SZ", "This is my string.") _RegTypeTest("REG_MULTI_SZ", "String line one." & @LF & "String line two." & @LF & "String line three.") _RegTypeTest("REG_EXPAND_SZ", "%TEMP%\AutoIt3") _RegTypeTest("REG_DWORD", 1234567890) Func _RegTypeTest($sType, $varData) RegWrite($sRegKey, "Test_" & $sType, $sType, $varData) ConsoleWrite("Debug: Wrote Test_" & $sType & " = " & $sType & " = " & $varData & @LF) $RegData = RegRead($sRegKey, "Test_" & $sType) $iType = @extended ConsoleWrite("Debug: Read Test_" & $sType & " = " & $iType & " = " & VarGetType($RegData) & " = " & $RegData & @LF & @LF) EndFunc ;==>_RegTypeTest Note I passed a binary in to a REG_BINARY but got a string back. And the REG_EXPAND_SZ did not expand the environment variable. You can cause it to expand with Opt("ExpandEnvStrings", 1), but that is global and not specific to this REG data type. So REG_EXPAND_SZ seems to mean nothing but REG_SZ, at least as implemented in AutoIt. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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