できた
Public Class Form1

  Private sw As System.IO.StreamWriter

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

    Try
      sw = New System.IO.StreamWriter("\\共有PC\共有フォルダ\lockfile.txt", False, System.Text.Encoding.GetEncoding(932))
    Catch ex As Exception
      MsgBox("他の人が使ってますお")
      Application.Exit()
    End Try

  End Sub

  Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
    Try
      sw.Close()
    Catch ex As Exception
    End Try
  End Sub

End Class