RegCreateKeyExW - ERROR_INVALID_PARAMETERS

M

Mobile Boy 36

I used RegCreateKeyEx in EVB without problems. In Vb.net I had to change the
long types into integer types because you have to pass a 32 bit value ( a
long in Evb was 32 bits; in vb.net you have to use the integer type).
I didm't touch the other parameters.
My return value is 87 (ERROR_INVALID_PARAMETERS). The registry key is not
created.
It seems that there is something wrong with the parameters (or with my
call...)
Does someone know how to resolve this problem? I would appreciate a
reaction...

My function:

Declare Function RegCreateKeyEx Lib "Coredll" Alias "RegCreateKeyExW" ( _
ByVal hkey As Integer, _
ByVal lpSubKey As String, _
ByVal Reserved As Integer, _
ByVal lpClass As String, _
ByVal dwOptions As Integer, _
ByVal samDesired As Integer, _
ByVal lpSecurityAttributes As Integer, _
ByVal phkResult As Integer, _
ByVal lpdwDisposition As Integer) _
As Integer

My call:
RetVal = RegCreateKeyEx _
(HKEY_LOCAL_MACHINE, "Software\Test", 0, _
vbNullString, 0, 0, 0, 0, 0)

Best regards,
Kevin
 
P

Paul G. Tobey [eMVP]

Problem #1: Remember that the phkResult is *returned*. You can pass it by
value or the initial value of the variable you pass is going to be
interpreted by the call as a pointer. You need to get the key returned
because you need to close it to avoid a leak.

Problem #2: Ditto the lpdwDisposition parameter.

Are you sure you don't want to just use OpenNetCF, which already has all
this done for you?

Paul T.
 

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