home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "Startup"
- Public os_info As OSVERSIONINFO
- Public Barleft As Integer
- Public Btns() As New Btn
- Public Icons() As New Task
- Public RootPath As String
- Public SystemPath As String
-
- Sub Main()
- 'If FindWindow("Shell_TrayWnd", vbNullString) Then MsgBox "This program can not run while windows is running!", vbCritical, "WARNING": End
- Dim strBuf As String
- strBuf = Space$(MAX_SIZE)
- If GetWindowsDirectory(strBuf, MAX_SIZE) Then RootPath = Left(strBuf, InStr(1, strBuf, Chr(0)) - 1) + "\"
- strBuf = Space$(MAX_SIZE)
- If GetSystemDirectory(strBuf, MAX_SIZE) Then SystemPath = Left(strBuf, InStr(1, strBuf, Chr(0)) - 1) + "\"
- os_info.dwOSVersionInfoSize = Len(os_info)
- Call GetVersion(os_info)
- Win32_IE = os_info.dwMajorVersion
- ReDim Icons(0)
- ReDim Btns(0)
- Barleft = 80 * Screen.TwipsPerPixelX
- Call setMinMax
- Desktop.Show
- Call EnumWindows(AddressOf EnumWindowsProc, 0)
- Desktop.Timer1.Enabled = True
- Call SystemTray
- 'If GetKeyState(VK_SHIFT) <> &H8000 Then Call StartUp
- End Sub
-
- Private Function StartUp()
- Const szRunPath = ("Software\Microsoft\Windows\CurrentVersion\Run")
- Const szRunOncePath = ("Software\Microsoft\Windows\CurrentVersion\RunOnce")
- RunEntriesIn HKEY_LOCAL_MACHINE, szRunOncePath
- DeleteEntriesIn HKEY_LOCAL_MACHINE, szRunOncePath
- RunEntriesIn HKEY_CURRENT_USER, szRunOncePath
- DeleteEntriesIn HKEY_CURRENT_USER, szRunOncePath
- RunEntriesIn HKEY_LOCAL_MACHINE, szRunPath
- RunEntriesIn HKEY_CURRENT_USER, szRunPath
- 'StartupMenu
- End Function
-
- Function RunEntriesIn(key, Path)
- Dim hKey As Long, lResult As Long, szNameBuffer As String * 1024, _
- szValueBuffer As String * 1024, dwLoop As Integer
- lResult = RegOpenKeyEx(key, Path, 0, KEY_READ, hKey)
- If (lResult = ERROR_SUCCESS) Then
- Do
- lResult = RegEnumValue(hKey, dwLoop, szNameBuffer, Len(szNameBuffer), 0, 0, szValueBuffer, Len(szValueBuffer))
- If lResult = ERROR_SUCCESS Then Call Shell(Left(szValueBuffer, InStr(1, szValueBuffer, Chr(0)) - 1), vbNormalFocus) Else Call RegCloseKey(hKey): Exit Function
- dwLoop = dwLoop + 1
- Loop
- Call RegCloseKey(hKey)
- End If
- End Function
-
- Private Function DeleteEntriesIn(key As HKeys, Path As String)
- Dim hKey As Long
- Dim lResult As Long
- lResult = RegOpenKeyEx(key, Path, 0, KEY_READ, hKey)
- If (lResult = ERROR_SUCCESS) Then
- Dim szNameBuffer As String * 1024, szValueBuffer As String * 1024
- Dim dwLoop As Long, dwNameSize As Long, dwValueSize As Long
- Do
- dwNameSize = Len(szNameBuffer)
- dwValueSize = Len(szValueBuffer)
-
- lResult = RegEnumValue(hKey, dwLoop, szNameBuffer, dwNameSize, 0, 0, szValueBuffer, dwValueSize)
- If (lResult = ERROR_NO_MORE_ITEMS) Then Call RegCloseKey(hKey): Exit Function
- If (lResult = ERROR_SUCCESS) Then
- lResult = RegDeleteValue(hKey, szNameBuffer)
- If (lResult <> ERROR_SUCCESS) Then Call RegCloseKey(hKey): Exit Function
- End If
- Loop
- Call RegCloseKey(hKey)
- End If
- End Function
-