RegOpenKeyEx error code?

S

sydneygirl

Help - I'm modifying a macro library, so that the macros will run with Office XP. This includes a number of API function calls, which are reading Registry values, eg to pick up the location of the User Templates.

In the function call RegOpenKeyEx(), I've changed the subkey value so that it points to the new Registry location ("software\microsoft\office\10.0\common\general\usertemplates"), but I get a return code (error) of 2. I have checked the registry and the key is definitely there.

Does anyone know what return code 2 is?
 
A

Andrew Cushen

Hi-

I found the following re.: RegOpenKeyEx in the platform
SDK docs:

<<
If the function succeeds, the return value is
ERROR_SUCCESS.

If the function fails, the return value is a nonzero error
code defined in Winerror.h. You can use the FormatMessage
function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a
generic description of the error.
What this says to me is that any value other than O is an
error, and that you need to call the API function
FormatMessage with the return value of RegOpenKeyEx to get
the actual error. I did check WINERROR.H and found no
error defined as 2.
One thought: do you have permission to read that Registry
key? Try running the code logged on as Administrator and
see if that works. If so, you've run into a permissions
problem.

Why don't you post your code that calls the API function?
We might be better able to help then.

Also, from what you say, it doesn't look like you passed
HKEY_CURRENT_USER to the function to start it in the
correct branch of the Registry.

Hope some of that helps,

-Andrew Cushen
================================================
-----Original Message-----
Help - I'm modifying a macro library, so that the macros
will run with Office XP. This includes a number of API
function calls, which are reading Registry values, eg to
pick up the location of the User Templates.
In the function call RegOpenKeyEx(), I've changed the
subkey value so that it points to the new Registry
location ("software\microsoft\office\10.0
\common\general\usertemplates"), but I get a return code
(error) of 2. I have checked the registry and the key is
definitely there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top