SpRegistry: Difference between revisions
No edit summary |
No edit summary |
||
| Line 34: | Line 34: | ||
* name – Name of the value to be set, queried, or deleted. | * name – Name of the value to be set, queried, or deleted. | ||
* val – Value to be set, queried, or deleted. | * val – Value to be set, queried, or deleted. | ||
* stem – The result of the enumerating operations will be set into this stem | * stem – The result of the enumerating operations will be set into this stem veriable. | ||
veriable. | |||
'''Returns:''' | '''Returns:''' | ||
| Line 57: | Line 56: | ||
/* Prints out a registry key with all values and subvalues, like the */ | /* Prints out a registry key with all values and subvalues, like the */ | ||
/* Registry Export function of Regedit */ | /* Registry Export function of Regedit */ | ||
PARSE ARG args | |||
IF RIGHT(args,1)='\' THEN args=LEFT(args,LENGTH(args)-1) | PARSE ARG args | ||
SAY 'REGEDIT4' | IF RIGHT(args,1)='\' THEN args=LEFT(args,LENGTH(args)-1) | ||
SAY '' | |||
CALL RegDump args | SAY 'REGEDIT4' | ||
RETURN | SAY '' | ||
RegDump: PROCEDURE | CALL RegDump args | ||
SAY '['||ARG(1)||']' | RETURN | ||
CALL KeyDump ARG(1) | |||
CALL spRegistry ARG(1),'SUBKEYS:','s' | RegDump: PROCEDURE | ||
DO i=1 TO s.0 | SAY '['||ARG(1)||']' | ||
CALL RegDump ARG(1)||'\'||s.i | |||
END | CALL KeyDump ARG(1) | ||
RETURN | |||
KeyDump: PROCEDURE | CALL spRegistry ARG(1),'SUBKEYS:','s' | ||
CALL spRegistry ARG(1),'VALUES:','v' | DO i=1 TO s.0 | ||
DO i=1 to v.0 | CALL RegDump ARG(1)||'\'||s.i | ||
CALL ValDump ARG(1), v.i | END | ||
END | RETURN | ||
CALL LINEOUT ,'' | |||
RETURN | KeyDump: PROCEDURE | ||
ValDump: PROCEDURE | CALL spRegistry ARG(1),'VALUES:','v' | ||
IF ARG(2)='' THEN DO | DO i=1 to v.0 | ||
val=spRegistry(ARG(1),'DEFAULT:') | CALL ValDump ARG(1), v.i | ||
type='' | END | ||
out='@=' | CALL LINEOUT ,'' | ||
END | RETURN | ||
ELSE DO | |||
val=spRegistry(ARG(1),ARG(2)) | ValDump: PROCEDURE | ||
type=spRegistry(ARG(1),'TYPE:',ARG(2)) | IF ARG(2)='' THEN DO | ||
out='"' | val=spRegistry(ARG(1),'DEFAULT:') | ||
DO i=1 TO LENGTH(ARG(2)) | type='' | ||
c=SUBSTR(ARG(2),i,1) | out='@=' | ||
IF c='\' | c='"' THEN out=out||'\' | END | ||
out=out||c | ELSE DO | ||
END | val=spRegistry(ARG(1),ARG(2)) | ||
out=out||'"='type | type=spRegistry(ARG(1),'TYPE:',ARG(2)) | ||
END | out='"' | ||
SELECT | DO i=1 TO LENGTH(ARG(2)) | ||
WHEN type='dword:' THEN CALL DWordDump val | c=SUBSTR(ARG(2),i,1) | ||
WHEN type='hex:' THEN CALL HexDump val | IF c='\' | c='"' THEN out=out||'\' | ||
WHEN type='' THEN CALL StringDump val | out=out||c | ||
END | |||
END | out=out||'"='type | ||
RETURN | END | ||
DWordDump: PROCEDURE EXPOSE out | SELECT | ||
DO i=1 TO LENGTH(out) | WHEN type='dword:' THEN CALL DWordDump val | ||
c=SUBSTR(out,i,1) | WHEN type='hex:' THEN CALL HexDump val | ||
CALL LINEOUT ,out||spD2X(ARG(1),'l') | WHEN type='' THEN CALL StringDump val | ||
RETURN | THERWISE EXIT 1 | ||
HexDump: PROCEDURE EXPOSE out | END | ||
DO i=1 TO LENGTH(ARG(1)) | RETURN | ||
IF i>1 & LENGTH(out)>3 THEN out=out||',' | |||
out=out||spD2X(C2D(SUBSTR(ARG(1),i,1)),'b') | DWordDump: PROCEDURE EXPOSE out | ||
IF LENGTH(out)>75 & i<=LENGTH(ARG(1)) THEN DO | DO i=1 TO LENGTH(out) | ||
CALL LINEOUT ,out||',\' | c=SUBSTR(out,i,1) | ||
out=' ' | CALL LINEOUT ,out||spD2X(ARG(1),'l') | ||
END | RETURN | ||
END | |||
IF out\='' THEN CALL LINEOUT ,out | HexDump: PROCEDURE EXPOSE out | ||
RETURN | DO i=1 TO LENGTH(ARG(1)) | ||
StringDump: PROCEDURE EXPOSE out | IF i>1 & LENGTH(out)>3 THEN out=out||',' | ||
CALL CHAROUT ,out||'"' | out=out||spD2X(C2D(SUBSTR(ARG(1),i,1)),'b') | ||
posx=LENGTH(out)+1 | |||
DO i=1 TO LENGTH(ARG(1)) | IF LENGTH(out)>75 & i<=LENGTH(ARG(1)) THEN DO | ||
IF i>1 & posx>76 & i<LENGTH(ARG(1)) THEN DO | CALL LINEOUT ,out||',\' | ||
CALL LINEOUT ,'"\' | out=' ' | ||
CALL CHAROUT ,'"' | END | ||
posx=1 | END | ||
END | IF out\='' THEN CALL LINEOUT ,out | ||
c=SUBSTR(ARG(1),i,1) | RETURN | ||
IF c='\' | c='"' THEN DO | |||
CALL CHAROUT ,'\' | StringDump: PROCEDURE EXPOSE out | ||
posx=posx+1 | CALL CHAROUT ,out||'"' | ||
END | posx=LENGTH(out)+1 | ||
CALL CHAROUT ,c | DO i=1 TO LENGTH(ARG(1)) | ||
posx=posx+1 | IF i>1 & posx>76 & i<LENGTH(ARG(1)) THEN DO | ||
END | CALL LINEOUT ,'"\' | ||
CALL LINEOUT ,'"' | CALL CHAROUT ,'"' | ||
RETURN | posx=1 | ||
END | |||
c=SUBSTR(ARG(1),i,1) | |||
IF c='\' | c='"' THEN DO | |||
CALL CHAROUT ,'\' | |||
posx=posx+1 | |||
END | |||
CALL CHAROUT ,c | |||
posx=posx+1 | |||
END | |||
CALL LINEOUT ,'"' | |||
RETURN | |||
[[Category:The OS/2 API Project]] | [[Category:The OS/2 API Project]] | ||
Revision as of 04:30, 6 April 2015
- Mode 1: Setting single value.
Syntax: result = spRegistry ( key , name , val , [ type ] )
- Mode 2: Setting default value of a certain key.
Syntax: result = spRegistry ( key , [ 'DEFAULT:' ] , val )
- Mode 3: Querying single value.
Syntax: result = spRegistry ( key , name )
- Mode 4: Query default value of a certain key.
Syntax: result = spRegistry ( key [ , [ 'DEFAULT:' ] ] )
- Mode 5: Query type of a single value.
Syntax: result = spRegistry ( key , [ 'TYPE:' ] , name )
- Mode 6: Deleting a single value.
Syntax: result = spRegistry ( key , name , 'DELETE:' )
- Mode 7: Deleting default value of a certain key.
Syntax: result = spRegistry ( key , [ 'DEFAULT:' ] , 'DELETE:' )
- Mode 8: Deleting an key and all associated subkeys and values.
Syntax: result = spRegistry ( key , 'DELETE:' )
- Mode 9: Querying names of all values associated with a certain key.
Syntax: result = spRegistry ( key , 'VALUES:' , 'stem' )
- Mode 10: Querying subkeys of a certain key.
Syntax: result = spRegistry ( key , 'SUBKEYS:' , 'stem' )
Parameters:
- key – Registry key.
- name – Name of the value to be set, queried, or deleted.
- val – Value to be set, queried, or deleted.
- stem – The result of the enumerating operations will be set into this stem veriable.
Returns:
- For successful setting invocations, result will equal . (1,2)
- For successful querying invocations, result will be given the value of the specified registry value. (3,4,5)
- For successful deleting invocations, result will equal . (6,7,8)
- For succesful enumerating operations, result will be number of items returned. (9,10)
- Possible types returned by mode 5 are 'dword:' (2 byte values), 'hex:' (variable length binary data), (variable length strings).
The error string 'ERROR:' may be returned if an error occurs. Additionally the Variable 'RC' will be set to the return code of the failing API Call.
Return Codes of common failure situations:
- 3 File Not Found (Key not found)
- 1010 Bad Key
Remarks: When setting a value of a non existing key, the key will be created.
Example Code:
/* regdump.cmd (spUtils Example Code) */
/* Prints out a registry key with all values and subvalues, like the */
/* Registry Export function of Regedit */
PARSE ARG args
IF RIGHT(args,1)='\' THEN args=LEFT(args,LENGTH(args)-1)
SAY 'REGEDIT4'
SAY
CALL RegDump args
RETURN
RegDump: PROCEDURE
SAY '['||ARG(1)||']'
CALL KeyDump ARG(1)
CALL spRegistry ARG(1),'SUBKEYS:','s'
DO i=1 TO s.0
CALL RegDump ARG(1)||'\'||s.i
END
RETURN
KeyDump: PROCEDURE
CALL spRegistry ARG(1),'VALUES:','v'
DO i=1 to v.0
CALL ValDump ARG(1), v.i
END
CALL LINEOUT ,
RETURN
ValDump: PROCEDURE
IF ARG(2)= THEN DO
val=spRegistry(ARG(1),'DEFAULT:')
type=
out='@='
END
ELSE DO
val=spRegistry(ARG(1),ARG(2))
type=spRegistry(ARG(1),'TYPE:',ARG(2))
out='"'
DO i=1 TO LENGTH(ARG(2))
c=SUBSTR(ARG(2),i,1)
IF c='\' | c='"' THEN out=out||'\'
out=out||c
END
out=out||'"='type
END
SELECT
WHEN type='dword:' THEN CALL DWordDump val
WHEN type='hex:' THEN CALL HexDump val
WHEN type= THEN CALL StringDump val
THERWISE EXIT 1
END
RETURN
DWordDump: PROCEDURE EXPOSE out
DO i=1 TO LENGTH(out)
c=SUBSTR(out,i,1)
CALL LINEOUT ,out||spD2X(ARG(1),'l')
RETURN
HexDump: PROCEDURE EXPOSE out
DO i=1 TO LENGTH(ARG(1))
IF i>1 & LENGTH(out)>3 THEN out=out||','
out=out||spD2X(C2D(SUBSTR(ARG(1),i,1)),'b')
IF LENGTH(out)>75 & i<=LENGTH(ARG(1)) THEN DO
CALL LINEOUT ,out||',\'
out=' '
END
END
IF out\= THEN CALL LINEOUT ,out
RETURN
StringDump: PROCEDURE EXPOSE out
CALL CHAROUT ,out||'"'
posx=LENGTH(out)+1
DO i=1 TO LENGTH(ARG(1))
IF i>1 & posx>76 & i<LENGTH(ARG(1)) THEN DO
CALL LINEOUT ,'"\'
CALL CHAROUT ,'"'
posx=1
END
c=SUBSTR(ARG(1),i,1)
IF c='\' | c='"' THEN DO
CALL CHAROUT ,'\'
posx=posx+1
END
CALL CHAROUT ,c
posx=posx+1
END
CALL LINEOUT ,'"'
RETURN