devilmaster1
Member
- Joined
- Jul 29, 2007
- Messages
- 16
- Programming Experience
- 5-10
Hey i been tying to use the registry api calls in vb.net and when i try i always get this error message.
object reference not set to an instance of an object vb.net
the code i was using is this.
Public Function MakeDWORD(FolderKey As String, SubFolderKey As String, KeyValue As String, KeyText As String)
Dim nBufferKey As Long, nBufferSubKey As Long
Dim InputValue As String
InputValue = KeyText
RegCreateKey HKEYCURRENTUSER, FolderKey, nBufferKey
RegOpenKey HKEYCURRENTUSER, FolderKey, nBufferKey
RegCreateKey nBufferKey, SubFolderKey, nBufferSubKey
RegOpenKey nBufferKey, SubFolderKey, nBufferSubKey
RegSetValueEx nBufferSubKey, KeyValue, 0, REG_DWORD, InputValue, 4
End Function
it errors out on the regcreatekey part.
RegCreateKey HKEYCURRENTUSER, FolderKey, nBufferKey
and thats the error i get any idea how i can fix that cause its kinda frustating i use vb.net 2003 and i know how to access the registery though the name spaces but its limited to only the reg_sz entrie i need to use dword and binary but i cant using namespaces but this function here is erroring out any idea how i can fix the problem ?
object reference not set to an instance of an object vb.net
the code i was using is this.
Public Function MakeDWORD(FolderKey As String, SubFolderKey As String, KeyValue As String, KeyText As String)
Dim nBufferKey As Long, nBufferSubKey As Long
Dim InputValue As String
InputValue = KeyText
RegCreateKey HKEYCURRENTUSER, FolderKey, nBufferKey
RegOpenKey HKEYCURRENTUSER, FolderKey, nBufferKey
RegCreateKey nBufferKey, SubFolderKey, nBufferSubKey
RegOpenKey nBufferKey, SubFolderKey, nBufferSubKey
RegSetValueEx nBufferSubKey, KeyValue, 0, REG_DWORD, InputValue, 4
End Function
it errors out on the regcreatekey part.
RegCreateKey HKEYCURRENTUSER, FolderKey, nBufferKey
and thats the error i get any idea how i can fix that cause its kinda frustating i use vb.net 2003 and i know how to access the registery though the name spaces but its limited to only the reg_sz entrie i need to use dword and binary but i cant using namespaces but this function here is erroring out any idea how i can fix the problem ?