【发布时间】:2011-09-09 18:41:58
【问题描述】:
我想启动 calc.exe 并隐藏它
但只能启动exe不能隐藏
我的代码有什么错误??
Imports System.Runtime.InteropServices
Imports System.IntPtr
Public Class Form1
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function ShowWindowAsync(ByVal hwnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As IntPtr = Process.GetProcessesByName("Calc")(0).Id
ShowWindowAsync(a, 0)
End Sub
End Class
【问题讨论】:
-
你甚至没有开始这个过程。显然,您只是尝试搜索现有流程并尝试显示。您应该开始一个新进程,获取窗口的 句柄(可能通过
MainWindowHandle属性),然后将该句柄传递给ShowWindow[Async]()函数。 -
我试过 a=process.start("calc").handle 之后我将 a 传递给 showwindows,但它仍然没有工作。它只能运行calc,但不能隐藏它
-
隐藏 calc.exe 应用程序的目的是什么?为什么要隐藏它?如果它被隐藏了,任何人将如何使用该应用程序