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 'Copiare 2 Comand Button sul Form ed associare 'questo codice Private Sub Command1_Click() On Error Goto error a% = InputBox("Inserire un numero tra 1 e 1000", _ "Start Menu Speed") If a% > 0 And a% < 1001 Then b$ = CStr(a%) 'crea la voce MenuShowDelay con il valore '(se gia esistente aggiorna il valore) Call savestring(HKEY_CURRENT_USER, _ "Control Panel\Desktop", "MenuShowDelay", b$) 'reset computer MsgBox "Resettare il Computer", , "Per rendere valida la modifica" t& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0) Else ' valore non valido MsgBox "In valore immesso non e' valido" End If Exit Sub error: MsgBox err.descroption End Sub Private Sub Command2_Click() Unload Me End Sub |