﻿# Open

**xcall MIAMEX, MX\_REGISTRY, REGOP\_OPEN, hkey, subkey, rights, hkeynew, status**

This call is needed to open up a branch of the Registry and returns a handle which can be used in subsequent opcodes.

**Parameters**

_hkey_  (B,4)  \[in\]

can be a key returned in the _hkeynew_ parameter from a previous open, or more likely, one of the following symbols (from [ashell.def](ashell.md)) for the main hives in the Registry:

**Symbol**HKEY\_CLASSES\_ROOTHKEY\_CURRENT\_USERHKEY\_LOCAL\_MACHINEHKEY\_USERS



_subkey_  \[in\]

is a string combining one or more levels beneath the level referenced by the key _hkey_, for example:

SUBKEY = "SOFTWARE\\MicroSabio\\JBCT\\ATE"

Note that _subkey _is not case sensitive on lookup, but when creating keys, the case specified will be retained. (Same idea as with Windows filenames.)

_rights_  \[in\]

is a numeric variable combining one or more of the following bits relating to the kind of rights you want to request for this key:

| **Symbol** | **Value** | **Description** |
|------|------|------|
| RGKEY\_QUERY\_VALUE | \&h00000001 | Ability to query a value |
| RGKEY\_SET\_VALUE | \&h00000002 | Ability to change or set a value |
| RGKEY\_CREATE\_SUB\_KEY | \&h00000004 | Ability to create a new sub key |
| RGKEY\_ENUM\_SUB\_KEYS | \&h00000008 | Ability to enumerate sub keys |
| RGKEY\_WOW64\_32KEY | \&h00000200 | access key from 32 bit registry view |
| RGKEY\_WOW64\_64KEY | \&h00000100 | access key from 64 bit registry view |
| RGKEY\_DELETE | \&h00010000 | ability to delete key |
| **Definition file: [ashell.def](ashell.md)** | | 

[Hex-Decimal Values](hex-decimalvalues.md)



_hkeynew_  (B,4)  \[out\]

will return the handle to the opened key, and will be needed for subsequent operations. Note that in a non-Windows environment, since the operation will do nothing, it will not update the hkeynew parameter. You should therefore set it to zero initially, so that you can check to make sure that it comes back with a non-zero value.

_status_  (F6)  \[out\]

returns 0 for success, or else an error code. You can convert the error code to a message using: xcall MIAMEX, MX\_ERRNOMSG, status, msg. Note that status may not be set in the case of the non-Windows environment; see _hkeynew_ comments for error checking advice.















