> 255) Then LnLevel = 255
If (LnLevel < 50) Then LnLevel = 50
prvGetLevel = LnLevel
End Function
Private Sub prvMakeTransparent(LhWnd As Long, bLevel As Byte)
Dim lOldStyle As Long
lOldStyle = GetWindowLong(LhWnd, GWL_EXSTYLE)
SetWindowLong LhWnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
SetLayeredWindowAttributes LhWnd, 0, bLevel, LWA_ALPHA
End Sub
Public Sub Main()
Dim LhWnd As Long
Dim LnLevel As Byte
LnLevel = prvGetLevel
If (InStr(1, Command(), "/silent", vbTextCompare) = 0) Then
'' If SetAutoStart(LnLevel) Then
'' MsgBox "TransTaskBar will be loaded when OS starts.", vbOKOnly Or vbInFORMation
'' End If
Else
End If
LhWnd = FindWindow("Shell_TrayWnd", vbNullString)
If (LhWnd <> 0) Then
prvMakeTransparent LhWnd, LnLevel
End If
End Sub
Public Function SetAutoStart(nLevel As Byte) As Boolean
Dim nRet As Long
Dim hKey As Long
Dim nResult As Long
Dim LsFullPath As String
With App
LsFullPath = App.Path & "\" & App.EXEName & ".exe"
End With
If (InStr(1, LsFullPath, " ") > 0) Then
LsFullPath = """" & LsFullPath & """"
End If
LsFullPath = LsFullPath & " /silent /TransLevel:" & CStr(nLevel)
'' Open (or create and open) key
nRet = RegCreateKeyEx(&H80000001, "Software\Microsoft\Windows\CurrentVersion\Run", 0&, vbNullString, _
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0&, hKey, nResult)
If nRet = ERROR_SUCCESS Then
'' Write new value to registry
nRet = RegSetvalueEx(hKey, App.EXEName, 0&, 1&, ByVal LsFullPath, Len(LsFullPath))
Call RegCloseKey(hKey)
End If
SetAutoStart = (nRet = ERROR_SUCCESS)
End Function
资料来源:Leontti A. Ramos M.