Help Urgent! RegOpenKeyEx Does not work

B

Birdling

Guys:

I am developing an .net application on Pocket PC 2003. Need to read the
registry keys, however, code did not work. Use Owner as an example:

Public Declare Function RegOpenKeyEx Lib "Coredll" Alias
"RegOpenKeyExW" (ByVal hKey As Integer, ByVal lpSubKey As _
String, ByVal ulOptions As Integer, ByVal samDesired As
Integer, ByVal phkResult As Integer) As Integer

Private Const ERROR_SUCCESS As Integer = &O0
Private Const HKEY_CLASSES_ROOT As Integer = &H80000000
Private Const HKEY_CURRENT_USER As Integer = &H80000001
Private Const HKEY_LOCAL_MACHINE As Integer = &H80000002
Private Const KEY_READ As Integer = &H20019

lngResult = RegOpenKeyEx(HKEY_CURRENT_USER, "\ControlPanel\Owner", 0,
KEY_READ, hlngSubKey)


It always return a 87, owner not set. Swear to god it was set. And
hlngSubKey is always 0. For the lpSubKey, I also tried Char() instead
of String, same result.

Similar code worked fine on Pocket PC 2002 (using eVB). Please help.
Feel free to email me.

Thanks a lot
 
C

Chris Tacke, eMVP

Your code doesn't have any blatant errors that are jusmping out at me - I'd
use IntPtrs for the handles, but that's probably not terribly important.
Try the OpenNETCF SDF registry stuff to see if it works, then use the
definitions from it.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate
 
P

Peter Foot [MVP]

Firstly your pointer should be ByRef not byvalue - it returns the handle for
you to use:-
Public Declare Function RegOpenKeyEx Lib "Coredll" Alias "RegOpenKeyExW"
(ByVal hKey As Integer, ByVal lpSubKey As _
String, ByVal ulOptions As Integer, ByVal samDesired As Integer, ByRef
phkResult As Integer) As Integer

Also the samDesired argument is not support - pass 0.

You may wish to use the OpenNETCF.Win32.Registry implementation which
directly matches that in the full .NET framework:-
www.opennetcf.org/sdf/

Peter
 
D

Daniel Moth

Why not use the ready made registry class from opennetcf? Or post a complete
sample for me to try.

Cheers
Daniel
 

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