【问题标题】:how to hide/unhide window by process name or processid using VB.NET?如何使用 VB.NET 按进程名称或进程 ID 隐藏/取消隐藏窗口?
【发布时间】:2014-01-28 16:48:42
【问题描述】:

我试图通过名称或 PID 隐藏/取消隐藏窗口进程,我尝试过

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As ShowWindowCommands) As Boolean

结束函数

但是ShowWindowCommands 是什么以及如何找到它?

谢谢!

【问题讨论】:

    标签: vb.net process window


    【解决方案1】:

    有很多方法可以做到这一点,最简单的应该是这个:

    '一般导入

    Imports System.Runtime.InteropServices
    

    '表格类声明

      <DllImport("user32.dll")> _
    Private Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
    End Function
    

    '那么如果你想隐藏firefox'swindow:

     Dim mywindow As Integer
        Dim processRunning As Process() = Process.GetProcesses()
        For Each pr As Process In processRunning
            If pr.ProcessName = "Firefox" Then
                mywindow = pr.MainWindowHandle.ToInt32()
                ShowWindow(mywindow , 0)
            End If
        Next
    

    【讨论】:

    • 如果 showWindow(myWindow,0) 是一种隐藏方式,如何让它正常显示?它只是将 0 更改为 1 吗? @K3rnel31
    【解决方案2】:

    你可以这样做:

    Form.FromHandle(Process.GetProcessById(PID).MainWindowHandle).Show()
    

    【讨论】:

    • @K3rnel31 你是对的。由于问题没有提及,我认为它是应用程序中的本地表单。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-03
    • 1970-01-01
    • 1970-01-01
    • 2010-10-21
    相关资源
    最近更新 更多