#pragma once

class CPipeClient
{
public:
    // 客户端只有PIPE_READMODE_BYTE PIPE_READMODE_MESSAGE两种模式;
    CPipeClient(LPCTSTR lpPipeName, DWORD dwMode=PIPE_READMODE_MESSAGE);
    ~CPipeClient(void);

private:
    HANDLE m_hPipeInst;
    // 客户端状态;
    BOOL m_bClientStop;
    // 管道名称;
    TCHAR m_szPipeName[MAX_PATH];
    // 管道通信模式;
    DWORD m_dwMode;
    // 缓存区;
    TCHAR m_szWriteBuff[1024];
    TCHAR m_szReceiveBuff[1024];
public:
    BOOL StartWork();
    void StopWork() { m_bClientStop = TRUE;Sleep(100000);}
    // 连续管道服务器线程;
    static DWORD WINAPI ConnectThread(LPVOID lpParam);
    // 读取管道消息线程;
    static DWORD WINAPI ReadMsgThread(LPVOID lpParam);
};
