HKEY_CURRENT_USER\Control Panel\Desktop
'Create a new project and add a module and a form to it. 'In the module put the following code: Public Const EWX_REBOOT = 2 Public Const EWX_FORCE = 4 Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long Public Const REG_SZ = 1 Public Const REG_DWORD = 4 Public Sub savestring(Hkey As Long, strPath As String, strValue As String, strdata As String) Dim keyhand Dim r r = RegCreateKey(Hkey, strPath, keyhand) r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strdata, Len(strdata)) r = RegCloseKey(keyhand) End Sub Put 2 command buttons on the form and add the following code: Private Sub Command1_Click() On Error GoTo error a% = InputBox("Enter a number between 1 and 1000", "Start Menu Speed") 'a is the integer value of the input in the inputbox 'checking the input If a% > 0 And a% < 1001 Then 'input is a valid number between 1 and 1000 'and a (integer) is to be converted in b (string) b$ = CStr(a%) 'creating MenuShowDelay with itīs value '(if allready exists it just changes the value) Call savestring(HKEY_CURRENT_USER, _ "Control Panel\Desktop", "MenuShowDelay", b$) 'resetting computer MsgBox "Reset your Computer", , "Changes are made" t& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0) Else 'value is a number but not valid MsgBox "Not a valid number between 1 and 1000" End If Exit Sub error: 'error, input was not a valid number MsgBox "Invalid Data Input" End Sub Private Sub Command2_Click() Unload Me End Sub |