这是我的代码:
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();
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,那个游戏.MainWindowHandle总是IntPtr.Zero.我需要找到运行过程的IntPtr以确认游戏是由启动器启动的,所以我让游戏发送它的IntPtr并让启动器响应它是否正常.但为此,我必须具体了解运行过程的IntPtr.
提前致谢!