0

I am encountering an error code of value 87, which correlates to ERROR_INVALID_PARAMETER as per Winerror.h. The function call to the RegCreateKeyExA() function is as follows:

RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software/Test/RegistryTest", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &createdKey, &dispositionValueOfCreatedKey);

where,

createdKey is a variable of HKEY type declared as HKEY createdKey;

dispositionValueOfCreatedKey is a variable of DWORD type declared as DWORD dispositionValueOfCreatedKey;

At the moment, I have not tried and am unaware of any means to mitigate this error as, I believe, the above function call satisfies all the parameter requirements mentioned in this MSFT documentation of the function.

Thanks in advance.

hecate
  • 620
  • 1
  • 8
  • 33
  • 3
    The component separator is a backslash (`\ `), not a forward slash (`/`). – IInspectable Feb 07 '20 at 21:08
  • 1
    As @IInspectable points out,you need a backslash separator, which you have to specify using a **double** backslash to avoid 'escaping' the next character. – Adrian Mole Feb 07 '20 at 21:12
  • @IInspectable whoops! silly me! Guess I really need some time off! – hecate Feb 07 '20 at 21:14
  • @AdrianMole "*... which you have to specify using a **double** backslash to avoid 'escaping' the next character...*" - unless you use a [raw string literal](https://stackoverflow.com/questions/56710024/), then no double-up escaping is necessary, eg: `RegCreateKeyExA(..., R("Software\Basil\RegistryTest"), ...);` – Remy Lebeau Feb 08 '20 at 03:49
  • @hecate You can post an answer and accept it for clear and helpful for other people are searching on this issue, instead of adding solution in question. – Rita Han Feb 10 '20 at 01:06

1 Answers1

0

The components of the registry path must be separated by a backslash (\), which must be escaped to avoid escaping the next corresponding character if the path string is not specified as a raw string literal as R("dir_1\dir_2\dir_3") (exclusive to MSFT compilers) or R"dir_1\dir_2\dir_3".

hecate
  • 620
  • 1
  • 8
  • 33