投稿者 nin  (社会人) 投稿日時 2013/11/22 21:22:06
時間ないので、コードのみ
idパスワードを記述したファイル(コンマ区切り)をサーバに配置
ダウンロードしたら消去しています
厳密をきするなら、暗号化する必要があります

 Dim kidousasenai As Boolean
    Dim idd(1, 100) As String
    Dim count As Integer = 0
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim i As Integer
        If kidousasenai Then MsgBox("最新バージョンが存在する為起動できません") : Exit Sub

        For i = 0 To count - 1

            If TextBox1.Text = idd(0, i) Then
                If TextBox2.Text = idd(1, i) Then
                    Form2.Show()
                    Me.Hide()
                    Exit Sub
                End If

            End If

        Next i
        MsgBox("id又はパスワードが異なっています")

    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'httpで、ファイルをダウンロード
        Dim wci As New System.Net.WebClient()
        Dim wcp As New System.Net.WebClient()
        Try
            wci.DownloadFile("http://192.168.123.202/test/version.txt", Application.StartupPath + "\version.txt")
            wcp.DownloadFile("http://192.168.123.202/test/id.csv", Application.StartupPath + "\id.csv")
        Catch
            MsgBox("ダウンロードエラーです")
        End Try

        wci.Dispose()
        wcp.Dispose()

        'バージョン確認処理
        If System.IO.File.Exists(Application.StartupPath + "\version.txt") Then
            Dim Reader As New IO.StreamReader(Application.StartupPath + "\version.txt")
            Dim version As Integer = Reader.ReadLine
            Reader.Close()

            If version > 2 Then
                MsgBox("最新バージョンが存在します")
                kidousasenai = True
            End If
        Else
            MsgBox("ファイルが存在しません")
        End If


        'id情報を読み出して配列に格納
        If System.IO.File.Exists(Application.StartupPath + "\id.csv") Then

            Dim Reader As New IO.StreamReader(Application.StartupPath + "\id.csv")
            'CSVの各項目を表す配列
            Dim Line As String = Reader.ReadLine 'CSVの一行
            Dim Items() As String
            '読出し
            Do Until IsNothing(Line)

                Items = Line.Split(",")                   '一行を
                idd(0, count) = Items(0)
                idd(1, count) = Items(1)
                count = count + 1
                Line = Reader.ReadLine                    '次の行を読み込む。
            Loop

            Reader.Close()

            ' System.IO.File.Delete(Application.StartupPath + "\id.csv")

        Else
            MessageBox.Show("ファイルが存在しません")
        End If



    End Sub