Registry Access

S

Stefan Mähr

Hello NG,

can anyone provide a codesnippet for creating a registry key (either VB or
C# don't care), the only ressource I found on net was opennetcf.org, which
is down since yesterday and i am in desperate need for this code snippet.
The following snippet (updated from evb) wont work and I got no idea why:

<DllImport("coredll.dll")> _
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


<DllImport("coredll.dll")> _
Private Function RegSetValueEx(ByVal hKey As Long, ByVal lpValueName As
String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As
String, ByVal cbData As Long) As Long ' Note that if you declare the
lpData parameter as String, you must pass it By Value.
End Function


lngResult = RegCreateKeyEx(HKEY_LOCAL_MACHINE, SubKey, 0, String.Empty,
REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, 0, hlngSubKey, lngDisposition)
lngResult = RegSetValueEx(hlngSubKey, Key, 0, REG_SZ, TempSetting, 2 *
Len(TempSetting))

Thanks in advance for all your help



Stefan
 
A

Alex Feinman [MVP]

The only thing I see that is obviously wrong is using Long type. Replace
every occurence with Integer and it should work.
Sorry about opennetcf.org being down. We are working on it.
 
S

Stefan Mähr

Thanks for all your help got it solved with using int32 instead of longs.

Stefan
 

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