#72041 - 2002-12-05 07:09 PM
Re: re: Sreg() - Searches registry for specified value and/or valuename
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
emmm - heres the link to the UDF:
Sreg() - Searches registry for specified value and/or valuename
All I know is my buddy runs up to me with this urgent requirement to scour the registry for a particular data value actually - not a key or value - that can appear in numerous places under a certain tree node.
Not too certain on all the details but it has something to do with a "random" print driver being installed by some product - and must be deleted to get things working again ... apparently this is a stop-gap fix until MS comes back with a reponse or fix. Not only does the registry need cleaning, but the disk file has to be purged as well. This is on a server (I think)
-Shawn
|
|
Top
|
|
|
|
#72053 - 2003-01-06 07:47 PM
Re: re: Sreg() - Searches registry for specified value and/or valuename
|
ShaneEP
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
Hello everybody...
I am trying to implement your Sreg function to search the HKEY_CURRENT_USER\Printers\Connections keys for any printers on a particular server. Here is the code I am trying...I dont get anything back when I run it but I know that there are keys in the tree that have the servername in the value. Im sure that its just my Kix ignorance thats the problem...Any assistance would be greatly appreciated.
code:
break on
$index=Sreg("HKEY_CURRENT_USER\Printers\Connections","servername",1) if @error "error occured: @serror" ? else for each $value in $index ? $value next endif exit 0
Function Sreg($_Subkey, $_String, $_Integer) if not keyexist("$_Subkey") exit 1010 endif if not len($_String) exit 24 endif if $_Integer<0 or $_Integer>2 exit 50 endif $_I="" $_Chr=chr(29) $=execute('sk("$_Subkey","$_String",$_Integer)') $_C=0 $_Is ="" for each $_F in split($_I,$_Chr) if len($_F) $_C=$_C+1 endif next $_C=$_C-1 $=execute('global $$_IA[$_C]') $_C=0 for each $_F in split($_I,$_Chr) if len($_F) $=execute('$$_IA[$_C]="$_F"') $_C=$_C+1 endif next $Sreg=$_IA $_I="" $_IA="" EndFunction Function sk($_key, $_St, $_In) $_vC=0 $_Vn=enumvalue($_key,$_vC) while len($_Vn) if $_In=0 if instr($_Vn,$_St) $_I=$_I+$_key+",$_Vn"+$_Chr endif else if instr(readvalue($_key,$_Vn),$_St) $_I=$_I+$_key+",$_Vn"+$_Chr else if $_In=2 and instr($_Vn,$_St) $_I=$_I+$_key+",$_Vn"+$_Chr endif endif endif $_vC=$_vC+1 $_Vn=enumvalue($_key,$_vC) loop $_C=0 $_ID="" $_Un=enumkey($_key,$_C) while len($_Un) $_ID=$_ID+"$_key\$_Un," $_C=$_C+1 $_Un=enumkey($_key,$_C) loop for each $_uk in split($_ID,",") if len($_uk) $=execute('sk("$_uk","$_St",$_In)') endif next EndFunction
[ 06. January 2003, 19:48: Message edited by: Shane Ptomey ]
|
|
Top
|
|
|
|
#72056 - 2003-01-06 08:33 PM
Re: re: Sreg() - Searches registry for specified value and/or valuename
|
ShaneEP
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
Got it work using the EnumKey with the following code...Thanks for all the great functions guys!
code:
break on $oldserver = "ServerName"
$array=arrayenumkey(HKEY_CURRENT_USER\Printers\Connections) for $counter=0 to ubound($array) $key = $array[$counter] IF INSTR ("$key", "$oldserver") DELKEY ("HKEY_CURRENT_USER\Printers\Connections\$key") ? 'Deleting $key' ENDIF next
get $ exit 0
function arrayenumkey($regsubkey) dim $retcode, $subkeycounter, $currentsubkey, $subkeyarray
if not keyexist($regsubkey) $arrayenumkey='' return endif
$subkeycounter=0 do $currentsubkey=enumkey($regsubkey,$subkeycounter) if $currentsubkey<>259 and @ERROR=0 redim preserve $subkeyarray[$subkeycounter] $subkeyarray[$subkeycounter]=$currentsubkey $subkeycounter=$subkeycounter+1 endif until $currentsubkey=259 or @ERROR
$arrayenumkey=$subkeyarray endfunction
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 781 anonymous users online.
|
|
|