Implementing an OPOS Printer Service Object for Capturing Printed Text

We are trying to create something like a printer driver shell for POS applications, which will allow us to capture the printed receipt and then send it again to the original printer.

So far, we have implemented it as a service object on top of "POS for .Net", it worked perfectly and that’s it, but it turned out that some outdated POS applications support only OPOS. To support them, we either have to make our "POS for .Net" service object available as an OPOS service object, or we need to write our own OPOS service object using CCO.

My questions:

  • In these legacy POS applications, is it possible to use our POS for .Net solution? (if so, how?)
  • How to create an OPOS service object? and can it use .Net framework (e.g. C #)?
  • Are we doing the right thing? Is there a better way to capture receipts (especially for these legacy apps)?
+5
source share
2 answers

Q) In these legacy POS applications, is it possible to use our POS for .Net solution? (if so, how?)

A) No, these applications do not use POS for .Net libraries and do not look for service objects using the POS registry keys for .Net. These applications use the OPOS registry entries (OLE POS) to search for registered service objects, and usually invoke a CCO, which in turn calls the service object.

Q) How to create an OPOS service object? and can it use .Net framework (e.g. C #)?

A) , .Net, COM-, - CCO, DLL, , , COM , GUID ProgId, regasm "/register/codebase/tlb, - UPOS\ , , , , , , , , , , , 7 , - UPOS\ - :

  • COFreezeEvents. , FreezeEvents.
  • GetPropertyNumber: \Boolean , .
  • SetPropertyNumber: \Boolean , .
  • GetPropertyString: string , .
  • SetPropertyString: string , .
  • OpenService. , .
  • CloseService. , .

, , CCO , , , UPOS .

, OpenService CloseService, , , CCO com, Open Close OpenService CloseService, Claim and Release ClaimDevice Release Device - , .

\

4 , ? , , , Dispatch , ? ++? .

, Include OPOS - CCO - *.hi, Opos.hi OposPtr.hi( , ), , CCO, , 4 - .

