01.
Imports
System.Net
02.
Imports
System.IO
03.
Public
Class
Form1
04.
05.
WithEvents
webclient1
As
New
WebClient
06.
07.
WithEvents
webclient2
As
New
WebClient
08.
Dim
oWrite
As
IO.StreamWriter
09.
11.
Dim
LocalPro
As
String
=
"C:12"
12.
Dim
iniPro
As
String
=
"C:\ver.ini"
14.
Dim
Proname
As
String
=
"12.exe"
15.
16.
17.
Private
Sub
Form1_Load(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
18.
Dim
chkIPaddress
As
New
Threading.Thread(
AddressOf
chkUpdate)
19.
CheckForIllegalCrossThreadCalls =
False
20.
chkIPaddress.Start()
21.
End
Sub
22.
Private
Sub
webclient2_DownloadProgressChanged(
ByVal
sender
As
Object
,
ByVal
e
As
System.Net.DownloadProgressChangedEventArgs)
Handles
webclient2.DownloadProgressChanged
23.
ProgressBar1.Maximum = e.TotalBytesToReceive
24.
ProgressBar1.Value = e.BytesReceived
25.
26.
Label2.Text = e.ProgressPercentage &
" %"
27.
End
Sub
28.
Private
Sub
webclient2_DownloadFileCompleted(
ByVal
sender
As
Object
,
ByVal
e
As
System.ComponentModel.AsyncCompletedEventArgs)
Handles
webclient2.DownloadFileCompleted
29.
30.
Process.Start(
"GOM.exe"
)
31.
Me
.Close()
32.
End
Sub
33.
34.
Private
Sub
chkUpdate()
35.
36.
Dim
versionpro
As
String
= webclient1.DownloadString(iniPro)
37.
38.
Dim
versionsite
As
String
= webclient1.DownloadString(iniServer)
39.
40.
41.
If
versionsite <> versionpro
Then
42.
43.
44.
46.
47.
48.
oWrite =
New
IO.StreamWriter(iniPro)
49.
50.
oWrite.Write(versionsite)
51.
oWrite.Close()
52.
53.
Else
54.
55.
Label2.Text =
"เวอร์ชั่นล่าสุดแล้ว"
56.
Process.Start(
"GOM.exe"
)
57.
Me
.Close()
58.
End
If
59.
End
Sub
60.
End
Class