Restore minimized window from vb.net

    Private Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal nCmdShow As Int32) As Boolean

    Enum SW As Int32
        Hide = 0
        Normal = 1
        ShowMinimized = 2
        ShowMaximized = 3
        ShowNoActivate = 4
        Show = 5
        Minimize = 6
        ShowMinNoActive = 7
        ShowNA = 8
        Restore = 9
        ShowDefault = 10
        ForceMinimize = 11
        Max = 11
    End Enum

    'Usage
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles Button1.Click

        Dim hWnd As IntPtr = Process.GetProcessById(12345).MainWindowHandle
        ShowWindow(hWnd, SW.Restore)

    End Sub

Get only Foreground processes

        Dim processes() As Process
        processes = Process.GetProcesses()
        For Each p As Process In processes
            If Not p.MainWindowHandle = 0 Then
                'p is a foreground process
                'do anything with p here.
            End If
        Next

Set EXE parent to Form

Original Post by Martin Xie

     Public Shared Function SetParent(ByVal instr As IntPtr, ByVal outstr As IntPtr) As IntPtr

    End Function

    Private Sub startProcess()
        Dim p As Process
        p = Process.Start("notepad.exe")
        Threading.Thread.Sleep(100)
        SetParent(p.MainWindowHandle, Me.Handle)
        Application.DoEvents()
    End Sub