无法隐藏进程
我想启动 calc.exe 并隐藏它
但只能启动exex但无法隐藏
我的代码有什么错误??
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
i want to start calc.exe and hide it
but only can start the exex but cant hide
what error in my code??
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下代码应该使用托管代码执行您想要的操作,但是当我使用 calc 尝试它时,它不会开始隐藏或最小化(其他 exe 按预期工作,所以它可能是 calc 特有的东西?)
The following code should do what you want using managed code, but when I tried it using calc it would not start hidden or minimized (other exe's worked as expected so it may be something peculiar with calc?)
我不久前做了一个适用于任何进程的代码片段,是两个通用函数,并且还具有递归模式并且易于使用:
I did time ago a snippet which works with any proccess, are two generic functions and also has recursive mode and is easy to use: