Hi,

I am trying to hide an external application using API in windows forms. I tried the following code but it does not work. Can someone help?

Thanks.

 

    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Const SW_HIDE As Integer = 0
    Const SW_SHOW As Integer = 5

 

    Private Sub test_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim GetHandle As Long
        Dim retVal As Long

        GetHandle = FindWindow(vbNullString, "Untitled - Notepad")
        'retVal = ShowWindow(GetHandle, SW_SHOW)
        'AppActivate("Untitled - Notepad")


        retVal = ShowWindow(GetHandle, SW_HIDE)
    End Sub