-
Notifications
You must be signed in to change notification settings - Fork 1
/
CreateListInfoXMLfromMAME.vb
63 lines (57 loc) · 1.93 KB
/
CreateListInfoXMLfromMAME.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Public Class CreateListInfoXMLfromMAME
Private p_MAME_EXE_Path As String
Private p_MAME_XML_Path As String
Public Property CMDArguments As String = "-listxml"
Public Property MAME_EXE_Path As String
Get
Return p_MAME_EXE_Path
End Get
Set(value As String)
If System.IO.File.Exists(value) Then
p_MAME_EXE_Path = value
Else
p_MAME_EXE_Path = ""
End If
End Set
End Property
Public Property MAME_XML_Path As String
Get
Return p_MAME_XML_Path
End Get
Set(value As String)
p_MAME_XML_Path = value
End Set
End Property
Public Function GenerateXML() As Integer
If System.IO.File.Exists(MAME_EXE_Path) Then
Try
Dim CMD As New Process
Dim SW As IO.StreamWriter
Dim SR As IO.StreamReader
CMD.StartInfo.FileName = MAME_EXE_Path
CMD.StartInfo.Arguments = CMDArguments
CMD.StartInfo.UseShellExecute = False
CMD.StartInfo.WorkingDirectory = IO.Path.GetDirectoryName(MAME_EXE_Path)
CMD.StartInfo.RedirectStandardInput = True
CMD.StartInfo.RedirectStandardOutput = True
CMD.StartInfo.CreateNoWindow = True
CMD.Start()
SW = CMD.StandardInput
SR = CMD.StandardOutput
CMD.Dispose()
Dim StreamWriter As New IO.StreamWriter(MAME_XML_Path)
StreamWriter.Write(SR.ReadToEnd())
StreamWriter.Flush()
StreamWriter.Close()
StreamWriter.Dispose()
SW.Dispose()
SR.Dispose()
Return 0
Catch
Return -2
End Try
Else
Return -1
End If
End Function
End Class