REGEDIT(1,2,3,4)
PURPOSE
This function will allow you to edit registry or INI file entries.
PARTS
1 sac | Required - What to do: |
regOpen - Open a registry entry/INI file for editing. This must be done before items can be read from or written to.
regReadInt - Read an integer value (B, I or R) from a registry item/INI file.
regReadStr - Read a string value (A) from a registry item/INI file.
regReadBool - Read a boolean value (L) from a registry item/INI file.
regWriteInt - Write an integer value (B, I or R) to a registry item/INI file.
regWriteStr - Write a string value (A) to a registry item/INI file.
regWriteBool - Write a boolean value (L) to a registry item/INI file.
regDelete - Delete a section from the registry/INI file.
regClose - Close a registry entry/INI file previously opened with regOpen.
2 f/c/e | This part depends on the option specified in part 1. |
regOpen - Required -
Registry: This is the 'path' you wish to open. All registry entries accessed using this function will be in 'HKEY_CURRENT_USER." Typically, you would use "SOFTWARE\"+any sub path you wish. For example, we use "SOFTWARE\Tas Professional.\TAS Pro\" etc. In this part you must specify the entire path name up to, but not including, the section name. The section name and actual variable name are specified in part 2 and 3 during the appropriate action.
INI File: This must be the entire file name, including any path. The extension of INI is automatically appended to the file name.
regReadInt, regReadStr, regReadBool, regWriteInt, regWriteStr, regWriteBool - Required - For these options you would specify the section name here. NOTE: You must have opened the registry entry/INI file first before you can read from or write to the entry.
reDelete - Required - This is the name of the section you wish to delete. NOTE: Be careful about using this option. It will delete the entire section for this entry and once deleted, it cannot be recovered.
3 f/c/e | regReadInt, regReadStr, regReadBool, regWriteInt, regWriteStr, regWriteBool - Required - For these options you would specify the variable name here. NOTE: You must have opened the registry entry/INI file first before you can read from or write to the entry. |
regOpen - If you are opening a registry entry then set this value to rtRegistry. If this is an INI file then set this to rtFile. The default value is rtRegistry.
4 f/c/e | regWriteInt, regWriteStr, regWriteBool - Required - For these options you would specify the value you wish to save to the registry here. NOTE: You must have opened the registry entry/INI file first before you can write to the entry. |
RETURN TYPE - Varies
The return value depends on the option set in part 1.
regReadInt - R - Returns the integer value from the registry/INI file item.
regReadStr - A - Returns the string value from the registry/INI file item.
regReadBool - L - Returns the boolean value from the registry/INI file item.
All other options return L. If the option completes properly the function will return .T., if not, it will return .F.
COMMENTS
NOTE: If you are not familiar with the registry (or INI files) in Windows you should not be using this function.
NOTE: The special alpha constants above (regOpen through regClose, rtRegistry and rtFile) are defined in COMPILERCONSTANTS.TXT.
NOTE: You may have only one registry or INI file open at a time.
Sample Code
This is an example of writing to an INI
define reg.cc.printer,reg.cc.ini type a size 80 // this is the path were they can find the xcharge.ini file and Printer
define reg.cc.copies type i size 2
define reg.cc.print,reg.cc.ask type l
define reg.cc.delay type i
define dummy_l type l
//Made 2 commands to show how to use regedit()
cmd read_ccreg
//open reg file
msg get_ini_path()
dummy_l = regedit(regOpen,get_ini_path()+'taspro',rtFile)
if dummy_l = .t.
reg.cc.ini = regedit(regReadstr,'X-charge','TRANSACTIONDIR')
reg.cc.printer = regedit(regReadstr,'X-charge','printername')
reg.cc.copies = regedit(regReadint,'X-charge','numcopies')
reg.cc.print = regedit(regReadBool,'X-charge','printrecipt')
reg.cc.ask = regedit(regReadBool,'X-charge','askprint')
reg.cc.delay = regedit(regReadint,'X-charge','delay')
//set defaults
if reg.cc.copies = 0 then reg.cc.copies = 1
if reg.cc.printer = '' then reg.cc.printer = printer_name()
if reg.cc.delay = 0 then reg.cc.delay = 3
else
msg 'Could not open TASPRO.INI for printer information..'
endif
ret
cmd writeccreg
dummy_l = regedit(regwritestr,'X-charge','TRANSACTIONDIR',reg.cc.ini)
dummy_l = regedit(regwritestr,'X-charge','printername',reg.cc.printer)
dummy_l = regedit(regwritestr,'X-charge','printername',reg.cc.printer)
dummy_l = regedit(regwriteint,'X-charge','numcopies',reg.cc.copies)
dummy_l = regedit(regwriteBool,'X-charge','printrecipt',reg.cc.print)
dummy_l = regedit(regwriteBool,'X-charge','askprint',reg.cc.ask)
dummy_l = regedit(regwriteint,'X-charge','delay',reg.cc.delay)
dummy_l = regedit(close)
ret
Page url: http://www.cassoftware.com/tas/manual/editregistry().htm