| |
NOTE - Use your Browsers BACK Button to return to prior page or
CLICK here.
INI-Func - Read/Write INI File
& Windows Registry Access |
|
I created this set of functions to read/write INI files and extract
INI key values... In addition I added the ability to retrieve windows registry values
(using an executable called TDREG.EXE found on this page)... a simple function call
initiates the process... |
There are several functions available...
(See program documentation for Input/Output Parameter requirements)
| INI-Func-New - Initialize INI Array |
| INI-Func-Imp - Import INI File (into Array) |
| INI-Func-Exp - Export INI File (from Array) |
| INI-Func-Idx - Retrieve Entry (Sequentially) |
| INI-Func-Get - Retrieve Entry (Section/Key) |
| INI-Func-Put - Place Entry into Array |
| INI-Func-Reg - Call TDREG.EXE (Registry Lookup) |
| TDREG.EXE - WinBatch Registry Access Program |
| TDREG_PS.SQC - PSoft Registry / TDREG.EXE Support
* Include tdreg_ps.sqc in begin-setup section of program *
|
You can find the INI-Func Set in my custom SQR library TDFUNC.SQC
MORE STUFF...
Download TDREG_PS.SQC Here
Download the TDREG.EXE program (and
TDREG.WBT source code) (ZIPPED)
TDREG_PS.SQC - PS Registry /
TDREG.EXE Support Variables |
!**********************************************************************
!* *
!* MODULE: TDREG_PS.SQC *
!* AUTHOR: TONY DELIA. *
!* DATE: 03/10/2000. *
!* SYSTEM: TD SQR UTILITY SERIES. *
!* DESC: TDREG.EXE ACCESS SUPPORT MODULE. *
!* INCLUDES: TDREG Input/Output INI Designations. *
!* PeopleSoft Configuration Manager Key Entries. *
!* *
!**********************************************************************
!* *
!* NOTE: The Registry Key components are designed for use *
!* with the INI/Registry Functions found in the *
!* TDFUNC.SQC Custom SQR Function Library. *
!* *
!* Place TDREG_PS.SQC in the begin-setup section. *
!* *
!**********************************************************************
!* *
!* LEGAL: CONFIDENTIALITY INFORMATION. *
!* *
!* This module is the original work of Tony DeLia. It *
!* can be considered ShareWare under the following *
!* conditions. *
!* *
!* A - The author's name (Tony DeLia) remains on any *
!* and all versions of this module. *
!* B - Any modifications must be clearly identified. *
!* C - A "vanilla" copy of this module must be kept *
!* alongside any revised versions. *
!* *
!**********************************************************************
!* *
!* WEBSITE: http://www.sqrtools.com *
!* *
!* Questions/Comments: tdelia@erols.com *
!* *
!**********************************************************************
! TDREG.EXE INI Settings
#define TDREG_I 'c:\windows\tdreg_i.ini'
#define TDREG_O 'c:\windows\tdreg_o.ini'
! Windows Registry Key Nodes
#define REG_current '[HKEY_CURRENT_USER]'
#define REG_local '[HKEY_LOCAL_MACHINE]'
#define REG_classes '[HKEY_CLASSES_ROOT]'
#define REG_users '[HKEY_USERS]'
! Configuration Manager Registry Key Node
#define CFG_key {REG_current}
! Configuration Manager Version Sub-Keys
#define CFG_sub60 'Software\PeopleSoft\PeopleTools\Release6\'
#define CFG_sub75 'Software\PeopleSoft\PeopleTools\Release7.5\'
! Configuration Manager Category Nodes
#define CFG_designer 'Application Designer'
#define CFG_cache 'Cache Settings'
#define CFG_crystal 'Crystal'
#define CFG_datamover 'Data Mover'
#define CFG_database 'Database Options'
#define CFG_image 'IMAGE'
#define CFG_mailserver 'MailServer'
#define CFG_nvision 'nVision'
#define CFG_psbooks 'PeopleBooks'
#define CFG_prcs 'Process Scheduler'
#define CFG_pscfg 'PSCFG'
#define CFG_psforms 'PSFORMS'
#define CFG_pside 'PSIDE'
#define CFG_psped 'PSPED'
#define CFG_psted 'PSTED'
#define CFG_pstools 'PSTOOLS'
#define CFG_query 'Query'
#define CFG_rdm 'RDM Build Settings'
#define CFG_remotecall 'RemoteCall'
#define CFG_setup 'Setup'
#define CFG_startup 'Startup'
#define CFG_trace 'Trace'
! Configuration Manager 7.5 Combinations (for INI/Reg Functions)
#define CFG75_prcs {CFG_sub75} || {CFG_prcs} || ','
#define CFG75_trace {CFG_sub75} || {CFG_trace} || ','
#define CFG75_designer {CFG_sub75} || {CFG_designer} || ','
#define CFG75_cache {CFG_sub75} || {CFG_cache} || ','
#define CFG75_crystal {CFG_sub75} || {CFG_crystal} || ','
#define CFG75_datamover {CFG_sub75} || {CFG_datamover} || ','
#define CFG75_database {CFG_sub75} || {CFG_database} || ','
#define CFG75_image {CFG_sub75} || {CFG_image} || ','
#define CFG75_mailserver {CFG_sub75} || {CFG_mailserver} || ','
#define CFG75_nvision {CFG_sub75} || {CFG_nvision} || ','
#define CFG75_psbooks {CFG_sub75} || {CFG_psbooks} || ','
#define CFG75_prcs {CFG_sub75} || {CFG_prcs} || ','
#define CFG75_pscfg {CFG_sub75} || {CFG_pscfg} || ','
#define CFG75_psforms {CFG_sub75} || {CFG_psforms} || ','
#define CFG75_pside {CFG_sub75} || {CFG_pside} || ','
#define CFG75_psped {CFG_sub75} || {CFG_psped} || ','
#define CFG75_psted {CFG_sub75} || {CFG_psted} || ','
#define CFG75_pstools {CFG_sub75} || {CFG_pstools} || ','
#define CFG75_query {CFG_sub75} || {CFG_query} || ','
#define CFG75_rdm {CFG_sub75} || {CFG_rdm} || ','
#define CFG75_remotecall {CFG_sub75} || {CFG_remotecall} || ','
#define CFG75_setup {CFG_sub75} || {CFG_setup} || ','
#define CFG75_startup {CFG_sub75} || {CFG_startup} || ','
#define CFG75_trace {CFG_sub75} || {CFG_trace} || ','
!**********************************************************************
!* End of Program *
!**********************************************************************
|
Sample Program (Using All INI
Functions) |
! NOTE - All extraneous coding removed (such as standard includes, etc)
!**********************************************************************
!* Setup Procedure *
!**********************************************************************
begin-setup
#include 'tdreg_ps.sqc' ! PS Configuration Manager Registry Keys
#define INI_Reg_Path c:\@td\@wbt\ ! Override tdreg.exe directory
end-setup
!**********************************************************************
!* Mainline Processing *
!**********************************************************************
begin-report
do Create-INI ! Create TDREG_I.INI (Registry Keys)
do INI-Func-Reg(#E_stat) ! Execute TDREG.EXE
if #E_stat = 0
do Process-INI ! Read TDREG_O.INI (Registry Values)
else
display 'Unsuccessful TDREG.EXE'
end-if
end-report
!**********************************************************************
!* Create INI Template for WinBatch (tdreg_i.ini) *
!**********************************************************************
begin-procedure Create-INI
do INI-Func-New()
! PeopleSoft INI Entries
let $sec = {CFG_key}
let $key = 'C1'
let $val = {CFG75_startup} || 'DBName'
do INI-Func-Put(0, $sec, $key, $val)
let $key = 'C2'
let $val = {CFG75_startup} || 'DBType'
do INI-Func-Put(1, $sec, $key, $val)
let $key = 'C3'
let $val = {CFG75_trace} || 'TracePC'
do INI-Func-Put(2, $sec, $key, $val)
let $key = 'C4'
let $val = {CFG75_trace} || 'TraceSql'
do INI-Func-Put(3, $sec, $key, $val)
let $key = 'C5'
let $val = {CFG75_prcs} || 'PSSQR1'
do INI-Func-Put(4, $sec, $key, $val)
let $key = 'C6'
let $val = {CFG75_prcs} || 'PSSQR2'
do INI-Func-Put(5, $sec, $key, $val)
let $key = 'C7'
let $val = {CFG75_prcs} || 'PSSQRFLAGS'
do INI-Func-Put(6, $sec, $key, $val)
! Non-PeopleSoft Registry Lookup...
let $sec = {REG_local}
let $key = 'L1'
let $val = 'SOFTWARE\Microsoft\Windows\CurrentVersion,ProductName'
do INI-Func-Put(7, $sec, $key, $val)
let $key = 'L2'
let $val = 'SOFTWARE\Microsoft\Windows\CurrentVersion,Version'
do INI-Func-Put(8, $sec, $key, $val)
let $key = 'L3'
let $val = 'SOFTWARE\Microsoft\Windows\CurrentVersion,RegisteredOwner'
do INI-Func-Put(9, $sec, $key, $val)
! Write INI File (Export)
let #I_no = 1
let $I_file = {TDREG_I}
do INI-Func-Exp($I_file, #I_no, 'Y', #O_ctr)
end-procedure
!**********************************************************************
!* Process INI (tdreg_o.ini) *
!**********************************************************************
begin-procedure Process-INI
if #E_stat = 0
let #I_no = 2
let $I_file = {TDREG_O}
do INI-Func-New()
do INI-Func-Imp($I_file, #I_no, 'Y', #O_ctr)
! Retrieve INI Values (using sequential index)
let #ctr = 0
while #ctr < #O_ctr
do INI-Func-Idx(#ctr, $sec, $key, $val)
show #ctr ' => ' $sec ' => ' $key ' => ' $val
let #ctr = #ctr + 1
end-while
end-if
end-procedure
!**********************************************************************
!* Include Members: *
!**********************************************************************
#Include 'tdfunc.sqc' !Custom SQR Function Library
<snip>
!**********************************************************************
!* End of Program *
!**********************************************************************
|
Sample Output - From SQR.LOG |
**********************************************
INI-Func-Exp (Export INI File)
**********************************************
Filename: c:\windows\tdreg_i.ini
**********************************************
[HKEY_CURRENT_USER]
C1=Software\PeopleSoft\PeopleTools\Release7.5\Startup,DBName
C2=Software\PeopleSoft\PeopleTools\Release7.5\Startup,DBType
C3=Software\PeopleSoft\PeopleTools\Release7.5\Trace,TracePC
C4=Software\PeopleSoft\PeopleTools\Release7.5\Trace,TraceSql
C5=Software\PeopleSoft\PeopleTools\Release7.5\Process Scheduler,PSSQR1
C6=Software\PeopleSoft\PeopleTools\Release7.5\Process Scheduler,PSSQR2
C7=Software\PeopleSoft\PeopleTools\Release7.5\Process Scheduler,PSSQRFLAGS
[HKEY_LOCAL_MACHINE]
L1=SOFTWARE\Microsoft\Windows\CurrentVersion,ProductName
L2=SOFTWARE\Microsoft\Windows\CurrentVersion,Version
L3=SOFTWARE\Microsoft\Windows\CurrentVersion,RegisteredOwner
**********************************************
Count: 10
**********************************************
**********************************************
INI-Func-Reg (Execute TDREG.EXE)
**********************************************
Module: c:\@td\@wbt\tdreg.exe
Status: 0.000000
**********************************************
**********************************************
INI-Func-Imp (Import INI File)
**********************************************
Filename: c:\windows\tdreg_o.ini
**********************************************
[HKEY_CURRENT_USER]
C1=HRDMO
C2=SQLBASE
C3=0
C4=0
C5=c:\sqr
C6=c:\HRMS75SU\user\sqr
C7=-ic:\sqr\;c:\HRMS75SU\sqr\;c:\sqr\ -mc:\HRMS75SU\sqr\allmaxes.max <snip>
[HKEY_LOCAL_MACHINE]
L1=Microsoft Windows 95
L2=Windows 95
L3=Tanya & Tony DeLia
[END_OF_DATA]
TDREG_DONE=YES
**********************************************
Count: 11
**********************************************
0.000000 => [HKEY_CURRENT_USER] => C1 => HRDMO
1.000000 => [HKEY_CURRENT_USER] => C2 => SQLBASE
2.000000 => [HKEY_CURRENT_USER] => C3 => 0
3.000000 => [HKEY_CURRENT_USER] => C4 => 0
4.000000 => [HKEY_CURRENT_USER] => C5 => c:/sqr
5.000000 => [HKEY_CURRENT_USER] => C6 => c:\HRMS75SU\user\sqr
6.000000 => [HKEY_CURRENT_USER] => C7 => -ic:\sqr\;c:\HRMS75SU\sqr\;c:\sqr\ <snip>
7.000000 => [HKEY_LOCAL_MACHINE] => L1 => Microsoft Windows 95
8.000000 => [HKEY_LOCAL_MACHINE] => L2 => Windows 95
9.000000 => [HKEY_LOCAL_MACHINE] => L3 => Tanya & Tony DeLia
10.000000 => [END_OF_DATA] => TDREG_DONE => YES
|
In the SQR.LOG above there are several sections printed:
1 - Optional Printing of REG-Func-Exp Entries (in Red)
2 - Status of TDREG.EXE using CALL SYSTEM (in Green)
3 - Optional Printing of REG-Func-Imp Entries (in Blue)
4 - The SHOW statements in our example (in Black)
Notice the Windows Registry Values have been successfully
returned!
|
Time Out! Let's take a break...
Here's another picture of mine... |
|
We've gone over a lot of information so far... and produced successful
results in our sample... take a quick look at my lobster (click to enlarge)... then we'll
proceed with the INI-Func source as well as the TDREG WinBatch source code... Now
that's something new... |
INI-Func Set - Source Code |
!**********************************************************************
!* Build INI Array *
!**********************************************************************
!* *
!* See INI-Func-New for INI Cleanup. *
!* See INI-Func-Imp for INI Import Parameters (READ). *
!* See INI-Func-Exp for INI Export Parameters (WRITE). *
!* See INI-Func-Idx for INI Index Retrieval. *
!* See INI-Func-Get for INI Key Retrieval. *
!* See INI-Func-Put for INI Key Placement (for Export). *
!* *
!**********************************************************************
!* *
!* EXAMPLE: #define INIsize 50 ! Override Array Size *
!* ... *
!* do INI-Func-Imp($I_file, #I_no, $I_print, #O_ctr) *
!* ... *
!* do INI-Func-Get('[TDREG]', 'TDREG_PARM', $O_value) *
!* do INI-Func-Idx(#idx, $O_sec, $O_key, $O_value) *
!* ... *
!* do INI-Func-New() *
!* do INI-Func-Put(#idx, $I_sec, $I_key, $I_value) *
!* ... *
!* do INI-Func-Exp($I_file, #I_no, $I_print, #O_ctr) *
!* ... *
!* *
!**********************************************************************
!* *
!* SAMPLE: Here's a sample INI File (TDREG_O.INI): *
!* *
!* [TDREG] *
!* TDREG_PARM=IKEY *
!* *
!* [HKEY_CURRENT_USER] *
!* DBName=FCVD *
!* DBType=ORACLE *
!* TracePC=0 *
!* TraceSql=0 *
!* PSSQR1=c:\sqr *
!* PSSQR2=g:\psoft\dev\fs750\sqr *
!* PSSQR3= *
!* PSSQR4= *
!* PSSQRFLAGS=-ic:\sqr\;g:\psoft\dev\fs750\sqr\ <snip> *
!* *
!* <etc> *
!* *
!**********************************************************************
!* *
!* EXAMPLE: Using Sample INI File Above: *
!* *
!* let #I_no = 1 *
!* let $I_file = 'c:\windows\tdreg_o.ini' *
!* *
!* ! Import INI File *
!* do INI-Func-Imp($I_file, #I_no, 'Y', #O_ctr) *
!* *
!* ! Specify INI Section Names *
!* let $sec_1 = '[TDREG]' *
!* let $sec_2 = '[HKEY_CURRENT_USER]' *
!* *
!* ! Retrieve Key Value *
!* do INI-Func-Get($sec_1,'TDREG_PARM', $O_parm) *
!* do INI-Func-Get($sec_2,'DBName', $O_dbname) *
!* do INI-Func-Get($sec_2,'DBType', $O_dbtype) *
!* do INI-Func-Get($sec_2,'PSSQR1', $O_pssqr1) *
!* do INI-Func-Get($sec_2,'PSSQR2', $O_pssqr2) *
!* *
!* RESULTS: $O_parm => 'IKEY' *
!* $O_dbname => 'FCVD' *
!* $O_dbtype => 'ORACLE' *
!* $O_pssqr1 => 'c:\sqr' *
!* $O_pssqr2 => 'g:\psoft\dev\fs750\sqr' *
!* *
!**********************************************************************
!**********************************************************************
!* INI-Array *
!**********************************************************************
#ifndef INI_Func_Remove
#ifndef INIsize
#define INIsize 100 ! Default INImtx Size
#endif
begin-procedure INI-Array
create-array name=INImtx size={INIsize} field=INIsec:char -
field=INIkey:char -
field=INIval:char
let #INImax = {INIsize} - 1
let #INIctr = 0
end-procedure
!**********************************************************************
!* INI-Func-New (Clear INImtx and reset #INIctr) *
!**********************************************************************
!* *
!* INPUT: n/a - No input parameters *
!* OUTPUT: n/a - No output parameters *
!* *
!* To de-activate this function: *
!* #define INI_Func_Remove *
!* *
!**********************************************************************
!* *
!* EXAMPLE: See INI-Array procedure for examples. *
!* *
!**********************************************************************
begin-procedure INI-Func-New()
clear-array name=INImtx
let #_INIctr = 0
end-procedure
!**********************************************************************
!* INI-Func-Imp (Read INI File) *
!**********************************************************************
!* *
!* INPUT: $I_file - Input INI Path/Filename *
!* #I_no - File Handle *
!* $I_print - Print INI Entries on log (Y/N) *
!* OUTPUT: #O_ctr - Number of INI Entries *
!* *
!* To de-activate this function: *
!* #define INI_Func_Remove *
!* *
!**********************************************************************
!* *
!* EXAMPLE: See INI-Array procedure for examples. *
!* *
!**********************************************************************
begin-procedure INI-Func-Imp($I_file, #I_no, $I_print, :#O_ctr)
uppercase $I_print
let #O_ctr = 0
if #_INImax = 0
do INI-Array
end-if
do INI-Func-New()
let $sec = ''
let $key = ''
let $val = ''
open $I_file as #I_no for-reading record=500:vary status=#I_stat
if #I_stat = 0
if $I_print = 'Y'
display ' '
display '**********************************************'
display 'INI-Func-Imp (Import INI File)'
display '**********************************************'
display 'Filename: ' noline
display $I_file
display '**********************************************'
display ' '
end-if
while 1 = 1
read #I_no into $rec:500
if #_end-file = 1
break
end-if
let $rec = rtrim($rec,' ')
! Ignore Comments
if substr($rec, 1, 1) <> ';'
! Section
if substr($rec, 1, 1) = '['
let $sec = $rec
let $key = ''
let $val = ''
if $I_print = 'Y'
display $rec
end-if
else
! Ignore Key/Data if NO Section
if $sec <> ''
! Key/Data
let #len = length($rec)
let #pos = instr($rec, '=', 1)
if #pos > 1
let $key = substr($rec, 1, #pos - 1)
let $val = substr($rec, #pos + 1, #len - #pos)
let INImtx.INIsec(#O_ctr) = $sec
let INImtx.INIkey(#O_ctr) = $key
let INImtx.INIval(#O_ctr) = $val
if $I_print = 'Y'
display $rec
end-if
let #O_ctr = #O_ctr + 1
end-if
end-if
end-if
end-if
end-while
close #I_no
else
display ' '
display '**********************************************'
display 'INI-Func-Imp (Import File Error)'
display '**********************************************'
display 'Filename: ' noline
display $I_file
display '**********************************************'
display ' '
end-if
! Save INI value count
let #_INIctr = #O_ctr
if $I_print = 'Y'
display ' '
display '**********************************************'
display ' Count: ' noline
display #O_ctr 999999
display '**********************************************'
display ' '
end-if
end-procedure
!**********************************************************************
!* INI-Func-Exp (Write INI File) *
!**********************************************************************
!* *
!* INPUT: $I_file - Output INI Path/Filename *
!* #I_no - File Handle *
!* $I_print - Print INI Entries on log (Y/N) *
!* OUTPUT: #O_ctr - Number of INI Entries *
!* *
!* To de-activate this function: *
!* #define INI_Func_Remove *
!* *
!**********************************************************************
!* *
!* EXAMPLE: See INI-Array procedure for examples. *
!* *
!**********************************************************************
begin-procedure INI-Func-Exp($I_file, #I_no, $I_print, :#O_ctr)
uppercase $I_print
let #O_ctr = #_INIctr
if #O_ctr > 0
let $prev = '$'
let $sec = ''
let $key = ''
let $val = ''
open $I_file as #I_no for-writing record=500:vary status=#I_stat
if #I_stat = 0
if $I_print = 'Y'
display ' '
display '**********************************************'
display 'INI-Func-Exp (Export INI File)'
display '**********************************************'
display 'Filename: ' noline
display $I_file
display '**********************************************'
display ' '
end-if
let #ctr = 0
while #ctr < #O_ctr
let $sec = INImtx.INIsec (#ctr)
let $key = INImtx.INIkey (#ctr)
let $val = INImtx.INIval (#ctr)
! Section Heading Entry
if $prev <> $sec
let $prev = $sec
let $rec = $sec
if substr($rec,1,1) <> '['
let $rec = '[' || $rec || ']'
end-if
write #I_no from $rec:500
if $I_print = 'Y'
display $rec
end-if
end-if
! Key/Data Entries
let $rec = $key
if $val <> ''
let $rec = $rec || '=' || $val
end-if
write #I_no from $rec:500
if $I_print = 'Y'
display $rec
end-if
let #ctr = #ctr + 1
end-while
close #I_no
else
display ' '
display '**********************************************'
display 'INI-Func-Exp (Export File Error)'
display '**********************************************'
display 'Filename: ' noline
display $I_file
display '**********************************************'
display ' '
end-if
else
display ' '
display '**********************************************'
display 'INI-Func-Exp (No INI Entries)'
display '**********************************************'
display ' '
end-if
if $I_print = 'Y'
display ' '
display '**********************************************'
display ' Count: ' noline
display #O_ctr 999999
display '**********************************************'
display ' '
end-if
end-procedure
!**********************************************************************
!* INI-Func-Put *
!**********************************************************************
!* *
!* INPUT: #I_idx - Sequential Index *
!* $I_sec - INI Section Name *
!* $I_key - INI Key Name *
!* $I_val - INI Data Value *
!* OUTPUT: n/a - No output parameters *
!* *
!* To de-activate this function: *
!* #define INI_Func_Remove *
!* *
!**********************************************************************
!* *
!* EXAMPLE: See INI-Array procedure for examples. *
!* *
!**********************************************************************
begin-procedure INI-Func-Put(#I_idx, $I_sec, $I_key, $I_val)
let INImtx.INIsec(#I_idx) = $I_sec
let INImtx.INIkey(#I_idx) = $I_key
let INImtx.INIval(#I_idx) = $I_val
if #_INIctr <= #I_idx
let #_INIctr = #I_idx + 1
end-if
end-procedure
!**********************************************************************
!* INI-Func-Idx *
!**********************************************************************
!* *
!* INPUT: #I_idx - Sequential Index *
!* OUTPUT: $O_sec - INI Section Name *
!* $O_key - INI Key Name *
!* $O_val - INI Data Value *
!* *
!* To de-activate this function: *
!* #define INI_Func_Remove *
!* *
!**********************************************************************
!* *
!* EXAMPLE: See INI-Array procedure for examples. *
!* *
!**********************************************************************
begin-procedure INI-Func-Idx(#I_idx, :$O_sec, :$O_key, :$O_val)
let $O_sec = INImtx.INIsec(#I_idx)
let $O_key = INImtx.INIkey(#I_idx)
let $O_val = INImtx.INIval(#I_idx)
end-procedure
!**********************************************************************
!* INI-Func-Get *
!**********************************************************************
!* *
!* INPUT: $O_sec - INI Section Name *
!* $O_key - INI Key Name *
!* OUTPUTL $O_val - INI Data Value *
!* *
!* To de-activate this function: *
!* #define INI_Func_Remove *
!* *
!**********************************************************************
!* *
!* EXAMPLE: See INI-Array procedure for examples. *
!* *
!**********************************************************************
begin-procedure INI-Func-Get($I_sec, $I_key, :$O_val)
let $O_val = ''
let #idx = 0
while #idx < #_INIctr
let $sec = INImtx.INIsec (#idx)
let $key = INImtx.INIkey (#idx)
if $I_sec = $sec
and $I_key = $key
let $O_val = INImtx.INIval(#idx)
break
end-if
let #idx = #idx + 1
end-while
end-procedure
!**********************************************************************
!* INI-Func-Reg (Access Windows Registry via WinBatch) *
!**********************************************************************
!* *
!* INPUT: n/a - No Input Parameters *
!* OUTPUT: #O_stat - TDREG.EXE Status *
!* *
!* To override the tdreg.exe directory *
!* #define INI_Reg_Path g:\psoft\dev\fs750\sqr\ *
!* *
!* To de-activate this function: *
!* #define INI_Func_Remove *
!* *
!**********************************************************************
!* *
!* EXAMPLE: See INI-Array procedure for examples. *
!* *
!**********************************************************************
begin-procedure INI-Func-Reg(:#O_stat)
#ifndef INI_Reg_path
#define INI_Reg_Path c:\windows\
#endif
call system using '{INI_Reg_Path}tdreg.exe' #O_stat WAIT
display '**********************************************'
display 'INI-Func-Reg (Execute TDREG.EXE)'
display '**********************************************'
display ' Module: ' noline
display '{INI_Reg_Path}tdreg.exe'
display ' Status: ' noline
display #O_stat
display '**********************************************'
display ' '
end-procedure
#endif
|
TDREG.WBT Source Code - WinBatch
(then compiled as TDREG.EXE) |
;**********************************************************************
;* *
;* MODULE: TDREG.WBT *
;* AUTHOR: TONY DELIA. *
;* DATE: 03/08/2000. *
;* DESC: DELIVER REGISTRATION KEY VALUES. *
;* *
;**********************************************************************
tdreg_i = "TDREG_I.INI"
tdreg_o = "TDREG_O.INI"
tdreg_x = "TDREG_X.INI"
tdreg_p = "IKEY"
if DirChange("c:\windows") == @TRUE
FileDelete(tdreg_o)
FileDelete(tdreg_x)
if FileExist(tdreg_i) == @TRUE
gosub BuildSectionList
if seclist <> "(NONE)"
sections = ItemCount(seclist, @TAB)
sec = 1
while sec <= sections
section = ItemExtract(sec, seclist, @TAB)
GoSub ProcessSection
sec = sec + 1
end while
gosub WrapUp
endif
endif
endif
Exit
;**********************************************************************
;* PROCESS SECTION *
;**********************************************************************
:ProcessSection
ErrorMode(@OFF)
keywords = IniItemizePvt(section, tdreg_i)
if keywords <> "(NONE)"
items = ItemCount(keywords, @TAB)
ctr = 1
while ctr <= items
Rvalue = ""
Ikey = ItemExtract(ctr, keywords, @TAB)
Ival = IniReadPvt(section, "%Ikey%", "", tdreg_i)
len = StrLen(Ival)
pos = StrScan(Ival, ",", 1, @FWDSCAN)
if pos > 0
Rpath = StrSub(Ival, 1, pos - 1)
Ritem = StrSub(Ival, pos + 1, len - pos)
if section <> "TDREG"
if section == "HKEY_CURRENT_USER"
Rkey = RegOpenKey(@REGCURRENT, Rpath)
Rerr = LastError()
else
if section == "HKEY_LOCAL_MACHINE"
Rkey = RegOpenKey(@REGMACHINE, Rpath)
Rerr = LastError()
else
if section == "HKEY_CLASSES_ROOT"
Rkey = RegOpenKey(@REGCLASSES, Rpath)
Rerr = LastError()
else
if section == "HKEY_USERS"
Rkey = RegOpenKey(@REGUSERS, Rpath)
Rerr = LastError()
else
Rkey = ""
Rerr = -1
endif
endif
endif
endif
if Rerr == 0
Rvalue = RegQueryValue(Rkey, "[%Ritem%]")
RegCloseKey(Rkey)
endif
endif
Okey = StrCat(Rpath, "\\", Ritem)
if tdreg_p == "OKEY"
IniWritePvt(section,Okey,Rvalue,tdreg_o)
else
IniWritePvt(section,Ikey,Rvalue,tdreg_o)
endif
else
; TDREG INI Parameter - specify Output INI Key
if Ikey == "TDREG_PARM"
if Ival == "OKEY"
tdreg_p = Ival
endif
IniWritePvt(section,Ikey,Ival,tdreg_o)
endif
endif
ctr = ctr + 1
end while
endif
ErrorMode(@CANCEL)
Return
;**********************************************************************
;* BUILD SECTION LIST *
;**********************************************************************
:BuildSectionList
ErrorMode(@OFF)
seclist = ""
tab = ""
ifl = FileOpen(tdreg_i, "READ")
if ifl <> 0
while @TRUE
rec = FileRead(ifl)
if rec == "*EOF*"
break
endif
if StrSub(rec,1,1) == "["
pos = StrScan(rec, "]", 1, @FWDSCAN)
if pos <> 0
section = StrSub(rec, 2, pos - 2)
seclist = StrCat(seclist, tab, section)
tab = @TAB
endif
endif
endwhile
FileClose(ifl)
endif
if seclist == ""
seclist = "(NONE)"
endif
ErrorMode(@CANCEL)
Return
;**********************************************************************
;* WRAPUP - Create Final INI Entries *
;**********************************************************************
:WrapUp
ErrorMode(@OFF)
section = "END_OF_DATA"
Ikey = "TDREG_DONE"
Ival = "YES"
IniWritePvt(section,Ikey,Ival,tdreg_o)
section = "TD_REG_INFO"
last_run = TimeDate( )
IniWritePvt(section,"AUTHOR", "Tony DeLia", tdreg_x)
IniWritePvt(section,"DATE", "03/09/2000", tdreg_x)
IniWritePvt(section,"SITE", "http://www.sqrtools.com", tdreg_x)
IniWritePvt(section,"EMAIL", "tdelia@erols.com", tdreg_x)
IniWritePvt(section,"LANG", "WinBatch", tdreg_x)
IniWritePvt(section,"LAST_RUN", last_run, tdreg_x)
ErrorMode(@CANCEL)
Return
;**********************************************************************
;* END OF PROGRAM *
;**********************************************************************
|
For information on WinBatch visit http://www.windowware.com
|
I would appreciate any feedback you may have on this site.
Send mail to tdelia@erols.com or click on the
Octopus. |
|
Please report any technical difficulties you may encounter to the address
above OR click on the Octopus. Thanks. |
NOTE - Use your Browsers BACK Button to return to prior page.
Tony DeLia - Updated March 10, 2000
|