modGeneral.bas
上传用户:yinyu8822
上传日期:2021-04-28
资源大小:79k
文件大小:4k
开发平台:

Visual Basic

  1. Attribute VB_Name = "modGeneral"
  2. 'Download by http://www.codefans.net
  3. Public Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
  4. 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
  5. Public Const HWND_BOTTOM = 1
  6. Public Const HWND_NOTOPMOST = -2
  7. Public Const HWND_TOP = 0
  8. Public Const HWND_TOPMOST = -1
  9. Public Const SWP_NOACTIVATE = &H10
  10. Public Const SWP_SHOWWINDOW = &H40
  11. Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
  12. Public Const SW_HIDE = 0
  13. Public Const SW_NORMAL = 1
  14. Public Const SW_SHOWMINIMIZED = 2
  15. Public Const SW_SHOWMAXIMIZED = 3
  16. Public Const SW_SHOWNOACTIVATE = 4
  17. Public Const SW_SHOW = 5
  18. Public Const SW_MINIMIZE = 6
  19. Public Const SW_SHOWMINNOACTIVE = 7
  20. Public Const SW_SHOWNA = 8
  21. Public Const SW_RESTORE = 9
  22. Public Const SW_SHOWDEFAULT = 10
  23. Public Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Boolean
  24. Public Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long
  25. Public Declare Function GetTopWindow Lib "user32" (ByVal hwnd As Long) As Long
  26. Public Declare Function GetForegroundWindow Lib "user32" () As Long
  27. Public Function WindowPos(frm As Object, setting As Integer)
  28. Dim i As Integer
  29. Select Case setting
  30. Case 1
  31. i = HWND_TOPMOST
  32. Case 2
  33. i = HWND_TOP
  34. Case 3
  35. i = HWND_NOTOPMOST
  36. Case 4
  37. i = HWND_BOTTOM
  38. End Select
  39. SetWindowPos frm.hwnd, i, frm.Left / 15, _
  40. frm.Top / 15, frm.Width / 15, _
  41. frm.Height / 15, SWP_SHOWWINDOW Or SWP_NOACTIVATE
  42. End Function
  43. Public Sub SetFGWindow(ByVal hwnd As Long, Show As Boolean)
  44. If Show Then
  45. If IsIconic(hwnd) Then
  46. ShowWindow hwnd, SW_RESTORE
  47. Else
  48. BringWindowToTop hwnd
  49. End If
  50. Else
  51. ShowWindow hwnd, SW_MINIMIZE
  52. End If
  53. End Sub
  54. Public Function LoadSettings()
  55. Dim ff As Long
  56. Dim data(4) As String
  57. ff = FreeFile
  58. Open App.Path & "SPFlog.log" For Input As #ff
  59. Do Until EOF(ff)
  60.     Input #ff, data(0), data(1), data(2), data(3), data(4)
  61.     frmOptions.lstLog.ListItems.Add , , data(0)
  62.     frmOptions.lstLog.ListItems(frmOptions.lstLog.ListItems.Count).SubItems(1) = data(1)
  63.     frmOptions.lstLog.ListItems(frmOptions.lstLog.ListItems.Count).SubItems(2) = data(2)
  64.     frmOptions.lstLog.ListItems(frmOptions.lstLog.ListItems.Count).SubItems(3) = data(3)
  65.     frmOptions.lstLog.ListItems(frmOptions.lstLog.ListItems.Count).SubItems(4) = data(4)
  66. Loop
  67. Close #ff
  68. If modReg.bGetRegValue(HKEY_LOCAL_MACHINE, SREG & "options", "active") = "1" Then
  69.     
  70.     frmMain.Toolbar1.Buttons(4).Caption = "all"
  71.     frmMain.Toolbar1.Buttons(4).ToolTipText = "show all connections"
  72.     frmMain.Toolbar1.Buttons(4).Value = tbrPressed
  73.     frmMain.RefreshTable True
  74. End If
  75. modReg.bIndexReg HKEY_LOCAL_MACHINE, SREG & "blockip", frmOptions.lstIP, "1"
  76. modReg.bIndexReg HKEY_LOCAL_MACHINE, SREG & "blocklp", frmOptions.lstLocP, "1"
  77. modReg.bIndexReg HKEY_LOCAL_MACHINE, SREG & "blockrp", frmOptions.lstRemP, "1"
  78. End Function
  79. Public Function Log(RemA As String, RemP As String, LocP As String, Txt As String)
  80. Dim ff As Long
  81. ff = FreeFile
  82. Open App.Path & "SPFlog.log" For Append As #ff
  83. Write #ff, Time & "-" & Date, RemA, RemP, LocP, Txt
  84. frmOptions.lstLog.ListItems.Add , , Time & "-" & Date
  85. frmOptions.lstLog.ListItems(frmOptions.lstLog.ListItems.Count).SubItems(1) = RemA
  86. frmOptions.lstLog.ListItems(frmOptions.lstLog.ListItems.Count).SubItems(2) = RemP
  87. frmOptions.lstLog.ListItems(frmOptions.lstLog.ListItems.Count).SubItems(3) = LocP
  88. frmOptions.lstLog.ListItems(frmOptions.lstLog.ListItems.Count).SubItems(4) = Txt
  89. Close #ff
  90. End Function