System.NotSupportedException - RegCreateKeyEx

M

Mobile Boy 36

I'm trying to use the WinCE API's to write to the registry in VB.Net. I
keep getting the following error: "An unhandled exception of type
'System.NotSupportedException' occurred ".

I know that System.NotSupportedExteption is 99.9% of the time an incorrect
P/Invoke
declaration. Please does someone know how to resolve this?

The function worked fine in EVB, no problem at all...but not in VB.NET



This is my function definition:

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

I also tried the .NET alternative declaration:

<DllImport("Coredll", Entrypoint:="RegCreateKeyExW", SetLastError:=True)> _
Private Function RegCreateKeyEx( _
ByVal hkey As Long, _
ByVal lpSubKey As String, _
ByVal Reserved As Long, _
ByVal lpClass As String, _
ByVal dwOptions As Long, _
ByVal samDesired As Long, _
ByVal lpSecurityAttributes As Long, _
ByVal phkResult As Long, _
ByVal lpdwDisposition As Long) _
As Long
End Function



Best regards,

Kevin
 
M

Maarten Struys, eMVP

A long datatype in the .NET CF is 64 bits wide, a long in native code is 32
bits wide. Therefor you have to change long in the declarations to int.
 

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