home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 3_2004-2005.ISO / Data / Zips / Programmin18171611112004.psc / Form2.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2004-11-11  |  7.0 KB  |  214 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form frmMain 
  4.    BorderStyle     =   1  'Fest Einfach
  5.    Caption         =   "Windows - XP - Firewall"
  6.    ClientHeight    =   7530
  7.    ClientLeft      =   2835
  8.    ClientTop       =   2625
  9.    ClientWidth     =   11010
  10.    LinkTopic       =   "Form2"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   7530
  14.    ScaleWidth      =   11010
  15.    Begin VB.CheckBox chkAllowIncomingEcho 
  16.       Caption         =   "Allow Incoming Echo Request"
  17.       Height          =   375
  18.       Left            =   5700
  19.       TabIndex        =   8
  20.       Top             =   960
  21.       Width           =   3735
  22.    End
  23.    Begin VB.PictureBox Picture1 
  24.       BorderStyle     =   0  'Kein
  25.       Height          =   615
  26.       Left            =   0
  27.       Picture         =   "Form2.frx":0000
  28.       ScaleHeight     =   615
  29.       ScaleWidth      =   11025
  30.       TabIndex        =   7
  31.       Top             =   0
  32.       Width           =   11025
  33.       Begin VB.Label Label1 
  34.          BackStyle       =   0  'Transparent
  35.          Caption         =   "Programming with the XP Fireall with VB6"
  36.          BeginProperty Font 
  37.             Name            =   "MS Sans Serif"
  38.             Size            =   9.75
  39.             Charset         =   0
  40.             Weight          =   700
  41.             Underline       =   0   'False
  42.             Italic          =   0   'False
  43.             Strikethrough   =   0   'False
  44.          EndProperty
  45.          ForeColor       =   &H00FFFFFF&
  46.          Height          =   375
  47.          Left            =   1200
  48.          TabIndex        =   9
  49.          Top             =   180
  50.          Width           =   6705
  51.       End
  52.    End
  53.    Begin VB.CommandButton cmdAddSelected 
  54.       Caption         =   "&Add Selected Ports to Firewall"
  55.       Height          =   465
  56.       Left            =   60
  57.       TabIndex        =   6
  58.       Top             =   6960
  59.       Width           =   2325
  60.    End
  61.    Begin VB.Frame Frame1 
  62.       Caption         =   "Firewall Status"
  63.       Height          =   1635
  64.       Left            =   60
  65.       TabIndex        =   0
  66.       Top             =   870
  67.       Width           =   5445
  68.       Begin VB.PictureBox picStatus 
  69.          BorderStyle     =   0  'Kein
  70.          Height          =   825
  71.          Left            =   4350
  72.          ScaleHeight     =   825
  73.          ScaleWidth      =   1005
  74.          TabIndex        =   3
  75.          Top             =   180
  76.          Width           =   1005
  77.       End
  78.       Begin VB.CommandButton cmdDisable 
  79.          Caption         =   "&Disable Firewall"
  80.          Height          =   465
  81.          Left            =   1950
  82.          TabIndex        =   2
  83.          Top             =   870
  84.          Width           =   1695
  85.       End
  86.       Begin VB.CommandButton cmdEnable 
  87.          Caption         =   "&Enable Firewall"
  88.          Height          =   465
  89.          Left            =   150
  90.          TabIndex        =   1
  91.          Top             =   870
  92.          Width           =   1695
  93.       End
  94.       Begin VB.Label lblStatus 
  95.          BeginProperty Font 
  96.             Name            =   "MS Sans Serif"
  97.             Size            =   8.25
  98.             Charset         =   0
  99.             Weight          =   700
  100.             Underline       =   0   'False
  101.             Italic          =   0   'False
  102.             Strikethrough   =   0   'False
  103.          EndProperty
  104.          Height          =   375
  105.          Left            =   150
  106.          TabIndex        =   4
  107.          Top             =   330
  108.          Width           =   4965
  109.       End
  110.    End
  111.    Begin MSComctlLib.ListView lsvPort 
  112.       Height          =   4305
  113.       Left            =   60
  114.       TabIndex        =   5
  115.       Top             =   2580
  116.       Width           =   10875
  117.       _ExtentX        =   19182
  118.       _ExtentY        =   7594
  119.       LabelWrap       =   -1  'True
  120.       HideSelection   =   -1  'True
  121.       _Version        =   393217
  122.       ForeColor       =   -2147483640
  123.       BackColor       =   -2147483643
  124.       BorderStyle     =   1
  125.       Appearance      =   1
  126.       NumItems        =   0
  127.    End
  128. Attribute VB_Name = "frmMain"
  129. Attribute VB_GlobalNameSpace = False
  130. Attribute VB_Creatable = False
  131. Attribute VB_PredeclaredId = True
  132. Attribute VB_Exposed = False
  133. Option Explicit
  134. '--> Enable and Disable Firewall from WinXP SP2 Via NetCon 1.0 Typelibrary
  135. '--> You need to have XPSP2 installed to use this
  136. Private oFirewall As clsFirewall
  137. Private lngPortCounter As Long
  138. Private Sub chkAllowIncomingEcho_Click()
  139.   If Me.chkAllowIncomingEcho.Value = True Then
  140.     Call oFirewall.AllowIncomingICMP(True)
  141.   Else
  142.     Call oFirewall.AllowIncomingICMP(False)
  143.   End If
  144. End Sub
  145. Private Sub cmdAddSelected_Click()
  146. Dim itm As ListItem
  147.   For Each itm In Me.lsvPort.ListItems
  148.     If itm.Checked = True Then
  149.       Call oFirewall.AddPortToFirewall(itm.SubItems(2), itm.SubItems(1), itm.Text)
  150.     End If
  151.   Next
  152. End Sub
  153. Private Sub cmdDisable_Click()
  154.   oFirewall.DisableFirewall
  155.   Call GetFirewallStatus
  156. End Sub
  157. Private Sub cmdEnable_Click()
  158.   oFirewall.EnableFirewall
  159.   Call GetFirewallStatus
  160. End Sub
  161. Private Sub Form_Load()
  162.   Call initListview
  163.   Set oFirewall = New clsFirewall
  164.   Call GetFirewallStatus
  165.   Call LoadPortList
  166. End Sub
  167. Private Sub GetFirewallStatus()
  168.   If oFirewall.FirewallStatus = True Then
  169.     Me.lblStatus.Caption = "Firewall enabled"
  170.     Me.picStatus.Picture = LoadResPicture(101, vbResBitmap)
  171.   Else
  172.     Me.lblStatus.Caption = "Firewall disabled"
  173.     Me.picStatus.Picture = LoadResPicture(102, vbResBitmap)
  174.   End If
  175. End Sub
  176. Private Sub initListview()
  177.   With Me.lsvPort
  178.     .View = lvwReport
  179.     .ColumnHeaders.Add Text:="Port", Width:=1000, Alignment:=AlignmentConstants.vbLeftJustify
  180.     .ColumnHeaders.Add Text:="Type", Width:=1000, Alignment:=vbCenter
  181.     .ColumnHeaders.Add Text:="Keyword", Width:=2000, Alignment:=vbCenter
  182.     .ColumnHeaders.Add Text:="Description", Width:=2000, Alignment:=vbCenter
  183.     .ColumnHeaders.Add Text:="Trojan Info", Width:=8000, Alignment:=vbCenter
  184.     .Checkboxes = True
  185.   End With
  186. End Sub
  187. Private Sub LoadPortList()
  188. '--> Load Portlist via Filesystem Object
  189. Dim oFso As FileSystemObject
  190. Dim stream As TextStream
  191. Dim strArray() As String
  192. Dim oItm As ListItem
  193. On Error GoTo errHandler
  194.   Set oFso = New FileSystemObject
  195.   Set stream = oFso.OpenTextFile(App.Path & "\Portlist.txt")
  196.   While Not stream.AtEndOfStream
  197.     lngPortCounter = lngPortCounter + 1
  198.     strArray = Split(stream.ReadLine, "|")
  199.     Set oItm = Me.lsvPort.ListItems.Add(Text:=strArray(0))
  200.     oItm.SubItems(1) = strArray(1)
  201.     oItm.SubItems(2) = strArray(2)
  202.     oItm.SubItems(3) = strArray(3)
  203.   Wend
  204.   stream.Close
  205.   Set stream = Nothing
  206.   Set oFso = Nothing
  207. Exit Sub
  208. errHandler:
  209.   MsgBox Err.Description
  210.   Err.Clear
  211.   If Not oFso Is Nothing Then Set oFso = Nothing
  212.   If Not stream Is Nothing Then stream = Nothing
  213. End Sub
  214.