Click or drag to resize

QueryString

Performs a write and read of a string result through as a single operation.

virtual HRESULT QueryString(const CString& strCommand, CString& pResult, long lTimeout = CUR_TIMEOUT) abstract;

virtual HRESULT QueryString(const CString& strCommand, BSTR* pResult, long lTimeout = CUR_TIMEOUT) abstract;
Parameters
strCommand

[in] Command string to send to the device.

pResult

[out] Response string read from the device.

lTimeout

[in] I/O timeout value in milliseconds.

Return Value

Returns S_OK if successful, otherwise a failure HRESULT.

Remarks

The QueryString function provides a mechanism of "send, then receive" typical to a device command sequences. In this manner, the response generated from the command can be read immediately. The device is not polled for errors after the write portion of the sequence.

The QueryString function performs a WriteStringNoPoll operation followed immediately by a ReadString operation.

Example

The following example demonstrates use of the QueryString function.

C++
// CoAcme4321.cpp
STDMETHODIMP Acme4321::IAcme4321_GetIdentification(BSTR* pbstrId)
{
  HRESULT hr = S_OK;

  // Send ID query to device and read the response as a BSTR string
  hr = io.QueryString(_T("*IDN?"), pbstrId);

  return hr;
}
See Also

Download a complete CHM version of this documentation here.