Note that there are some explanatory texts on larger screens.

plurals
  1. POImplement COM interface C++ / VC++ 6.0 / MFC
    primarykey
    data
    text
    <p>Entry level programmer here trying to implement a COM interface. I am working on a program that interfaces with the Aloha point of sale system. Aloha uses COM to work with external programs. I am trying to intercept card data from the mag card reader, which is an OPOS reader, not a keyboard wedge. The documentation I have doesn't explain how to implement this particular interface, but it does explain how to implement a similar one. I have tried to follow this example but I am getting no where. Support from Aloha is non-existent, their documentation is poor, outdated and sometimes just wrong, even though I have paid for a license.</p> <p>I tried to make a simple app just to test this functionality. Here is what I did:</p> <p>1) create a new project in vc++ 6.0 using ATL COM app wizard 2) server type dll 3) insert new atl object -> simple object 4) right click on my new class and choose implement interface 5) browse for type library, chose Iber.tlb (Aloha's tlb) 6) chose the interface I want to implement</p> <p>That made a .h, .cpp and .rgs file.</p> <p>The .h file has:</p> <pre><code>public: // IInterceptMagcard STDMETHOD(InterceptMagcard)(BSTR bstrAccountNumber, BSTR bstrCustomerName, BSTR bstrExpirationDate, BSTR bstrTrack1Info, BSTR bstrTrack2Info, BSTR bstrTrack3Info, BSTR bstrRawMagcardData, LONG * bWasDataHandled) { if (bWasDataHandled == NULL) return E_POINTER; return E_NOTIMPL; } </code></pre> <p>Is that where I implement my code? I put some test code in there to write out to a txt file just to test it. I then used:</p> <pre><code>HRESULT hr = CoCreateInstance(CLSID_AlohaMag, NULL, CLSCTX_INPROC_SERVER, IID_IAlohaMag, (void **) &amp;g_pIInterceptMagcard); </code></pre> <p>where g_pIInterceptMagcard is a pointer to my interface class created with the wizard above.</p> <p>When I try to register I get the following HRESULT: 0x80040112 That is "class not licensed for use."</p> <p>Does that mean my program didn't make the necessary registry entries?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COThis doesn't explain your problem but: the g_pIInterceptMagcard variable should not be a pointer to your interface class since [CoCreateInstance](http://msdn.microsoft.com/en-us/library/ms686615(v=VS.85).aspx) will overwrite it with a pointer to the class implementing CLSID_AlohaMag.
      singulars
    2. CO@Frank: Not quite sure what you mean. On return, g_pIInterceptMagcard will point to the IAlohaMag interface of an AlohaMag object. I don't think your term "interface class" is clear because the separation of interface from implementation is crucial in COM. (There's no such thing as an "interface class".) And the returned pointer points to an object, not to a class. (There's no such thing as a pointer to a class in COM or C++.)
      singulars
    3. CO@ciaran: the OP says "where g_pIInterceptMagcard is a pointer to my interface class created with the wizard above". I took that to mean something like `g_pIInterceptMagcard = new MyInterceptMagcard()` was executed before the CoCreateInstance call. What I was trying to point out was that any attempt to assign g_pIInterceptMagcard before calling CoCreateInstance is wasted effort because CoCreateInstance overwrites the contents of the last parameter (i.e., g_pIInterceptMagcard ) with a pointer to the interface requested.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload