|
-
July 9th, 2009, 10:32 PM
#1
[RESOLVED] Process Closes On Open, Doesn't Trigger Process.Exit
Alright, so I made a process to start a 3D game (Worms 4: Mayhem). I first tried it in a console application, and it started the process, and then it got closed. I thought it was just because I was ina console application, so I tried it in a WinApp. Same result.
I also tried pre-pending an "explorer.exe" to the games .exe file (in the process' path string), so explorer would actually run it instead of my program. Again, same result. Also, it doesn't trigger the Process.Exit event.
Does it have to do with the fact that it's a 3D game with DirectX and stuff?
Can I get some help or maybe some workaround? I can't really have a modding editor/program if I can't run the main game.
-
July 9th, 2009, 10:46 PM
#2
Re: Process Closes On Open, Doesn't Trigger Process.Exit
Well, your video game would be in a constant loop, so you must be doing something to exit the application. A WinForms application closes when the main form closes or if you do it programmatically. Not much else to say without seeing some code.
-
July 9th, 2009, 11:07 PM
#3
Re: Process Closes On Open, Doesn't Trigger Process.Exit
Oh, I got it fixed.
I used a using block, and everything fine now.
Code:
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WorkingDirectory = "Path/To/Game"
startInfo.FileName = "Worms 4 Mayhem.exe";
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
// Log error.
}
This works.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|