Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //initialize wia
- HRESULT h = CoInitialize(NULL);
- IWiaDevMgr* pWiaDevMgr = NULL;
- //create wia device manager
- HRESULT hr = CreateWiaDeviceManager(&pWiaDevMgr);
- //show connected devices and get deviceId
- BSTR bstrDeviceID = SysAllocString(L"");
- HRESULT hr2 = EnumerateWiaDevices(pWiaDevMgr, &bstrDeviceID);
- //create device with device id
- IWiaItem* ppWiaDevice;
- HRESULT hr3 = CreateWiaDevice(pWiaDevMgr, bstrDeviceID, &ppWiaDevice);
- //case IWiaItem to IWiaItemExtras
- IWiaItemExtras* ppWiaExtra = (IWiaItemExtras*)ppWiaDevice;
- //try to send data
- DWORD dwEscapeCode = 256;
- BYTE* lpInData = new unsigned char[37]{ 0x01, 0x92, 0x00 , 0x00 , 0x00, 0x00, 0x00 , 0x00 , 0x00 , 0x01 ,
- 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
- 0x00, 0x00, 0x00, 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x03 ,
- 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x00 };
- DWORD cbInDataSize = sizeof(lpInData);
- BYTE* pOutData = new unsigned char[4]{ 0x00 , 0x00,0x00,0x00 };
- DWORD dwOutDataSize = sizeof(pOutData);
- DWORD pdwActualDataSize = NULL;
- BSTR bstre = SysAllocString(L"");
- //just to test if ppWiaExtra is working
- HRESULT hr6 = ppWiaExtra->GetExtendedErrorInfo(&bstre); //works
- //try to send data with Escape Method
- //see https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-iwiaitemextras-escape
- HRESULT hr5 = ppWiaExtra->Escape(dwEscapeCode, lpInData, cbInDataSize, pOutData, dwOutDataSize, &pdwActualDataSize); //error below
- //Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.
- //This is usually a result of calling a function declared with one calling
- //convention with a function pointer declared with a different calling convention.
- //Function in HeaderFile:
- /*
- virtual HRESULT STDMETHODCALLTYPE Escape(
- [in] DWORD dwEscapeCode,
- [size_is][in] __RPC__in_ecount_full(cbInDataSize) BYTE * lpInData,
- [in] DWORD cbInDataSize,
- [length_is][size_is][out] __RPC__out_ecount_part(dwOutDataSize, pdwActualDataSize ? *pdwActualDataSize : dwOutDataSize) BYTE * pOutData,
- [in] DWORD dwOutDataSize,
- [out] __RPC__out DWORD * pdwActualDataSize) = 0;
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement