<div class="content" name="FAX_ReadFile" uuid="ccf63991-bf80-47ad-9fd1-4f4e3a966142"><p>The fax client application calls the <b>FAX_ReadFile (Opnum
71)</b> method to copy a file from the server (in chunks).</p><p>In response, the server MUST validate that the <i>hCopy</i>
context handle refers to a valid copy handle returned by <b>FAX_StartCopyMessageFromServer</b> (section
<a href="eeec1571-a24c-4cb3-bc2a-875300086431" data-linktype="relative-path">3.1.4.1.96</a>) and for
which <b>FAX_EndCopy</b> (section <a href="efdf1a1b-8f2c-450c-b6a7-36f115aa6ec3" data-linktype="relative-path">3.1.4.1.15</a>) has not been
called. To indicate success, the server MUST copy the contents of the message
specified by the <i>hCopy</i> handle into the buffer and return the buffer to
the client. The server MUST also return the number of bytes it wrote
successfully to the buffer. The server MUST NOT write more than <i>dwMaxDataSize</i>
bytes to the buffer.</p><p>The fax client SHOULD call the <b>FAX_ReadFile</b> (section
3.1.4.1.66) method one or several times, each call reading one part (chunk) of
the file.<a id="Appendix_A_Target_141"></a><a aria-label="Product behavior note 141" href="056171e7-80bc-45ff-8107-66ba3abb2023#Appendix_A_141" data-linktype="relative-path">&lt;141&gt;</a> The fax client SHOULD stop
calling <b>FAX_ReadFile</b> when the fax server returns a zero number of bytes
in the output <i>*lpdwDataSize</i> argument, meaning that no more data is
available to be copied from the respective file.</p><p>If the fax client calls <b>FAX_ReadFile</b> after the file
is entirely copied, the fax server SHOULD return a zero number of bytes in the
output <i>*lpdwDataSize</i> argument and write no data in the <i>lpbData</i>
buffer.</p><p>No specific access rights are required for the client&#39;s fax
user account to successfully call this method.</p><p>The client MUST allocate the memory for the buffer before
making the call and MUST free the buffer when done with the data written by the
server in the buffer.</p><dl>
<dd>
<div><pre> error_status_t FAX_ReadFile(
   [in, ref] RPC_FAX_COPY_HANDLE hCopy,
   [in] DWORD dwMaxDataSize,
   [out, ref, size_is(*lpdwDataSize)] 
     LPBYTE lpbData,
   [in, out, ref] LPRANGED_DWORD lpdwDataSize
 );
</pre></div>
</dd></dl><p><b>hCopy: </b>A copy handle returned by <b>FAX_StartCopyMessageFromServer</b>.</p><p><b>dwMaxDataSize: </b>A <b>DWORD</b> (<a href="../ms-dtyp/cca27429-5689-4a16-b2b4-9325d93e4ba2" data-linktype="relative-path">[MS-DTYP]</a>
section <a href="../ms-dtyp/262627d8-3418-4627-9218-4ffe110850b2" data-linktype="relative-path">2.2.9</a>)
value that indicates the maximum size, in bytes, of data to be read and
returned in the buffer. The caller MUST set this argument to a value greater
than zero before making the call.</p><p><b>lpbData: </b>A pointer to the buffer in which to
place the data. This data MUST be allocated by the caller to be at least the
size specified by the <i>lpdwDataSize</i> argument. The data to be placed in
this buffer is a binary data block read from the file indicated by the <i>dwlMessageId</i>
and <i>Folder</i> arguments for the <b>FAX_StartCopyMessageFromServer</b> call,
which the client used to obtain the <i>hCopy</i> handle.</p><p><b>lpdwDataSize: </b>A pointer to a <b>DWORD</b> in
which to return the size, in bytes, of the data that is sent in this segment.
The caller MUST set <i>*lpdwDataSize</i> to the same value as <i>dwMaxDataSize</i>
before making the call.</p><p><b>Return Values: </b>This method MUST return
0x00000000 (ERROR_SUCCESS) for success; otherwise, it MUST return one of the following
error codes, one of the fax-specific errors that are defined in section <a href="cbe6c4fb-4dda-4f6c-9701-0d490ba0d105" data-linktype="relative-path">2.2.52</a>, or one of the
other standard errors defined in <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>
section <a href="../ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d" data-linktype="relative-path">2.2</a>.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>ERROR_INVALID_HANDLE 0x00000006</td>
  <td>The handle specified by the hCopy argument is not a valid copy handle returned by FAX_StartCopyMessageFromServer for which FAX_EndCopy has not been called.&lt;142&gt;</td>
 </tr><tr>
  <td>ERROR_INVALID_PARAMETER 0x00000057</td>
  <td>The parameter is incorrect. This error code is returned under any of the following conditions: § The handle specified by the hCopy argument is NULL.&lt;143&gt; § The value specified for the dwMaxDataSize argument is zero. § The value specified for the *lpdwDataSize at input (when the call is made) is different than the value specified for the dwMaxDataSize argument.</td>
 </tr></tbody></table>
</dd></dl><p><b>Exceptions Thrown: </b>No exceptions are thrown
except those that are thrown by the underlying <a href="46aba9c4-ebb1-4b10-86ac-4bb3025657b9#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a> protocol, <a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a>.</p></div>