VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 控制windows开始菜单的速度
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:8199, 日期:2001-04-25
Controling the Speed of the Windows Start Menu

With this trick you can control the popup speed of the Windows Start Menu.

We have to create a new string in the windows registry, the new string is called MenuShowDelay and the value has to be between 1 (fastest) and 1000 (slowest), it has to be located in:

HKEY_CURRENT_USERControl PanelDesktopCreate 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 SubPut 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磗 value
    注释:(if already 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
Tip by Gijs de Jong