Worrow Posted March 2, 2005 Posted March 2, 2005 I am trying to write a small frontend for MAME. Here is the code I use to start MAME: Dim startInfo As New ProcessStartInfo("j:\mame\mame.exe") startInfo.Arguments = ListBox1.SelectedItem 'game name here. startInfo.UseShellExecute = True Process.Start(startInfo) The problem is right after MAME loading the game it just closes the window, but my frontend remains. :confused: Is there anyway to around this problem. Or is there any other ways to do the same thing? Thanks in advance. Quote
Leaders dynamic_sysop Posted March 2, 2005 Leaders Posted March 2, 2005 To start a process and keep track of the process, you need to declare a new instance of it , eg: Dim info As New ProcessStartInfo("iexplore.exe") info.UseShellExecute = True info.Arguments = "http://msn.co.uk" '/// carry out any additional arguments, eg: navigate to a webpage in this case Dim proc As New Process '/// create a new instance of the Process Class proc.StartInfo = info proc.Start() if you are using a Console Application and it's dissapearing after a process has started, you can add ' Console.ReadLine() ' after the code that starts the process. ( if you wish to keep the Console window open that is ) Quote
HJB417 Posted March 2, 2005 Posted March 2, 2005 Maybe you should invoke Process.WaitForExit after your call to Process.Start. Quote
Worrow Posted March 3, 2005 Author Posted March 3, 2005 I have tried the both methods but it seems like MAME quit itself right after finish loading the game. Quote
HJB417 Posted March 3, 2005 Posted March 3, 2005 I'm guessing it started another process and you would need to call WaitForExit on it. Quote
Worrow Posted March 3, 2005 Author Posted March 3, 2005 Here is the new code: Dim startInfo As New ProcessStartInfo("j:\mame\mame.exe") Dim proc As New Process startInfo.Arguments = ListBox1.SelectedItem startInfo.UseShellExecute = True proc.Start(startInfo).WaitForExit() The result is the same. It quits after it loaded the game. Quote
*Experts* Nerseus Posted March 3, 2005 *Experts* Posted March 3, 2005 I'm guessing that you need to set a "startup folder" for the process. Meaning, your program isn't running from "j:\mame" so you need to tell mame to run from that folder. When MAME starts up, it's trying to locate other files in YOUR program's folder rather than in "j:\mame" and it's "crashing" out. Note: I see that you're providing the full path to the EXE, but that's not the same as "the folder where the program is running from". -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Worrow Posted March 3, 2005 Author Posted March 3, 2005 It works!! Thanks, Nerseus :D Thank you! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.