Writing .Reg Files
1.) Header line: this FIRST line is mandatory. MUST contain only these exact words (case sensitive = character capitalization required!):
- REGEDIT4 = for Windows 95/98/ME and NT 4.0 or
- Windows Registry Editor Version 5.00 = for Windows 2000/XP.
This is the only way Windows OS can recognize, validate and run a .REG file.
3.) Remarked (comment) line(s): optional. MUST begin with a semicolon (;) which may be followed by a space (optional). May be inserted anywhere in the .REG file, but NOT before the header, which MUST be present as FIRST line.
4.)(Sub)Key line: MUST be preceded and terminated by square parenthesis ([]). (Sub)Key name MUST start with the Hive Key name (left end) and MUST contain entire Subkey pathway leading to the current Subkey name (right end). Consecutive (Sub)Key names MUST be separated by SINGLE backslash marks (\).
(Sub)Key names not present in the Registry will be automatically created when the REG file is merged into the Registry. Exception: new Hive (Root) Keys can be created ONLY in Windows NT4/2000/XP, but NOT in Windows 95/98/ME.
5.) Value line: MUST contain these elements in this exact order:
- Value name: MUST be preceded and terminated by quotation marks ("").
- Equal mark (=): separates Value name from Value type.
- Value type: MUST be specified (Dword [REG_DWORD], Binary [REG_BINARY], etc) if Value type other than String [REG_SZ].
- Colon mark (:): MUST exist if Value type other than String.
- Value data: MUST be in the same format as defined by Value type: text/ASCII, Unicode/ANSI, (alpha)numeric (decimal, hexadecimal or binary) etc. MUST be preceded and terminated by quotation marks ("") ONLY IF Value type is String.
Value Data syntax
- String Value [REG_SZ] (API Code 1): "ValueName"="ValueData"
Value Data is expressed here in Unicode or ANSI formats: simple text/ASCII, expanded or extended.
- Dword Value [REG_DWORD] (API Code 4): "ValueName"=ValueType:ValueData
Value Data is expressed here in Double WORD (4 bytes = 32 bits) formats: decimal, hexadecimal or binary.
- Large Binary (hex) Value (any Binary Value API Code):
"ValueName"=ValueType(API Code):ValueData,ValueData,\
ValueData,ValueData
Large Values can span onto more than one line. Each line (except the last one) is terminated by a comma (,) followed by a SINGLE backslash mark (\). Consecutive lines are separated by carriage returns (CR).
- String Value [REG_SZ] (API Code 1): "ValueName"="ValueData"
6.) Empty (blank) line: this LAST line is mandatory for proper operation. Similar to inserting a carriage return (CR) at the end of file.
This is how a generic text/ASCII .REG file looks like:
-----Begin cut ∓ paste here-----
REGEDIT4
; Comment line:
[HKEY_KEY_NAME\SubkeyName1\SubKeyName2]
; String Value format:
"ValueName"="ValueData"
; Dword or Binary Value format:
"ValueName"=ValueType:ValueData
------End cut ∓ paste here------
Example of actual .REG file:
-----Begin cut ∓ paste here-----
REGEDIT4
; First Value below displays MS Windows version:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion]
; String Value format:
"Version"="Windows ME"
; Dword Value format:
"CacheWriteDelay"=dword:00000320
; Binary Value format:
"OldWinVer"=hex:00
------End cut ∓ paste here------
0 comments:
Post a Comment