ecp_lnk.dll


<= previous ^ top next =>

Overview

[ecp_lnk is part of ecpSE. It can be downloaded and used separately, but it is governed by the same license (GPL) as ecpSE. Please see the main ecpSE page for details. Currently, only the source is available so you will need Visual Basic 6.0 sp3 to compile it. If this proves to be a problem please contact me.]

ecp_lnk.dll is an ActiveX DLL which provides a wrapper and an object model for SFWLink (sfwlnk32.dll). This provides several enhancements to SFWLink.
ecp_lnk.dll provides a object model to simplify scanning calls. As an ActiveX Server it can be called from any ActiveX Client including VB, MS Office, Pythonwin, ActivePerl, VC++, Java, etc. The ecp_lnk.dll runs in its own memory space, and each instance runs in its own thread. This will stabilize the scanning process as a DDE error in scanning will not bring down a client application.


Setting up ecp_lnk.dll

Place \ecp_lnk\ anywhere. [If you download the source as a package with the other stuff it will be in the \Python\ecp_lnk\ directory. The installer won't be available for a little while.] Open ecp_lnk.vbp with Visual Basic 6.0 sp3 and select File | Make ecp_lnk.dll That's it.

It doesn't matter where ecp_lnk.dll is which is not the case for sfwlnk32.dll. It can sometimes be tricky getting ecp_lnk.dll to find sfwlnk32.dll. It depends upon the ultimate client app (and what runtime libraries are being used) as to where it will look. Places to put sfwlnk32.dll (and multiple copies don't seem to be a problem, even NCS software like MicrotestQ uses multiples) include


Object Model


Example - Scanning a Single Form

Python Example
    >>> import win32com.client                              # Import Client Components
    >>> x = win32com.client.Dispatch(r'ecp_lnk.SingleScan') # Set x = to Object Instance
    >>> y = x.Scan('001')                                   # Call Scan of Single Form
    >>> print y
    '_SCANNED_DATA_IS_RETURNED_'

Visual Basic 6 Example
First add a reference to ecp_lnk.dll (note that ecp_lnk is released under the GPL which may effect embedding it directly into a VB exe). Then add code like the following:
    Dim s_Obj as New ecp_lnk.SingleScan     'Add this to the general declarations of your Form. 

    Private Function ScanOneForm(ByVal strForm As Sring) as String
        ScanOneForm = s_Obj.Scan(strForm)   'If an error occurs, the error will be returned instead of the scanned data.
    End Function

    Private Sub Command1_Click()
        Text1.Text = ScanOneForm("701")
    End Sub

Example - Scanning Multiple Forms

Python Example
This example is super simple on purpose. You should add more error/data handling to suit your needs.
    >>> # ecp_lnk.dll specific code is ORANGE
    >>> import win32com.client                              # Import Client Components
    >>> x = win32com.client.Dispatch(r'ecp_lnk.Engine')     # Set x = to Scanning Engine Object Instance
    >>> x.SFWPath('C:\\SFW')                                # Sets Path to ScanTools [Optional]
    >>> err = x.ecpLoad                                     # Loads ScanTools [LoadSFW()]
    >>> err = x.ecpSetUp('701', '000001', '001', '1', 'N', 'M', 'N', '1', '', '', '')
    >>> # The parameters in ecpSetUp mirror the SetUpSFW Parameters. If they are blank defaults (shown) are used.
    >>> err = x.ecpScan('Start')                            # Starts Scanning Process
    >>> while 1:                                            # Loops Scanner 
    ...     if err ==  2:                                   # COMPLETE point
    ...         err = x.ecpScan('Continue')                 # Returns sfwlnk32.dll error code.  See NCS Documentation for details
    ...     if err in [1, 0]:                               # XPRINT point
    ...         err = x.ecpScan('Continue')
    ...         z = x.ecpData                               # Returns current data string [can only be called after .ecpScan('X')]
    ...         print z                                     # Scanned data is printed
    ...     else:                                           # Reached when Scanner returns "Done" signal
    ...         x.ecpScan('Done')                           # Closes SFW DDE
    ...         break
    ... else:                                               # Scanning process is over (or didn't begin).
    ...     x.ecpClose                          
    ...     print x.ScanPoint                               # Returns Scanner Diagnostic Information

Visual Basic 6 Example
First add a reference to ecp_lnk.dll (note that ecp_lnk is released under the GPL which may effect embedding it directly into a distributed VB exe.) Then add code like the following:
    Dim s_Obj as New ecp_lnk.Engine         'Add this to the general declarations of your Form. 

    Private Function LoopScanForms(ByVal strForm As Sring) as String
        Dim ecpErr as Integer

        'Load ScanTools
        s_Obj.ecpLoad
        'Call SetUpSFW() [These are the default values. If no values are entered these will be.
        'to override them insert other strings.]
        s_Obj.ecpSetUp("701", "000001", "001", "1", "N", "M", "N", "1", "", "", "")
        ecpErr = s_Obj.ecpScan("Start")
        Do While ecpErr <> 102
            Select Case ecpErr
                Case 1
                    ecpErr = s_Obj.ecpScan("Continue")
                Case 2
                    ecpErr = s_Obj.ecpScan("Continue")
                    Call ParseData(s_Obj.ecpData())
                Case Else
                    ecpErr = s_Obl.ecpScan("Done")
            End Select
        Loop
    End Function

    Private Sub ParseData(ByVal DATA as String)
        'Do something with the scanner data contained in DATA variable.
    End Sub

    Private Sub Command1_Click()
        Call LoopScanForms("701")
    End Sub

Download ecp_lnk.dll

ecp_lnk.dll (Windows Installer) (1,379KB) This has not been tested, and may or may not work. At any rate, you should download the source to get a clearer idea about how to use ecp_lnk. If you do not have Visual Basic 6.0, the code can be read in any text editor.

ecp_lnk_source.zip (VB6SP3 Source) (5KB)

<= previous ^ top next =>