vb Code:
Public Function RegWriteDword(lngHKey As Long, strSubKey As String, strValueName As String, lngDwordDat As Long) As Long
'Create the subkey, value name and respective DWORD value.
Dim lngRetval As Long
Dim lngKeyHandle As Long
'Set the default return value.
RegWriteDword = ERROR_FAILED '999
'Create the key.
If RegCreateKeyEx(lngHKey, strSubKey, 0&, 0&, REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY, ByVal 0&, lngKeyHandle, lngRetval) = ERROR_SUCCESS Then
'Open the new key.
If RegOpenKeyEx(lngHKey, strSubKey, 0&, KEY_SET_VALUE, lngKeyHandle) = ERROR_SUCCESS Then
'Write it to the registry, and return a code.
RegWriteDword = RegSetValueEx(lngKeyHandle, strValueName, 0&, REG_DWORD, lngDwordDat, Len(lngDwordDat))
End If
End If
'Close any key opened with RegCreateKeyEx.
Call RegCloseKey(lngKeyHandle)
End Function