-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
executable file
·299 lines (275 loc) · 11.5 KB
/
Form1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
Imports Microsoft.Win32
Imports Microsoft.Win32.Registry
Imports System.runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
Public Class NetSend
Public Function Sende(ByVal SendeAn As String, _
ByVal SendeNachricht As String) As Integer
Return NetMessageBufferSend(Nothing, SendeAn, Nothing, _
SendeNachricht, SendeNachricht.Length * 2 + 2)
End Function
<DllImportAttribute("Netapi32", CharSet:=CharSet.Unicode)> _
Public Shared Function NetMessageBufferSend(ByVal servername As String, _
ByVal msgname As String, ByVal fromname As String, ByVal buf As String, _
ByVal buflen As Integer) As Integer
End Function
End Class
#Region " Vom Windows Form Designer generierter Code "
Public Sub New()
MyBase.New()
' Dieser Aufruf ist für den Windows Form-Designer erforderlich.
InitializeComponent()
' Initialisierungen nach dem Aufruf InitializeComponent() hinzufügen
End Sub
' Die Form überschreibt den Löschvorgang der Basisklasse, um Komponenten zu bereinigen.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
' Für Windows Form-Designer erforderlich
Private components As System.ComponentModel.IContainer
'HINWEIS: Die folgende Prozedur ist für den Windows Form-Designer erforderlich
'Sie kann mit dem Windows Form-Designer modifiziert werden.
'Verwenden Sie nicht den Code-Editor zur Bearbeitung.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents txtsender As System.Windows.Forms.TextBox
Friend WithEvents txtnachricht As System.Windows.Forms.TextBox
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents txtanzahl As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents chkcheck As System.Windows.Forms.CheckBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.txtsender = New System.Windows.Forms.TextBox
Me.txtnachricht = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.Label3 = New System.Windows.Forms.Label
Me.txtanzahl = New System.Windows.Forms.TextBox
Me.Label4 = New System.Windows.Forms.Label
Me.chkcheck = New System.Windows.Forms.CheckBox
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 24)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Empfänger:"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(8, 72)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(72, 24)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Nachricht:"
'
'txtsender
'
Me.txtsender.BackColor = System.Drawing.Color.Silver
Me.txtsender.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.txtsender.Location = New System.Drawing.Point(80, 16)
Me.txtsender.Name = "txtsender"
Me.txtsender.Size = New System.Drawing.Size(272, 20)
Me.txtsender.TabIndex = 2
Me.txtsender.Text = ""
'
'txtnachricht
'
Me.txtnachricht.BackColor = System.Drawing.Color.Silver
Me.txtnachricht.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.txtnachricht.Location = New System.Drawing.Point(80, 64)
Me.txtnachricht.Multiline = True
Me.txtnachricht.Name = "txtnachricht"
Me.txtnachricht.Size = New System.Drawing.Size(272, 192)
Me.txtnachricht.TabIndex = 3
Me.txtnachricht.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(368, 16)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(64, 24)
Me.Button1.TabIndex = 4
Me.Button1.Text = "Optionen"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(368, 40)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(64, 24)
Me.Button2.TabIndex = 5
Me.Button2.Text = "Info"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(368, 208)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(64, 24)
Me.Button3.TabIndex = 6
Me.Button3.Text = "Senden"
'
'Label3
'
Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label3.Location = New System.Drawing.Point(372, 282)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(72, 16)
Me.Label3.TabIndex = 7
Me.Label3.Text = "{ schließen }"
'
'txtanzahl
'
Me.txtanzahl.BackColor = System.Drawing.Color.Silver
Me.txtanzahl.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.txtanzahl.ForeColor = System.Drawing.Color.Black
Me.txtanzahl.Location = New System.Drawing.Point(408, 240)
Me.txtanzahl.MaxLength = 2
Me.txtanzahl.Name = "txtanzahl"
Me.txtanzahl.Size = New System.Drawing.Size(24, 20)
Me.txtanzahl.TabIndex = 8
Me.txtanzahl.Text = "1"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(360, 240)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(48, 16)
Me.Label4.TabIndex = 9
Me.Label4.Text = "Anzahl:"
'
'chkcheck
'
Me.chkcheck.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.chkcheck.Location = New System.Drawing.Point(80, 264)
Me.chkcheck.Name = "chkcheck"
Me.chkcheck.Size = New System.Drawing.Size(176, 16)
Me.chkcheck.TabIndex = 10
Me.chkcheck.Text = "Benachrichtigung"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.Silver
Me.ClientSize = New System.Drawing.Size(442, 296)
Me.ControlBox = False
Me.Controls.Add(Me.chkcheck)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.txtanzahl)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.txtnachricht)
Me.Controls.Add(Me.txtsender)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.Text = " Advanced Net Sender"
Me.ResumeLayout(False)
End Sub
#End Region
Dim reg As RegistryKey
Public Sub check_registry()
reg = LocalMachine.OpenSubKey("Software", True)
If reg.OpenSubKey("Adv Sender", True) Is Nothing Then
reg.CreateSubKey("Adv Sender")
Else
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
check_registry()
reg = LocalMachine.OpenSubKey("Software\Adv Sender", True)
On Error Resume Next
If reg.GetValue("Checkit") = "true" Then
Me.chkcheck.Checked = True
Else
Me.chkcheck.Checked = False
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
write_registry()
Dim frm2 As New Form2
frm2.frm = Me
frm2.ShowDialog()
End Sub
Public Sub write_registry()
reg = LocalMachine.OpenSubKey("Software\Adv Sender", True)
reg.SetValue("top", Me.Top)
reg.SetValue("left", Me.Left)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MessageBox.Show("Um an gespeicherte Computernamen Nachrichten zu senden, müssen sie mit einem Slash beginnen" & vbCrLf & _
"z.B.: /localhost")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
reg = LocalMachine.OpenSubKey("Software\Adv Sender\computers", True)
Dim sAdresse As String
Dim Message As New NetSend
Dim erg As Integer
If Me.txtsender.Text.StartsWith("/") Then
sAdresse = Me.txtsender.Text.Replace("/", "")
' Nachricht übermiiteln
If Me.txtanzahl.Text <= "1" Then
erg = Message.Sende(reg.GetValue(sAdresse), Me.txtnachricht.Text)
Else
Dim i As Integer
i = 0
Do Until i = Me.txtanzahl.Text
erg = Message.Sende(reg.GetValue(sAdresse), Me.txtnachricht.Text)
i = i + 1
Loop
End If
Else
If Me.txtanzahl.Text <= "1" Then
erg = Message.Sende(Me.txtsender.Text, Me.txtnachricht.Text)
Else
Dim i As Integer
i = 0
Do Until i = Me.txtanzahl.Text
erg = Message.Sende(Me.txtsender.Text, Me.txtnachricht.Text)
i = i + 1
Loop
End If
End If
' Checken ob nachricht verschickt wurde!
If Me.chkcheck.Checked = True Then
If erg = 0 Then
MessageBox.Show("Nachricht erfolgreich übermittelt", "Übermittlung OK", _
MessageBoxButtons.OK, MessageBoxIcon.None)
Else
MessageBox.Show("Fehler: " & erg, "Keine Nachricht gesendet!", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Else
End If
End Sub
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
Me.Close()
End
End Sub
Private Sub chkcheck_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkcheck.CheckedChanged
reg = LocalMachine.OpenSubKey("Software\Adv Sender", True)
If Me.chkcheck.Checked = True Then
reg.SetValue("Checkit", "true")
Else
reg.SetValue("Checkit", "false")
End If
End Sub
End Class