这是我的代码:
using (Process game = Process.Start(new ProcessStartInfo() {
FileName="DatabaseCheck.exe",
RedirectStandardOutput = true,
CreateNoWindow = true,
UseShellExecute = false }))
{
lblLoad.Text = "Loading";
int Switch = 0;
while (game.MainWindowHandle == IntPtr.Zero)
{
Switch++;
if (Switch % 1000 == 0)
{
lblLoad.Text += ".";
if (lblLoad.Text.Contains("...."))
lblLoad.Text = "Loading.";
lblLoad.Update();
game.Refresh();
}
}
问题是,game.MainWindowHandle 总是 IntPtr.Zero。我需要找到运行过程的IntPtr来确认游戏是由启动器启动的,所以我让游戏发送它是IntPtr,如果没问题让启动器响应。但为此,我必须具体了解运行进程的 IntPtr。
提前致谢!