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

Re: Registry Access by Alex

Alex
Wed Nov 05 03:26:35 CST 2003

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.

"Stefan Mähr" <maehr.stefan@schweighofer.com> wrote in message
news:edEIY02oDHA.2512@TK2MSFTNGP09.phx.gbl...
> 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
>
>



Re: Registry Access by Maarten

Maarten
Wed Nov 05 03:34:21 CST 2003

What is the error you are getting?

--
Regards,

Maarten Struys, eMVP
PTS Software bv

"Stefan Mähr" <maehr.stefan@schweighofer.com> wrote in message
news:edEIY02oDHA.2512@TK2MSFTNGP09.phx.gbl...
> 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
>
>



Re: Registry Access by Stefan

Stefan
Wed Nov 05 03:42:07 CST 2003

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

Stefan


"Stefan Mähr" <maehr.stefan@schweighofer.com> schrieb im Newsbeitrag
news:edEIY02oDHA.2512@TK2MSFTNGP09.phx.gbl...
> 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
>
>