|
-
Mar 9th, 2007, 08:04 AM
#1
Thread Starter
Frenzied Member
-
Mar 9th, 2007, 08:37 AM
#2
Thread Starter
Frenzied Member
Re: [RESOLVED by schoolbusdriver]Save to registry, but it doesn't!
Hmm, thought I did.
I am getting the error:
User defined type may not be passed ByVal
on this line of code:
vb Code:
Result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "StartOption", ByVal 0&, REG_DWORD, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0&, lngKeyHandle, Ret)
on the "ByVal 0&" part.
I have this line of code elsewhere and it works without this error:
vb Code:
Result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Left", ByVal 0&, REG_DWORD, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0&, lngKeyHandle, Ret)
Now I'm not too sure what this means, but looking at the API code it says:
lpSecurityAttributes As Any
But when I type the code out, the intellisense (or what ever the tooltiptext is called) it says
lpSecurityAttributes As SECURITY_ATTRIBUTES
Does this matter, or make any sense?
vb Code:
Dim lngKeyHandle As Long
Dim Ret As Long
Dim Result As Long
Const strSubKey = "Software\Deftech\CodeLibrary\2.0"
'SelectedOption holds the option button index number
'Check if the specified key exists
Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strSubKey, 0&, KEY_ALL_ACCESS, lngKeyHandle)
If Result <> 0 Then
'Key doesn't exist. 0 signifies success.
'Create a new key
Result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "StartOption", ByVal 0&, REG_DWORD, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0&, lngKeyHandle, Ret)
If Result <> 0 Then '0 signifies success.
MsgBox "Error while creating the Key!!"
Exit Sub
End If
'Open the new key.
RegOpenKeyEx HKEY_LOCAL_MACHINE, "StartOption", 0&, KEY_ALL_ACCESS, lngKeyHandle
End If
'Now that we have a valid handle - Give it a value
'The 4 signifies the length of the value. For a DWORD (Long) it's always 4.
RegSetValueEx lngKeyHandle, "StartOption", 0&, REG_DWORD, SelectedOption, 4
'close the opened key
RegCloseKey lngKeyHandle
Last edited by aikidokid; Mar 9th, 2007 at 08:46 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|