Windows Dev Center

Using the Bidi Schema to Query a Device

This sample code shows how you can implement a client to retrieve bidi information from a device. In particular, it illustrates how you can query a device.

Include the header file.


#include "bidispl.h"

Paste the following code in your method.



IBidiSpl                * pIBidiSpl = NULL; 
IBidiRequest    * pIReq = NULL;

hr = CoInitializeEx (NULL, COINIT_MULTITHREADED) ;
hr = CoCreateInstance(CLSID_BidiSpl,
                NULL, 
                CLSCTX_INPROC_SERVER,
                IID_IBidiSpl, 
                (void**)&pIBidiSpl) ;

dwAccess = BIDI_ACCESS_USER;
hr = pIBidiSpl->BindDevice (pPrinter, dwAccess);
hr = CoCreateInstance(CLSID_BidiRequest,
                NULL, 
                CLSCTX_INPROC_SERVER,
                IID_IBidiRequest, 
                (void**)&pIReq);
                
hr = pIReq->SetSchema (L"\\Printer.DuplexUnit:CurrentValue");
hr = pIBidiSpl->SendRecv (BIDI_ACTION_GET, pIReq);
hr = pIReq->GetOutputData (0,
                &pszSchema, 
                &dwType,
                &pData,
                &uSize);

if (dwType == BIDI_BOOL) {
        bDuplexInstalled = *(PBOOL)pData;
}
        
CoTaskMemFree (pData);
hr = pIBidiSpl->UnbindDevice ();
pIReq->Release ();
pIBidiSpl->Release ();
CoUninitialize ();


 

 

Community Additions

Show:
© 2015 Microsoft