INVOCAR AL DISEÑADOR DESDE UN SEGUNDO HILO DE EJECUCIÓN

Public Delegate Sub changeIconStatusInvoker(index As Integer)

Private WithEvents changeIconStatusWorker As System.ComponentModel.BackgroundWorker

'Cambiamos el icono en el campo correspondiente de la fila de un datagridview (dgUsers), segun el valor del campo status

Private Sub changeIconStatusWorkerWorker_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles changeIconStatusWorker.DoWork
       
     Dim d As New changeIconStatusInvoker(AddressOf Me.changeIcon)
     For i As Integer = 0 To dgUsers.RowCount - 1

           Me.Invoke(d, New Object() {i}) 
            
     Next

 End Sub

 Function changeIcon(index As Integer) As Boolean
     
     If dgUsers("statusID", index).Value = "1" Then
        dgUsers("status", index).Value = My.Resources.chat_on
     Else
        dgUsers("status", index).Value = My.Resources.chat_off
     End If
           
     Return True


 End Function

DESCARGAR IMAGEN

Function DownloadImage(_URL As String) As Image

        Dim _tmpImage As Image = Nothing

        Try

            Dim _HttpWebRequest As System.Net.HttpWebRequest = CType(System.Net.HttpWebRequest.Create(_URL), System.Net.HttpWebRequest)
            _HttpWebRequest.AllowWriteStreamBuffering = True

            _HttpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)"
            _HttpWebRequest.Referer = "http://www.google.com/"

            _HttpWebRequest.Timeout = 20000


            Dim _WebResponse As System.Net.WebResponse = _HttpWebRequest.GetResponse()
            Dim _WebStream As System.IO.Stream = _WebResponse.GetResponseStream()


            _tmpImage = Image.FromStream(_WebStream)

            _WebResponse.Close()
            _WebStream.Close()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        Return _tmpImage
    End Function


CREAR ENTRADA EN EL REGISTRO

'HKEY_LOCAL_MACHINE
Function createRegistryKey_LocalMachine(KeyName As String, valueName As String, value As String) As Boolean

        Try
            Dim ExistKey As String = Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\" & KeyName, valueName, "Not Exist")

            If ExistKey = "Not Exist" Then
                Dim key As Microsoft.Win32.RegistryKey
                key = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION")
                key.SetValue(valueName, value, Microsoft.Win32.RegistryValueKind.DWord)
                key.Close()

                Return True
            Else
                Return False
            End If

        Catch ex As Exception
            Return False
        End Try


    End Function


createRegistryKey_LocalMachine("Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", "miAplicacion.exe", "8888")
createRegistryKey_LocalMachine("SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", "miAplicacion.exe", "8888")

EXTRAER CONTENIDO (TEXTO) DE UN ARCHIVO PDF (con iTextSharp.dll)

Dim oReader As New iTextSharp.text.pdf.PdfReader(PdfFileName)
Dim its As New iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy

DocumentText = iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(oReader, 1, its)


oReader.Close()

'http://sourceforge.net/projects/itextsharp/

MOSTRAR TECLADO VIRTUAL (tabtip.exe)

Private TabTipProcess As Process
Private Sub closeTabTip()
   If tdbConfig.enableVirtualKeyboard Then
      If Me.TabTipProcess IsNot Nothing AndAlso Me.TabTipProcess.HasExited Then
          TabTipProcess.Close()
      End If
    End If
End Sub

Private Sub openTabTip()
  If tdbConfig.enableVirtualKeyboard Then
     Dim progFiles As String = "C:\Program Files\Common Files\Microsoft Shared\ink"
     Dim onScreenKeyboardPath As String = System.IO.Path.Combine(progFiles, "TabTip.exe")
     Me.TabTipProcess = Process.Start(onScreenKeyboardPath)     
  End If

End Sub

DETECTAR ROTACIÓN PANTALLA

Inherits System.Windows.Forms.Form

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

        AddHandler Microsoft.Win32.SystemEvents.DisplaySettingsChanged,
      AddressOf DetectScreenRotation

End Sub

Public Sub DetectScreenRotation(ByVal sender As System.Object,
      ByVal e As System.EventArgs)
        Dim theScreenBounds As Rectangle
        theScreenBounds = Screen.GetBounds(Screen.PrimaryScreen.Bounds)

        If (theScreenBounds.Height > theScreenBounds.Width) Then
           'acción para pantalla en horizontal
         Else
           'acción para pantalla en vertical
        End If
    End Sub
  

End Class