Main > Software Forum

VB Developers question

(1/1)

danpomeroy:
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

SGT:
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: ---    ChDrive ("e:")
    ChDir ("\emulators\mame")
    Shell ("mame.exe pacman")
--- End code ---

headkaze:
This is VB 2005 though. So you really want to use the System.Diagnostics.Process namespace.


--- Code: ---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
--- End code ---

SGT:
What is the advantage?

headkaze:

--- Quote from: SGT on November 19, 2007, 07:43:08 pm ---What is the advantage?

--- End quote ---

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 ;)

Navigation

[0] Message Index

Go to full version