Hi,
i have tried to create a new key in the registry but the compiler dont let me succeed: It tells me always that the function RegCreateKeyEx() does not exist in the lib.
Can someone help me
Here is the code:
Declare Function RegCreateKeyEx Lib "Coredll.dll" 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, _ ByVal phkResult As Long, _ ByVal lpdwDisposition As Long) _As
Long
Public Function CreateNewKey(ByVal lSection As Long, _
ByVal sNewKeyName As String)
Dim hNewKey As Long '-- Handle to the new key
Dim lRetVal As Long '-- Result of the RegCreateKeyEx function '-- Create Registry Key '-- If key already exists, nothing happenslRetVal = RegCreateKeyEx(lSection, sNewKeyName, 0, _
vbNullString, REG_OPTION_NON_VOLATILE, _
KEY_ALL_ACCESS, _
0, hNewKey, lRetVal)
'-- Return Handle to KeyCreateNewKey = hNewKey
'-- Close Registry HandleRegCloseKey(hNewKey)
End Function
create a new rigistry key
DragonSpeed
With a very quick glance I can tell you that those Longs should be Integers (and I won't check if anything else is wrong too).
What you should do in CF v1.0 is use the OpenNETCF.Win32 namespace from the SDF. For CF v2.0, you should use Microsoft.Win32 which is there now out of the box. No point reinventing the wheel in either case.
Cheers
Daniel