I am trying to create some bidirectional communication with a printer, and I am having a little problem.

I was originally working with a HP Color LaserJet 2820, which does not support bidirectional communication, so the error that I was getting (ERROR_NOT_SUPPORTED), makes sense.

I've since switched to a Konica Minolta Magicolor 5450, which does support BiDi, yet I still get the same error. I would like to know if anyone has successfully implemented this interface with a bi-directional printer, or can assist me in doing so.

My code so far is (the error occurs on line 43.)

System::String^ BiDiTest::GetToner(System::String^ PrinterName, System::String^ valueRequired) 
    IBidiSpl        * pIBidiSpl = NULL;  
    IBidiRequest    * pIReq = NULL; 
    HRESULT hr = 0; 
    //Convert System::String^ to LPCWSTR ---------------------- 
    const wchar_t* chars = 
    (const wchar_t*)(Marshal::StringToHGlobalUni(PrinterName)).ToPointer(); 
    LPCWSTR name = chars; 
    //  ---------------------------------------------------- 
        DWORD dwAccess = BIDI_ACCESS_USER; 
        BSTR request = CString(mySchema).AllocSysString(); 
        DWORD Erroc = GetLastError(); 
        hr = CoInitializeEx (NULL, COINIT_MULTITHREADED); 
        hr = CoCreateInstance(CLSID_BidiSpl, NULL, CLSCTX_INPROC_SERVER, IID_IBidiSpl, 
        hr = pIBidiSpl->BindDevice(name, dwAccess); 
        hr = CoCreateInstance(CLSID_BidiRequest, 
        hr = pIReq->SetSchema (L"\\Printer.Layout.InputBins.Tray2:Installed"); 
        LPWSTR   pszSchema = NULL; 
        DWORD    dwType = NULL; 
        BYTE     *pData = NULL; 
        ULONG    uSize = NULL; 
        bool bDuplexInstalled; 
        BSTR* response = NULL; 
        hr = pIBidiSpl->SendRecv(BIDI_ACTION_GET, pIReq);
           // This is where I get the error....
        hr = pIReq->GetOutputData (0, &pszSchema, &dwType, &pData, &uSize); 
        CoTaskMemFree (pData); 
        hr = pIBidiSpl->UnbindDevice (); 
    return PrinterName; 

Thanks in advance.

Recommended Answers

All 2 Replies

I still havent figured this one out

I still havent figured this one out

Have you tried the printer vendor's support facilities?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.