'托盘API 模块
Private M_IconData As NOTIFYICONDATA
Private Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * 128
dwState As Long
dwStateMask As Long
szInfo As String * 256
uTimeout As Long
szInfoTitle As String * 64
dwInfoFlags As Long
End Type
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
'使用高分辨率图标所用的API
Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal dwImageType As Long, ByVal dwDesiredWidth As Long, ByVal dwDesiredHeight As Long, ByVal dwFlags As Long) As Long
Private Declare Function timeGetTime Lib "winmm.dll" () As Long '延迟API
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) '避免延迟时CPU使用率过高 Sleep API
Dim CountStrC As Integer
'统计参数个数
Dim Strcmd '参数拆分后的数组
Dim Info, TitleAndKind, Title, TipKinds, Start_Pro As String
'内容 标题与提示种类 标题 提示种类 点击运行
Dim Hide_Start As Boolean '是否隐藏启动点击运行
Dim TrayIcon '用于存高分辨率图标
Dim SleepT '延迟时间
Dim Begintime As Double '记录当前时间
Private Sub Form_Load()
Me.Hide '无窗口
On Error GoTo EndPor '防止拖拽(如果参数类型不对则结束程序)
Dim Tmp As String, i '自定义延迟 时 获取延迟时间
For i = 1 To Len(Strcmd(0)) '只获取数字
Tmp = Mid(Strcmd(0), i, 1)
If Asc(Tmp) <= Asc("9") And Asc(Tmp) >= Asc("0") Then SleepT = SleepT & Tmp
Next
If CountStrC >= "2" Then '如果有标题 则
If Strcmd(1) <> "" Then '如果标题不为空 则
If InStr(Strcmd(1), "#@") <> "0" Then '如果指定了标题类型 则
TitleAndKind = Split(Strcmd(1), "#@") '拆分标题 与 标题类型 参数 并存入 数组
Title = TitleAndKind(0) '获取标题
'设定提示类型
If TitleAndKind(1) = "0" Then
TipKinds = &H0 '无标题图标
Else
If TitleAndKind(1) = "1" Then
TipKinds = &H7 '询问标题图标
Else
If TitleAndKind(1) = "2" Then
TipKinds = &H2 '感叹标题图标
Else
If TitleAndKind(1) = "3" Then
TipKinds = &H3 '错误标题图标
Else
If TitleAndKind(1) = "4" And CountStrC >= "5" Then If Trim(Strcmd(4)) <> "" Then TipKinds = &H4 '当设定了 托盘图标与4时,设定标题图标 同 托盘图标
End If
End If
End If
End If
Else
Title = Strcmd(1) '没指定类型时 直接 获取标题
End If
Else '如果标题为空 则
TipKinds = &H0 '无提示类型
End If
If CountStrC >= "3" Then
Info = Replace((Strcmd(2)), "\n", vbCrLf) '获取内容 并 转义"\n"回车符
If CountStrC >= "4" Then '如果有点击后 运行的命令
If InStr(Strcmd(3), "##") <> "0" Or InStr(Strcmd(3), "##") <> "0" Then '如果指定为隐藏运行 获取命令路径 并 删除 ##
Start_Pro = Replace(Strcmd(3), "##", "")
Hide_Start = True
Else
Start_Pro = Trim(Strcmd(3)) '否则直接 获取点击后 运行的命令
End If
If CountStrC >= "5" Then
TrayIcon = LoadImage(App.hInstance, Trim(Strcmd(4)), 1, 16, 16, &H10 Or &H1000) '先检测图标文件是否存在 如存在自定义托盘图标
If Trim(Strcmd(4)) <> "" Then If TrayIcon = "0" Then GoTo TrayIcoHelp '如果托盘ICO 文件类型不对 则提示错误
End If
End If
End If
If Info = "" Then '如果内容为空 则 提示错误
Info = "提示内容应不为空"
Show_Error '调用错误 处理
End If
End If
Else '如果参数里不含分号 则
If Command = "" Then '如果参数为空 则 显示参数格式
Title = "气泡 调用参数 "
Info = "[时间];;[标题[#@标题图标]];;内容;;" & vbCrLf & "[点击后执行的命令[##]];;[托盘图标路径]" & vbCrLf & vbCrLf & "正键 点击我 查看参数详细说明"
SleepT = 20000
Else '如果有参数 但参数没包含分号
Info = "请键入 参数分隔符" & vbCrLf & "参数分隔符为两个西文半角的 分号"
Show_Error '调用错误 处理
End If
End If