Jump to content

SpRegistry: Difference between revisions

From EDM2
Created page with " * Mode 1: Setting single value. '''Syntax:''' result = spRegistry ( key , name , val , [ type ] ) • Mode 2: Setting default value of a certain key. Syntax: result = spRegi..."
 
No edit summary
Line 29: Line 29:
veriable.
veriable.
'''Returns:'''  
'''Returns:'''  
For successful setting invocations, result will equal ''. (1,2)
* For successful setting invocations, result will equal ''. (1,2)
For successful querying invocations, result will be given the value of the specified
* For successful querying invocations, result will be given the value of the specified registry value. (3,4,5)
registry value. (3,4,5)
* For successful deleting invocations, result will equal ''. (6,7,8)
For successful deleting invocations, result will equal ''. (6,7,8)
* For succesful enumerating operations, result will be number of items returned. (9,10)
For succesful enumerating operations, result will be number of items returned.
* Possible types returned by mode 5 are 'dword:' (2 byte values), 'hex:' (variable length binary data), '' (variable length strings).
(9,10)
 
Possible types returned by mode 5 are 'dword:' (2 byte values), 'hex:' (variable
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.
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:
Return Codes of common failure situations:
3 File Not Found (Key not found)
* 3 File Not Found (Key not found)
1010 Bad Key
* 1010 Bad Key


'''Remarks:''' When setting a value of a non existing key, the key will be created.
'''Remarks:''' When setting a value of a non existing key, the key will be created.
Line 132: Line 129:
RETURN
RETURN
</PRE>
</PRE>
[[Category:The OS/2 API Project]]

Revision as of 04:19, 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
OTHERWISE 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