Results 1 to 1 of 1

Thread: Send params to DosBox

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Send params to DosBox

    Hi,

    This is the code I wrote to automate the loading of a game, etc in Dosbox without having to manually edit the config file or enter the lines in to Dosbox each time.

    vb Code:
    1. 'Date: 09\06/2012
    2.      'Description: Automatically load game in Dosbox
    3.      'Author: Nightwalker83
    4.      'Version: 1.0
    5.      'Website: http://aaronspehr.net/
    6.         Option Explicit
    7.         Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    8.          
    9.         Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    10.         Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
    11.         Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    12.          
    13.         Private Const SYNCHRONIZE = &H100000
    14.         Private Const INFINITE = -1&
    15.          Dim ff As Integer
    16.         ' Start the indicated program and wait for it
    17.         ' to finish, hiding while we wait.
    18.         Private Sub ShellAndWait(ByVal program_name As String)
    19.         Dim process_id As Long
    20.         Dim process_handle As Long
    21.          
    22.             ' Start the program.
    23.             On Error GoTo ShellError
    24.             process_id = Shell(program_name, vbNormalFocus)
    25.             On Error GoTo 0
    26.          
    27.             ' Hide.
    28.             Me.Visible = False
    29.             DoEvents
    30.          
    31.             ' Wait for the program to finish.
    32.             ' Get the process handle.
    33.             process_handle = OpenProcess(SYNCHRONIZE, 0, process_id)
    34.             If process_handle <> 0 Then
    35.                 WaitForSingleObject process_handle, INFINITE
    36.                 CloseHandle process_handle
    37.             End If
    38.          
    39.             ' Reappear.
    40.             Me.Visible = True
    41.             Exit Sub
    42.          
    43. ShellError:
    44.             MsgBox "Error running '" & program_name & _
    45.                 "'" & vbCrLf & Err.Description
    46.         End Sub
    47.        
    48.         Private Sub Command1_Click()
    49.          commands
    50.          loadDosbox
    51.         End Sub
    52.      
    53.     Private Sub commands()
    54.     ff = FreeFile
    55.     Open "C:\Users\Aaron\AppData\Local\DOSBox\" & "dosbox-0.74.conf" For Append As #ff
    56.     Print #ff, "mount c e:\dosgames -freesize 1000"
    57.     Print #ff, "mount d e:\dosgames\dfcd -t cdrom -label Daggerfall"
    58.     Print #ff, "d:"
    59.     Print #ff, "install"
    60.     Print #ff, "mount c e:\dosgames -freesize 1000"
    61.     Print #ff, "mount d c:\dosgames\dfcd -t cdrom -label Daggerfall"
    62.     Print #ff, "c:"
    63.     Print #ff, "cd/dagger"
    64.     Print #ff, "dagger"
    65.     Close #ff
    66.     End Sub
    67.      
    68.     Private Sub loadDosbox()
    69.     Dim sYourCommand As String
    70.     sYourCommand = """" & "C:\Program Files (x86)\DOSBox-0.74\DOSBox.exe"
    71.           ShellAndWait sYourCommand
    72.     End Sub

    Edit:

    To use just make sure you open the config file in the above location via the "DOSBox 0.74 Options" bat file.


    Nightwalker
    Last edited by Nightwalker83; Jun 9th, 2012 at 03:36 AM. Reason: Fixed spelling!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width