OPOS PropIndex \ .

    if (PropertyIndexHelper.IsStringPidx(PropIndex))
    {
        switch (PropIndex)
        {
            case PropertyIndexHelper.PIDX_CheckHealthText:
                return _physicalPrinter.CheckHealthText;

            case PropertyIndexHelper.PIDX_DeviceDescription:
                return _physicalPrinter.DeviceDescription;

            case PropertyIndexHelper.PIDX_DeviceName:
                return _physicalPrinter.DeviceName;
                                  .
                                  .
                                  .
                                  .
                                  .
+5

MEYWD , #.

[ComVisible(true), Guid("Put a GUID here")]
public interface IMSR
{
    //Common Opos
    [DispId(0x01)]
    int CheckHealth([In] int lLevel);
    [DispId(0x02)]
    int ClaimDevice([In] int lTimeOut);
    [DispId(0x03)]
    int ClearInput();
    [DispId(0x04)]
    int ClearInputProperties();
    [DispId(0x05)]
    int ClearOutput();
    [DispId(0x06)]
    int CloseService();
    [DispId(0x07)]
    int COFreezeEvents([In, MarshalAs(UnmanagedType.VariantBool)] bool Freeze);
    [DispId(0x08)]
    int CompareFirmwareVersion([In, MarshalAs(UnmanagedType.BStr)] string FirmwareFileName, [In, Out]ref int pResult);
    [DispId(0x09)]
    int DirectIO([In] int lCommand, [In, Out] ref int pData, [In, Out, MarshalAs(UnmanagedType.BStr)] ref string pString);
    [DispId(0x0A)]
    int OpenService([In, MarshalAs(UnmanagedType.BStr)] string lpclDevClass, [In, MarshalAs(UnmanagedType.BStr)] string lpclDevName, [In, MarshalAs(UnmanagedType.IDispatch)] object lpDispatch);
    [DispId(0x0B)]
    int ReleaseDevice();
    [DispId(0x0C)]
    int ResetStatistics([In, MarshalAs(UnmanagedType.BStr)] string StatisticsBuffer);
    [DispId(0x0D)]
    int RetrieveStatistics([In, Out, MarshalAs(UnmanagedType.BStr)] ref string pStatisticsBuffer);
    [DispId(0x0E)]
    int UpdateFirmware([In, MarshalAs(UnmanagedType.BStr)] string FirmwareFileName);
    [DispId(0x0F)]
    int UpdateStatistics([In, MarshalAs(UnmanagedType.BStr)] string StatisticsBuffer);
    [DispId(0x10)]
    int GetPropertyNumber([In] int lPropIndex);
    [DispId(0x11)]
    string GetPropertyString([In] int lPropIndex);
    [DispId(0x12)]
    void SetPropertyNumber([In] int lPropIndex, [In] int nNewValue);
    [DispId(0x13)]
    void SetPropertyString([In] int lPropIndex, [In, MarshalAs(UnmanagedType.BStr)] string StringData);
    //MSR Specific
    [DispId(0x14)]
    int AuthenticateDevice([In, MarshalAs(UnmanagedType.BStr)] string deviceResponse);
    [DispId(0x15)]
    int DeauthenticateDevice([In, MarshalAs(UnmanagedType.BStr)] string deviceResponse);
    [DispId(0x16)]
    int RetrieveCardProperty([In, MarshalAs(UnmanagedType.BStr)] string propertyName, [Out, MarshalAs(UnmanagedType.BStr)] out string cardProperty);
    [DispId(0x17)]
    int RetrieveDeviceAuthenticationData([In, Out, MarshalAs(UnmanagedType.BStr)] ref string challenge);
    [DispId(0x18)]
    int UpdateKey([In, MarshalAs(UnmanagedType.BStr)]string key,[In, MarshalAs(UnmanagedType.BStr)] string keyName);
    [DispId(0x19)]
    int WriteTracks([In] object data,[In] int timeout);
}

MSR, CommonOPOS . , , - DispID 0x14 (20) . , , OPOS , , #. 6 SO , .

- OpenService. , - . Control. , COM . MSR, .

[ComImport, Guid("CCB91121-B81E-11D2-AB74-0040054C3719"), InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface COPOSMSR
{
    void SOData([In] int Status);
    void SODirectIO([In] int EventNumber, [In, Out] ref int pData, [In, Out, MarshalAs(UnmanagedType.BStr)] ref string pStrIng);
    void SOError([In] int ResultCode, [In] int ResultCodeExtended, [In] int ErrorLocus, [In, Out] ref int pErrorResponse);
    void SOOutputCompleteDummy([In] int OutputID);
    void SOStatusUpdate([In] int Data);
    void SOProcessID([Out] out int pProcessID);
}

I OPOS. , .. ( msr OPOS), , , .

c:\Program Files (x86)\Opos\oposSrc\zMSR\MSR.idl

[
    object,
    uuid(CCB91121-B81E-11D2-AB74-0040054C3719),
    dual,
    helpstring("IOPOSMSR 1.5 Interface"),
    pointer_default(unique)
]
interface IOPOSMSR_1_5 : IDispatch
{
// Methods for use only by the Service Object
    [id(1), hidden, helpstring("method SOData")] HRESULT SOData( [in] long Status );
    [id(2), hidden, helpstring("method SODirectIO")] HRESULT SODirectIO( [in] long EventNumber, [in, out] long* pData, [in, out] BSTR* pString );
    [id(3), hidden, helpstring("method SOError")] HRESULT SOError( [in] long ResultCode, [in] long ResultCodeExtended, [in] long ErrorLocus, [in, out] long* pErrorResponse );
    [id(4), hidden, helpstring("method SOOutputCompleteDummy")] HRESULT SOOutputCompleteDummy( [in] long OutputID );
    [id(5), hidden, helpstring("method SOStatusUpdate")] HRESULT SOStatusUpdate( [in] long Data );
    [id(9), hidden, helpstring("method SOProcessID")] HRESULT SOProcessID( [out, retval] long* pProcessID );

SO.. .

    public int OpenService(string lpclDevClass, string lpclDevName, object lpDispatch)
    {
        controlObject = (COPOSMSR)lpDispatch;
        controlObject.SOData(1)//I just fired a Data Event
    }

, SO ++ , #. , # .

, , .

COM Interop Part1: #

http://msdn.microsoft.com/en-us/library/aa645736(v=vs.71).aspx

COM Interop 2: #

http://msdn.microsoft.com/en-us/library/aa645738(v=vs.71).aspx

COM

https://msdn.microsoft.com/en-us/library/sak564ww%28v=vs.100%29.aspx

+3

All Articles