title: Passing struct data type to named pipes in C++
body: <p>I found one sample program that passes string from client to server in named pipes. How can I pass a struct data type through named pipes in c++?</p>
  
  <p>WriteFile function of client looks like this:</p>
  
  <pre><code>WriteFile(hPipe,TEXT("Hello Pipe\n"),12,&amp;dwWritten,NULL);
  </code></pre>
  
  <p>ReadFile function of server looks like this:</p>
  
  <pre><code>while (ReadFile(hPipe, buffer, sizeof(buffer)-1, &amp;dwRead, NULL))
  </code></pre>
  
  <p>The structure I need to pass looks like this:</p>
  
  <pre><code>struct EventLogEntry 
     {
         string date;
         string time;
         string subsystem;
         unsigned long eventType;
         string majorFunction;
         string messageText;
         unsigned long timeStamp; //Added for TimeZone Corrections
     };
  </code></pre>
  
  <p>In <code>CreateNamedPipe()</code> I'm using <code>PIPE_TYPE_BYTE</code> <code>PIPE_READMODE_BYTE</code> pipe mode.  Do I need to change them to <code>PIPE_TYPE_BYTE</code> and <code>PIPE_READMODE_MESSAGE</code>?</p>