Module1.bas
上传用户:albinfu
上传日期:2021-08-24
资源大小:71k
文件大小:8k
- Attribute VB_Name = "Message"
- Public Type NOTIFYICONDATA
- cbSize As Long
- hwnd As Long
- uId As Long
- uFlags As Long
- ucallbackMessage As Long
- hIcon As Long
- szTip As String * 64
- End Type
- Public Const NIM_ADD = &H0
- Public Const NIM_MODIFY = &H1
- Public Const NIM_DELETE = &H2
- Public Const NIF_MESSAGE = &H1
- Public Const NIF_ICON = &H2
- Public Const NIF_TIP = &H4
- Public Const WM_LBUTTONDBLCLK = &H203
- Public Const WM_LBUTTONDOWN = &H201
- Public Const WM_RBUTTONUP = &H205
- Public Const WM_MOUSEMOVE = &H200
- Public Const WM_RBUTTONDOWN = &H204
- Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
- Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
- Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
- Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
- Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
- Public Declare Function GetForegroundWindow Lib "user32" () As Long
- Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
- Public Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
- Public TrayI As NOTIFYICONDATA
- Public Const DRIVE_REMOVABLE = 2
- Public Const DRIVE_FIXED = 3
- Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
- Public Declare Function GetMenuItemCount Lib "user32" (ByVal hmenu As Long) As Long
- Public Declare Function RemoveMenu Lib "user32" (ByVal hmenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
- Public Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
- Public Const MF_BYPOSITION = &H400&
- Public Const MF_REMOVE = &H1000&
- Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
- Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
- Public Const WS_CAPTION = &HC00000
- Public Const WS_MINIMIZEBOX = &H20000
- Public Const WS_MAXIMIZEBOX = &H10000
- Public Const WS_SYSMENU = &H80000
- Public Const GWL_STYLE = (-16)
- Public Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
- Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
- Public Const KEYEVENTF_KEYUP = &H2
- Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
- Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
- Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
- Public Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
- Public Const FILE_ATTRIBUTE_ARCHIVE = &H20 '存档
- Public Const FILE_ATTRIBUTE_COMPRESSED = &H800 '压缩
- Public Const FILE_ATTRIBUTE_DIRECTORY = &H10 '目录
- Public Const FILE_ATTRIBUTE_HIDDEN = &H2 '隐藏
- Public Const FILE_ATTRIBUTE_NORMAL = &H80 '正常
- Public Const FILE_ATTRIBUTE_READONLY = &H1 '只读
- Public Const FILE_ATTRIBUTE_SYSTEM = &H4 '系统
- Public Const SW_MINIMIZE = 6
- Public Const SW_SHOWMAXIMIZED = 3
- Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
- Public Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long
- Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
- Function TitleBar()
- Dim hmenu As Long
- Dim ncount As Long
- hmenu = GetSystemMenu(Form1.hwnd, 0)
- ncount = GetMenuItemCount(hmenu)
- Call RemoveMenu(hmenu, 0, MF_REMOVE Or MF_BYPOSITION)
- Call RemoveMenu(hmenu, 1, MF_REMOVE Or MF_BYPOSITION)
- Call RemoveMenu(hmenu, 2, MF_REMOVE Or MF_BYPOSITION)
- 'Call RemoveMenu(hmenu, 3, MF_REMOVE Or MF_BYPOSITION)
- 'Call RemoveMenu(hmenu, 4, MF_REMOVE Or MF_BYPOSITION)
- DrawMenuBar Form1.hwnd
- Dim SN As Long
- SN = GetWindowLong(Form1.hwnd, GWL_STYLE)
- 'SN = SN And Not WS_SYSMENU
- SN = SN And Not WS_MAXIMIZEBOX
- 'SN = SN And Not WS_MINIMIZEBOX
- 'SN = SN And Not WS_CAPTION
- SetWindowLong Form1.hwnd, GWL_STYLE, SN
- End Function
- Function GetAutoRun(Mypath As String) As String '====判断根目录下所有文件的类型
- If Mypath = "" Then Exit Function
- Dim ATest As Integer, FileT As String
- ATest = GetFileAttributes(Mypath)
- If ATest And FILE_ATTRIBUTE_ARCHIVE Then FileT = FileT & "A"
- If ATest And FILE_ATTRIBUTE_DIRECTORY Then FileT = FileT & "D"
- If ATest And FILE_ATTRIBUTE_HIDDEN Then FileT = FileT & "H"
- If ATest And FILE_ATTRIBUTE_NORMAL Then FileT = FileT & "N"
- If ATest And FILE_ATTRIBUTE_READONLY Then FileT = FileT & "R"
- If ATest And FILE_ATTRIBUTE_SYSTEM Then FileT = FileT & "S"
- GetAutoRun = FileT
- End Function
- Function TellFileType(GiveMe As String) As String '====文件属性中文说明====
- Dim FT As String
- If InStr(GiveMe, "A") Then FT = FT & "存档" & "+"
- If InStr(GiveMe, "D") Then FT = FT & "目录" & "+"
- If InStr(GiveMe, "H") Then FT = FT & "隐藏" & "+"
- If InStr(GiveMe, "N") Then FT = FT & "正常" & "+"
- If InStr(GiveMe, "R") Then FT = FT & "只读" & "+"
- If InStr(GiveMe, "S") Then FT = FT & "系统" & "+"
- TellFileType = Left(FT, Len(FT) - 1)
- End Function
- Function WriteLog(xx As String) '====转入后台记录====
- If xx = "" Then Exit Function
- Dim fso, w
- Set fso = CreateObject("scripting.filesystemobject")
- Set w = fso.opentextfile("d:usb.txt", 8, True)
- w.writeline xx
- w.Close
- End Function
- Function RecordNumber() As Integer '=====记录条数====
- Dim fso, f, FF
- RecordNumber = 0
- On Error Resume Next
- Set fso = CreateObject("scripting.filesystemobject")
- If fso.fileexists("d:usb.txt") = False Then Exit Function
- Set f = fso.opentextfile("d:usb.txt", 1, True)
- FF = f.readall
- RecordNumber = f.Line - 1
- f.Close
- End Function
- Function GetFactory(ll As String) As String '====卷标名称====
- Dim Volume As String * 255
- If ll = "" Then Exit Function
- Call GetVolumeInformation(ll, Volume, 255, 0&, 0&, 0&, 0&, 255)
- GetFactory = Left(Volume, InStr(Volume, vbNullChar) - 1)
- End Function
- 'Function HelpMe(i As Integer) As String '===帮助=====
- 'Dim s(1 To 9) As String, X As String
- 's(1) = "打开目录功能:当插入可移动磁盘时,自动扫描隐藏文件并确认安全后再自动打开U盘所在目录。"
- 's(2) = "最前显示功能:当前窗口置于所有窗口之上,或以正常窗口显示当有新窗口打开时被覆盖。"
- 's(3) = "消息提示功能:当插入、移除U盘、自动隐藏时,均有进度条状态显示。"
- 's(4) = "自动隐藏功能:一段时间没有鼠标动作后(30秒)将自动隐藏转入后台处理,不影响正常工作。"
- 's(5) = "时间显示功能:显示当前程序已启动时间,可以观察程序运行状态有无异常。"
- 's(6) = "窗口检测功能:100MHZ频率自动扫描,能自动跟随鼠标活动,一旦发现磁盘目录有危险性文件时,能在病毒运行之前先删除它。"
- 's(7) = "安全打开功能:能打开当前U盘所在盘符目录,而非鼠标双击打开,窗口标题会有提示。"
- 's(8) = "查看删除功能:对可移动磁盘的所有动作均在后台作详细记录,可查看操作记录,删除记录。"
- 's(9) = "系统扫描功能:对可移动磁盘、本地磁盘作全面扫描,发现病毒文件立即删除。"
- 'HelpMe = s(i)
- 'End Function