Imports System
Imports System.Net
Imports Microsoft.VisualBasic.Interaction
Imports System.Diagnostics
Public Class ClipboardFusionHelper
Public Shared Function ProcessText(text As String) As String
Dim url as String = text
If Not DoesURLExists(text) Then
url = "http://www.google.com/search?q={0}"
url = String.Format(url, text.Replace(" "c, "+"c))
End If
Process.Start(url)
Return text
End Function
Public Shared Function UrlIsValid(ByVal url As String) As Boolean
Dim is_valid As Boolean = False
If url.ToLower().StartsWith("www.") Then url = _
"http://" & url
Dim web_response As HttpWebResponse = Nothing
Try
Dim web_request As HttpWebRequest = _
HttpWebRequest.Create(url)
web_response = _
DirectCast(web_request.GetResponse(), _
HttpWebResponse)
Return True
Catch ex As Exception
Return False
Finally
If Not (web_response Is Nothing) Then _
web_response.Close()
End Try
End Function
Public Shared Function URLExists(ByVal url As String) As Boolean
Try
Dim Request As Object
Dim ff As Integer
Dim rc As Object
Request = CreateObject(url)
With Request
.Open("GET", url, False)
.Send()
rc = .StatusText
End With
Request = Nothing
If rc = "OK" Then URLExists = True
EndNow:
return URLExists
Catch ex As Exception
return false
End Try
End Function
Public Shared Function DoesURLExists(ByVal url As String) As Boolean
Dim responsea as Boolean = false
Try
Dim webRequest As System.Net.WebRequest = System.Net.WebRequest.Create(url)
webRequest.Method = "HEAD"
Dim response As System.Net.HttpWebResponse = CType(webRequest.GetResponse, System.Net.HttpWebResponse)
If (response.StatusCode.ToString = "OK") Then
responsea = true
End If
Catch ex As Exception
Return responsea
End Try
return responsea
End Function
End Class