Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for readreg.rex

(view source code of readreg.rex as plain text)

  1. /* Check and parse command line arguments */
  2. Parse Arg section key
  3. If key = "" Then Call Syntax
  4. Parse Value section With hive"\"tree
  5. If Pos( "HKEY_", Translate( hive ) ) <> 1 Then Call Syntax
  6.  
  7. /* Initialize W32Funcs */
  8. Call RxFuncAdd "w32loadfuncs", "W32Util", "w32loadfuncs"
  9. Call w32loadfuncs
  10.  
  11. /* Read default printer and port from registry */
  12. handle = w32RegOpenKey( hive, tree )
  13. regval = w32RegQueryValue( handle, key )
  14. Call w32RegCloseKey handle
  15.  
  16. /* Display the result */
  17. Say
  18. Say "["||section||"]"
  19. Say key||"="||regval
  20.  
  21. /* Normal program termination */
  22. Exit 0
  23.  
  24.  
  25. Syntax:
  26. 	Say
  27. 	Say "ReadREG.rex,  Version 1.00"
  28. 	Say "Read a value from the registry"
  29. 	Say
  30. 	Say 'Usage:  <REXX>  READREG.REX  "section"  "key"'
  31. 	Say
  32. 	say 'Where:  "<REXX>"  is your Rexx interpreter:'
  33. 	say "                  - Windows: REGINA.EXE or REXX.EXE, whichever you installed"
  34. 	say "                  - OS/2:    no need to specify, just rename script to *.cmd"
  35. 	Say '        "section" is the registry section name, without brackets'
  36. 	Say '        "key"     is the key whose value must be read'
  37. 	Say
  38. 	Say "Arguments should be enclosed in double quotes if they contain spaces"
  39. 	Say
  40. 	Say "Example: read the user part of the PATH environment variable:"
  41. 	Say 'READREG.REX  "HKEY_CURRENT_USER\Environment" "Path"'
  42. 	Say
  43. 	Say "Written by Rob van der Woude"
  44. 	Say "http://www.robvanderwoude.com"
  45. 	Exit 1
  46. Return
  47.  

page last uploaded: 2017-04-06, 13:33