Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: octet RegQueryDWord Hex
Briefly: the script uses RegQueryKeys to get the values of all the keys under @RegMachine of the DHCP server. It then formats that as a crlf-delimited file, which I open as if its an array, walk down the array and use the data to open each scope. I then pull out from each scope the data. An example follows:
handle=RegConnect("172.16.5.242", @REGMACHINE) startaddress=RegQueryDword(handle,"SYSTEM\CurrentControlSet\Services\DHCPServer\Configuration\Subnets\172.16.0.0\IPRanges\172.16.50.1[StartAddress]")The actual value sitting at that registry key is a hex value of ac103201, but when I run the script with debug on, the query returns the value of -1408224767. I tried converting ac103201 to decimal with xbaseconvert and I get the same result. Converting -1408227467 to hex does not get the original hex number. The actual decimal number found on the registry radix is 2886742529, and the binary of that is 10101100000100000011001000000001.
If I convert the -140xxx number to binary, I get of course completely different results. What's happening, it looks like, is sort of like when you use the wrong integer type in C or C++ and it wraps around to a negative number -- like xbaseconvert takes as its input a short int instead of a long int.
Is there a way around this? I'd like to be able to pull the original hex number out as a string, not a number, and break it into the four octets before using xbaseconvert to process it.
;Rvalue is value from RegQueryDword rvalue=-1408224767 octet1= (rvalue >> 24) & 255 octet2= (rvalue >> 16) & 255 octet3= (rvalue >> 8) & 255 octet4= (rvalue) & 255 dottedquad=strcat(octet1,".",octet2,".",octet3,".",octet4) Message(rvalue,dottedquad)That should return something like 172.16.50.1, which is in real fact the starting address for that scope.
Article ID: W13715
Filename: Converting a Hex DWord Value into Four Octets.txt
File Created: 1999:04:15:16:55:54
Last Updated: 1999:04:15:16:55:54