The NEW Build Your Own Arcade Controls

Main => Software Forum => Topic started by: danpomeroy on November 19, 2007, 05:44:23 pm

Title: VB Developers question
Post by: danpomeroy on November 19, 2007, 05:44:23 pm
I can shell out to MAME but when I add the rom name it won't load. With no rom name, mame loads but says there are no roms even though there is. Any Ideas?

VB2005
Title: Re: VB Developers question
Post by: SGT on November 19, 2007, 06:34:48 pm
Its a working directory problem.  Before shelling out, use CHDRIVE and CHDIR to the directory where mame is located.   That way, MAME can find the MAME.INI file (if it exists) and the ROMS folder.

Code: [Select]
    ChDrive ("e:")
    ChDir ("\emulators\mame")
    Shell ("mame.exe pacman")
Title: Re: VB Developers question
Post by: headkaze on November 19, 2007, 07:03:28 pm
This is VB 2005 though. So you really want to use the System.Diagnostics.Process namespace.

Code: [Select]
Private Sub LaunchGame(ByVal GameName As String)
   Dim myProcess As Process = New Process
   AddHandler myProcess.Exited, AddressOf MameExited
   myProcess.StartInfo.WorkingDirectory = "E:\Emulators\Mame"
   myProcess.StartInfo.FileName = "E:\Emulators\Mame\Mame.exe"
   myProcess.StartInfo.Arguments = GameName
   myProcess.StartInfo.CreateNoWindow = True
   myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
   myProcess.EnableRaisingEvents = True
   myProcess.Start()
End Sub

Private Sub MameExited(ByVal sender As Object, ByVal e As System.EventArgs)
   MessageBox.Show("Mame exited!")
End Sub
Title: Re: VB Developers question
Post by: SGT on November 19, 2007, 07:43:08 pm
What is the advantage?
Title: Re: VB Developers question
Post by: headkaze on November 19, 2007, 08:46:26 pm
What is the advantage?

No great advantage, but Process is a handy namespace to get used to working with. It can tell you when a process has exited and hide the Command Line window for example. It gives you more control over the legacy Shell() method from VB6. It's really just the standard way to launch a process using VB.NET, but you get the same result in the end I guess ;)