Type DataBuffer
    Code As Integer
    ReturnValue As Double
End Type

Global Const BufferSize = 10

Type DosApHandle
    ToDosHandle As Long
    FromDosHandle As Long
    WindowsTask As Integer
    DosInstance As Integer
    DosIsDead As Integer
    UnusedPointer As Long
End Type

Global DosAp As DosApHandle

Global Const ERROR_FILE_NOT_FOUND = 2
Global Const ERROR_ACCESS_DENIED = 5
Global Const ERROR_INVALID_HANDLE = 6
Global Const ERROR_REQ_NOT_ACCEP = 71
Global Const ERROR_ALREADY_ASSIGNED = 85
Global Const ERROR_BROKEN_PIPE = 109
Global Const ERROR_OPEN_FAILED = 110
Global Const ERROR_PIPE_NOT_CONNECTED = 233
Global Const ERROR_CANNOT_COPY = 266
Global Const ERROR_INVALID_MESSAGE = 1002
Global Const ERROR_REGISTRY_IO_FAILED = 1016
Global Const ERROR_INVALID_BLOCK_LENGTH = 1106
Global Const ERROR_DLL_INIT_FAILED = 1114

Global Const SW_HIDE = 0
Global Const SW_SHOWMINIMIZED = 2

Declare Function LoadDosAp Lib "winside.dll" (ByVal DosApName As String, DosAp As DosApHandle, ByVal ShowWindow As Integer, ByVal QueueSize As Integer) As Long

Declare Function DebugDosAp Lib "winside.dll" (ByVal Debugger As String, ByVal DosApName As String, DosAp As DosApHandle, ByVal QueueSize As Integer) As Long

Declare Function SendToDos Lib "winside.dll" (DosApPtr As DosApHandle, DataPtr As Any, ByVal DataCount As Integer) As Long

Declare Function SendStringToDos Lib "winside.dll" (DosApPtr As DosApHandle, ByVal MessageString As String) As Long

Declare Function SendStrucAndStringToDos Lib "winside.dll" (DosApPtr As DosApHandle, DataPtr As Any, ByVal DataCount As Integer, MessageString As Any) As Long

Declare Function GetFromDos Lib "winside.dll" (DosApPtr As DosApHandle, DataPtr As Any, ByVal DataCount As Integer, RetLength As Long) As Long

Declare Function GetStringFromDos Lib "winside.dll" (DosApPtr As DosApHandle, MessageString As Any) As Long

Declare Function UnloadDosAp Lib "winside.dll" (DosApPtr As DosApHandle, DataPtr As Any, ByVal DataCount As Integer) As Long



Sub ErrorMessage (retcode As Long)
Dim message As String
    Select Case retcode
        Case ERROR_CANNOT_COPY
            message = "DOS Application Either Terminated Unexpectedly or Is Not Responding"
        Case ERROR_PIPE_NOT_CONNECTED
            message = "DOS Application Either Terminated Unexpectedly or Is Not Responding"
        Case ERROR_DLL_INIT_FAILED
            message = "PHARLAPX.386 Is Missing From Windows SYSTEM.INI file.  Add to [386Enh] section and Restart Windows"
        Case ERROR_ALREADY_ASSIGNED
            message = "Another Copy of This Application Is Already Running"
        Case ERROR_REQ_NOT_ACCEP
            message = "Could Not Start DOS Application"
        Case ERROR_BROKEN_PIPE
            message = "DOS Application Has Stopped Running"
        Case Else
            message = "Internal Error Number " & retcode
    End Select
    MsgBox message, MB_OK, "Program Name"

End Sub

