ShellExecute的返回值不是真正的句柄,msdn上ShellExecute的文档里写了:The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however. It can be cast only to an int and compared to either 32 or the following error codes below.如果用ShellExecuteEx,那里面的hProcess应该对应Process的Handle
或者说用ShellExecute开启一段exe程序,然后用什么函数可以关闭这个exe程序?
可以用ShellExecuteEx,它可以返回进程的句柄,然后就能使用各种方式kill了
多谢了,正接触微软的C#,不懂的太多。
Process p = Process.Start(ps);p.Kill();
你在启动进程的时候就保留这个句柄,然后kill的时候就可以直接用了
而不是启动的时候将它丢弃,然后要kill的时候想破头的去找