Public Class clsBXLLIB

    Public m_strProcessor As String = Nothing

    Public Sub New()

    End Sub

    Public Function IsWow64() As Boolean

        If (m_strProcessor Is Nothing) Then
            m_strProcessor = System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE")
        End If

        If m_strProcessor = "x86" Then
            Return False
        End If

        Return True

    End Function


    Public Function ConnectPrinter(ByVal szPrinterName As String) As Boolean
        If IsWow64() = True Then
            Return ConnectPrinter_x64(szPrinterName)
        Else
            Return ConnectPrinter_x86(szPrinterName)
        End If
    End Function

    Public Function DisconnectPrinter() As Boolean
        If IsWow64() = True Then
            Return DisconnectPrinter_x64()
        Else
            Return DisconnectPrinter_x86()
        End If
    End Function

    Public Function StartLabel() As Boolean
        If IsWow64() = True Then
            Return StartLabel_x64()
        Else
            Return StartLabel_x86()
        End If
    End Function

    Public Sub EndLabel()
        If IsWow64() = True Then
            EndLabel_x64()
        Else
            EndLabel_x86()
        End If
    End Sub

    Public Function GetBIXOLON_PrinterList(ByVal strInstalledPrinter As System.Text.StringBuilder) As Integer
        If IsWow64() = True Then
            Return GetBIXOLON_PrinterList_x64(strInstalledPrinter)
        Else
            Return GetBIXOLON_PrinterList_x86(strInstalledPrinter)
        End If
    End Function

    Public Function GetDllVersion(ByVal strBxlPrtList As System.Text.StringBuilder) As Boolean
        If IsWow64() = True Then
            Return GetDllVersion_x64(strBxlPrtList)
        Else
            Return GetDllVersion_x86(strBxlPrtList)
        End If
    End Function

    Public Function GetPrinterResolution() As Integer
        If IsWow64() = True Then
            Return GetPrinterResolution_x64()
        Else
            Return GetPrinterResolution_x86()
        End If
    End Function


    Public Function Print1DBarcode(ByVal nHorizontalPos As Integer, _
                                   ByVal nVerticalPos As Integer, _
                                   ByVal nBarcodeType As Integer, _
                                   ByVal nNarrowBarWidth As Integer, _
                                   ByVal nWideBarWidth As Integer, _
                                   ByVal nBarcodeHeight As Integer, _
                                   ByVal nRotation As Integer, _
                                   ByVal nHRI As Integer, _
                                   ByVal pData As String) _
                                   As Boolean
        If IsWow64() = True Then
            Return Print1DBarcode_x64(nHorizontalPos, nVerticalPos, nBarcodeType, nNarrowBarWidth, nWideBarWidth, nBarcodeHeight, nRotation, nHRI, pData)
        Else
            Return Print1DBarcode_x86(nHorizontalPos, nVerticalPos, nBarcodeType, nNarrowBarWidth, nWideBarWidth, nBarcodeHeight, nRotation, nHRI, pData)
        End If
    End Function


    Public Function PrintDeviceFont(ByVal nHorizontalPos As Integer, _
                                    ByVal nVerticalPos As Integer, _
                                    ByVal nFontName As Integer, _
                                    ByVal nHorizontalMulti As Integer, _
                                    ByVal nVerticalMulti As Integer, _
                                    ByVal nRotation As Integer, _
                                    ByVal bBold As Boolean, _
                                    ByVal szText As String) _
                                    As Boolean
        If IsWow64() = True Then
            Return PrintDeviceFont_x64(nHorizontalPos, nVerticalPos, nFontName, nHorizontalMulti, nVerticalMulti, nRotation, bBold, szText)
        Else
            Return PrintDeviceFont_x86(nHorizontalPos, nVerticalPos, nFontName, nHorizontalMulti, nVerticalMulti, nRotation, bBold, szText)
        End If
    End Function

    Public Function PrintDeviceFontW(ByVal nHorizontalPos As Integer, _
                                     ByVal nVerticalPos As Integer, _
                                     ByVal nFontName As Integer, _
                                     ByVal nHorizontalMulti As Integer, _
                                     ByVal nVerticalMulti As Integer, _
                                     ByVal nRotation As Integer, _
                                     ByVal bBold As Boolean, _
                                     ByVal szText As String, _
                                     ByVal nCodePage As Integer) _
                                     As Boolean
        If IsWow64() = True Then
            Return PrintDeviceFontW_x64(nHorizontalPos, nVerticalPos, nFontName, nHorizontalMulti, nVerticalMulti, nRotation, bBold, szText, nCodePage)
        Else
            Return PrintDeviceFontW_x86(nHorizontalPos, nVerticalPos, nFontName, nHorizontalMulti, nVerticalMulti, nRotation, bBold, szText, nCodePage)
        End If
    End Function


    Public Function SetConfigOfPrinter(ByVal nSpeed As Integer, _
                                       ByVal nDensity As Integer, _
                                       ByVal nOrientation As Integer, _
                                       ByVal bAutoCut As Integer, _
                                       ByVal nCuttingPeriod As Integer, _
                                       ByVal bBackFeeding As Boolean) _
                                       As Boolean
        If IsWow64() = True Then
            Return SetConfigOfPrinter_x64(nSpeed, nDensity, nOrientation, bAutoCut, nCuttingPeriod, bBackFeeding)
        Else
            Return SetConfigOfPrinter_x86(nSpeed, nDensity, nOrientation, bAutoCut, nCuttingPeriod, bBackFeeding)
        End If
    End Function


    Public Function Prints(ByVal nLabelSet As Integer, ByVal nCopiesOfEachLabel As Integer) As Boolean
        If IsWow64() = True Then
            Return Prints_x64(nLabelSet, nCopiesOfEachLabel)
        Else
            Return Prints_x86(nLabelSet, nCopiesOfEachLabel)
        End If
    End Function


    Public Function SetPaper(ByVal nHorizontalMagin As Integer, _
                             ByVal nVerticalMargin As Integer, _
                             ByVal nPaperWidth As Integer, _
                             ByVal nPaperLength As Integer, _
                             ByVal nMediaType As Integer, _
                             ByVal nOffSet As Integer, _
                             ByVal nGapLengthORThicknessOfBlackLine As Integer) _
                             As Boolean
        If IsWow64() = True Then
            Return SetPaper_x64(nHorizontalMagin, nVerticalMargin, nPaperWidth, nPaperLength, nMediaType, nOffSet, nGapLengthORThicknessOfBlackLine)
        Else
            Return SetPaper_x86(nHorizontalMagin, nVerticalMargin, nPaperWidth, nPaperLength, nMediaType, nOffSet, nGapLengthORThicknessOfBlackLine)
        End If
    End Function


    Public Function ClearBuffer() As Boolean
        If IsWow64() = True Then
            Return ClearBuffer_x64()
        Else
            Return ClearBuffer_x86()
        End If
    End Function


    Public Function PrintBlock(ByVal nHorizontalStartPos As Integer, _
                               ByVal nVerticalStartPos As Integer, _
                               ByVal nHorizontalEndPos As Integer, _
                               ByVal nVerticalEndPos As Integer, _
                               ByVal nOption As Integer, _
                               ByVal nThickness As Integer) _
                               As Boolean
        If IsWow64() = True Then
            Return PrintBlock_x64(nHorizontalStartPos, nVerticalStartPos, nHorizontalEndPos, nVerticalEndPos, nOption, nThickness)
        Else
            Return PrintBlock_x86(nHorizontalStartPos, nVerticalStartPos, nHorizontalEndPos, nVerticalEndPos, nOption, nThickness)
        End If
    End Function


    Public Function PrintCircle(ByVal nHorizontalStartPos As Integer, _
                                ByVal nVerticalStartPos As Integer, _
                                ByVal nDiameter As Integer, _
                                ByVal nMulti As Integer) _
                                As Boolean
        If IsWow64() = True Then
            Return PrintCircle_x64(nHorizontalStartPos, nVerticalStartPos, nDiameter, nMulti)
        Else
            Return PrintCircle_x86(nHorizontalStartPos, nVerticalStartPos, nDiameter, nMulti)
        End If
    End Function


    Public Function PrintDirect(ByVal pDirectData As String, _
                                ByVal bAddCrLf As Boolean) _
                                As Integer
        If IsWow64() = True Then
            Return PrintDirect_x64(pDirectData, bAddCrLf)
        Else
            Return PrintDirect_x86(pDirectData, bAddCrLf)
        End If
    End Function

    Public Function WriteBuffer(ByVal pDirectData As String, _
                                ByVal nDataLength As Integer) _
                                As Boolean
        If IsWow64() = True Then
            Return WriteBuffer_x64(pDirectData, nDataLength)
        Else
            Return WriteBuffer_x86(pDirectData, nDataLength)
        End If
    End Function

    Public Function PrintTrueFont(ByVal nXPos As Integer, _
                                  ByVal nYPos As Integer, _
                                  ByVal strFontName As String, _
                                  ByVal nFontSize As Integer, _
                                  ByVal nRotaion As Integer, _
                                  ByVal bItalic As Boolean, _
                                  ByVal bBold As Boolean, _
                                  ByVal bUnderline As Boolean, _
                                  ByVal strText As String, _
                                  ByVal bDataCompression As Boolean) _
                                  As Boolean
        If IsWow64() = True Then
            Return PrintTrueFont_x64(nXPos, nYPos, strFontName, nFontSize, nRotaion, bItalic, bBold, bUnderline, strText, bDataCompression)
        Else
            Return PrintTrueFont_x86(nXPos, nYPos, strFontName, nFontSize, nRotaion, bItalic, bBold, bUnderline, strText, bDataCompression)
        End If
    End Function

    Public Function PrintTrueFontW(ByVal nXPos As Integer, _
                                   ByVal nYPos As Integer, _
                                   ByVal strFontName As String, _
                                   ByVal nFontSize As Integer, _
                                   ByVal nRotaion As Integer, _
                                   ByVal bItalic As Boolean, _
                                   ByVal bBold As Boolean, _
                                   ByVal bUnderline As Boolean, _
                                   ByVal strText As String, _
                                   ByVal bDataCompression As Boolean) _
                                   As Boolean
        If IsWow64() = True Then
            Return PrintTrueFontW_x64(nXPos, nYPos, strFontName, nFontSize, nRotaion, bItalic, bBold, bUnderline, strText, bDataCompression)
        Else
            Return PrintTrueFontW_x86(nXPos, nYPos, strFontName, nFontSize, nRotaion, bItalic, bBold, bUnderline, strText, bDataCompression)
        End If
    End Function

    Public Function PrintTrueFontLib(ByVal nXPos As Integer, _
                                     ByVal nYPos As Integer, _
                                     ByVal strFontName As String, _
                                     ByVal nFontSize As Integer, _
                                     ByVal nRotaion As Integer, _
                                     ByVal bItalic As Boolean, _
                                     ByVal bBold As Boolean, _
                                     ByVal bUnderline As Boolean, _
                                     ByVal strText As String, _
                                     ByVal bDataCompression As Boolean) _
                                     As Boolean
        If IsWow64() = True Then
            Return PrintTrueFontLib_x64(nXPos, nYPos, strFontName, nFontSize, nRotaion, bItalic, bBold, bUnderline, strText, bDataCompression)
        Else
            Return PrintTrueFontLib_x86(nXPos, nYPos, strFontName, nFontSize, nRotaion, bItalic, bBold, bUnderline, strText, bDataCompression)
        End If
    End Function

    Public Function PrintTrueFontLibW(ByVal nXPos As Integer, _
                                      ByVal nYPos As Integer, _
                                      ByVal strFontName As String, _
                                      ByVal nFontSize As Integer, _
                                      ByVal nRotaion As Integer, _
                                      ByVal bItalic As Boolean, _
                                      ByVal bBold As Boolean, _
                                      ByVal bUnderline As Boolean, _
                                      ByVal strText As String, _
                                      ByVal bDataCompression As Boolean) _
                                      As Boolean
        If IsWow64() = True Then
            Return PrintTrueFontLibW_x64(nXPos, nYPos, strFontName, nFontSize, nRotaion, bItalic, bBold, bUnderline, strText, bDataCompression)
        Else
            Return PrintTrueFontLibW_x86(nXPos, nYPos, strFontName, nFontSize, nRotaion, bItalic, bBold, bUnderline, strText, bDataCompression)
        End If
    End Function

    Public Function PrintTrueFontLibWithAlign( _
                                    ByVal nXPos As Integer, _
                                    ByVal nYPos As Integer, _
                                    ByVal strFontName As String, _
                                    ByVal nFontSize As Integer, _
                                    ByVal nRotaion As Integer, _
                                    ByVal bItalic As Boolean, _
                                    ByVal bBold As Boolean, _
                                    ByVal bUnderline As Boolean, _
                                    ByVal strText As String, _
                                    ByVal nPrintWidth As Integer, _
                                    ByVal nAlignment As Integer, _
                                    ByVal bDataCompression As Boolean) _
                                    As Boolean
        If IsWow64() = True Then
            Return PrintTrueFontLibWithAlign_x64(nXPos, nYPos, strFontName, nFontSize, nRotaion, bItalic, bBold, bUnderline, strText, nPrintWidth, nAlignment, bDataCompression)
        Else
            Return PrintTrueFontLibWithAlign_x86(nXPos, nYPos, strFontName, nFontSize, nRotaion, bItalic, bBold, bUnderline, strText, nPrintWidth, nAlignment, bDataCompression)
        End If
    End Function

    Public Function PrintTrueFontLibWithAlignW( _
                                    ByVal nXPos As Integer, _
                                    ByVal nYPos As Integer, _
                                    ByVal strFontName As String, _
                                    ByVal nFontSize As Integer, _
                                    ByVal nRotaion As Integer, _
                                    ByVal bItalic As Boolean, _
                                    ByVal bBold As Boolean, _
                                    ByVal bUnderline As Boolean, _
                                    ByVal strText As String, _
                                    ByVal nPrintWidth As Integer, _
                                    ByVal nAlignment As Integer, _
                                    ByVal bDataCompression As Boolean) _
                                    As Boolean
        If IsWow64() = True Then
            Return PrintTrueFontLibWithAlignW_x64(nXPos, nYPos, strFontName, nFontSize, nRotaion, bItalic, bBold, bUnderline, strText, nPrintWidth, nAlignment, bDataCompression)
        Else
            Return PrintTrueFontLibWithAlignW_x86(nXPos, nYPos, strFontName, nFontSize, nRotaion, bItalic, bBold, bUnderline, strText, nPrintWidth, nAlignment, bDataCompression)
        End If
    End Function


    Public Function PrintVectorFont(ByVal nXPos As Integer, _
                                    ByVal nYPos As Integer, _
                                    ByVal strFontSelection As String, _
                                    ByVal nFontWidth As Integer, _
                                    ByVal nFontHeight As Integer, _
                                    ByVal strRightSideCharSpacing As String, _
                                    ByVal bBold As Boolean, _
                                    ByVal bReversePrinting As Boolean, _
                                    ByVal bTextStyle As Boolean, _
                                    ByVal nRotation As Integer, _
                                    ByVal strTextAlignment As String, _
                                    ByVal nTextDirection As Integer, _
                                    ByVal pData As String) _
                                    As Boolean
        If IsWow64() = True Then
            Return PrintVectorFont_x64(nXPos, nYPos, strFontSelection, nFontWidth, nFontHeight, strRightSideCharSpacing, bBold, bReversePrinting, bTextStyle, nRotation, strTextAlignment, nTextDirection, pData)
        Else
            Return PrintVectorFont_x86(nXPos, nYPos, strFontSelection, nFontWidth, nFontHeight, strRightSideCharSpacing, bBold, bReversePrinting, bTextStyle, nRotation, strTextAlignment, nTextDirection, pData)
        End If
    End Function

    Public Function PrintVectorFontW(ByVal nXPos As Integer, _
                                     ByVal nYPos As Integer, _
                                     ByVal strFontSelection As String, _
                                     ByVal nFontWidth As Integer, _
                                     ByVal nFontHeight As Integer, _
                                     ByVal strRightSideCharSpacing As String, _
                                     ByVal bBold As Boolean, _
                                     ByVal bReversePrinting As Boolean, _
                                     ByVal bTextStyle As Boolean, _
                                     ByVal nRotation As Integer, _
                                     ByVal strTextAlignment As String, _
                                     ByVal nTextDirection As Integer, _
                                     ByVal pData As String, _
                                     ByVal nCodePage As Integer) _
                                     As Boolean
        If IsWow64() = True Then
            Return PrintVectorFontW_x64(nXPos, nYPos, strFontSelection, nFontWidth, nFontHeight, strRightSideCharSpacing, bBold, bReversePrinting, bTextStyle, nRotation, strTextAlignment, nTextDirection, pData, nCodePage)
        Else
            Return PrintVectorFontW_x86(nXPos, nYPos, strFontSelection, nFontWidth, nFontHeight, strRightSideCharSpacing, bBold, bReversePrinting, bTextStyle, nRotation, strTextAlignment, nTextDirection, pData, nCodePage)
        End If

    End Function


    Public Function PrintQRCode(ByVal nXPos As Integer, _
                                ByVal nYPos As Integer, _
                                ByVal nModel As Integer, _
                                ByVal nECCLevel As Integer, _
                                ByVal nSize As Integer, _
                                ByVal nRotation As Integer, _
                                ByVal pData As String) _
                                As Boolean
        If IsWow64() = True Then
            Return PrintQRCode_x64(nXPos, nYPos, nModel, nECCLevel, nSize, nRotation, pData)
        Else
            Return PrintQRCode_x86(nXPos, nYPos, nModel, nECCLevel, nSize, nRotation, pData)
        End If
    End Function

    Public Function PrintImageLib(ByVal nHorizontalStartPos As Integer, _
                                  ByVal nVerticalStartPos As Integer, _
                                  ByVal pBitmapFilename As String, _
                                  ByVal nDither As Integer, _
                                  ByVal bDataCompression As Boolean) _
                                  As Boolean
        If IsWow64() = True Then
            Return PrintImageLib_x64(nHorizontalStartPos, nVerticalStartPos, pBitmapFilename, nDither, bDataCompression)
        Else
            Return PrintImageLib_x86(nHorizontalStartPos, nVerticalStartPos, pBitmapFilename, nDither, bDataCompression)
        End If
    End Function

    Public Function PrintImageLibW(ByVal nHorizontalStartPos As Integer, _
                                   ByVal nVerticalStartPos As Integer, _
                                   ByVal pBitmapFilename As String, _
                                   ByVal nDither As Integer, _
                                   ByVal bDataCompression As Boolean) _
                                   As Boolean
        If IsWow64() = True Then
            Return PrintImageLibW_x64(nHorizontalStartPos, nVerticalStartPos, pBitmapFilename, nDither, bDataCompression)
        Else
            Return PrintImageLibW_x86(nHorizontalStartPos, nVerticalStartPos, pBitmapFilename, nDither, bDataCompression)
        End If
    End Function

    Public Function PrintImageLibWithSize(ByVal nHorizontalStartPos As Integer, _
                                          ByVal nVerticalStartPos As Integer, _
                                          ByVal nNewWidth As Integer, _
                                          ByVal nNewHeight As Integer, _
                                          ByVal pBitmapFilename As String, _
                                          ByVal nDither As Integer, _
                                          ByVal bDataCompression As Boolean) _
                                          As Boolean
        If IsWow64() = True Then
            Return PrintImageLibWithSize_x64(nHorizontalStartPos, nVerticalStartPos, nNewWidth, nNewHeight, pBitmapFilename, nDither, bDataCompression)
        Else
            Return PrintImageLibWithSize_x86(nHorizontalStartPos, nVerticalStartPos, nNewWidth, nNewHeight, pBitmapFilename, nDither, bDataCompression)
        End If
    End Function

    Public Function SetShowMsgBox(ByVal bShowMsgBox As Boolean) As Boolean
        If IsWow64() = True Then
            Return SetShowMsgBox_x64(bShowMsgBox)
        Else
            Return SetShowMsgBox_x86(bShowMsgBox)
        End If
    End Function

    Public Sub DEBUGLOG_ON()
        If IsWow64() = True Then
            DEBUGLOG_ON_x64()
        Else
            DEBUGLOG_ON_x86()
        End If
    End Sub

    Public Sub DEBUGLOG_OFF()
        If IsWow64() = True Then
            DEBUGLOG_OFF_x64()
        Else
            DEBUGLOG_OFF_x86()
        End If
    End Sub

End Class
