亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? server.c

?? 《C/C++程序員實用大全》配套代碼 [涉及平臺] VC++ [作者] void [文件大小] 629KB [更新日期] 2005-10-28
?? C
?? 第 1 頁 / 共 2 頁
字號:
#define  STRICT
#include <windows.h>
#include "server.h"

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

                                       // clients[] is a global array of
                                       // structures used to keep track
                                       // of the multiple instances of
                                       // the server side of the named
                                       // pipe.  As a client connects
                                       // to a given instance, a new
                                       // server thread is created and
                                       // added to the array.
WRTHANDLE clients[MAX_PIPE_INSTANCES];
DWORD     clientCount = 0;             // Global count of connected clients.

HWND   hWnd;
HANDLE hInst;
CHAR   lpBuffer[255];


int APIENTRY WinMain (HINSTANCE hInstance,
                      HINSTANCE hPrevInstance,
                      LPSTR  lpCmdLine,
                      int    nCmdShow)


{

  MSG  msg;
  WNDCLASS wc;


  UNREFERENCED_PARAMETER( lpCmdLine );
  UNREFERENCED_PARAMETER( hPrevInstance );

  //
  // Detect platform and exit gracefully if not Windows NT.
  //

  {
    OSVERSIONINFO osvi;
    osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);

    GetVersionEx (&osvi);
    if (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) {
	  LoadString(hInst, IDS_WRONGOS, lpBuffer, sizeof(lpBuffer)); 	
      MessageBox (NULL, lpBuffer, "SERVER32", MB_OK | MB_ICONSTOP);
      return 0;
    }
  }



  hInst = hInstance;

  wc.style = 0;
  wc.lpfnWndProc = (WNDPROC)MainWndProc;
  wc.cbClsExtra = 0;
  wc.cbWndExtra = 0;
  wc.hInstance = hInstance;
  wc.hIcon = LoadIcon (hInstance, "npserver");
  wc.hCursor = LoadCursor (NULL, IDC_ARROW);
  wc.hbrBackground = GetStockObject (WHITE_BRUSH);
  wc.lpszMenuName = "PipeMenu";
  wc.lpszClassName = "PipeWClass";

  RegisterClass(&wc);

  LoadString(hInst, IDS_WINDOWTITLE, lpBuffer, sizeof(lpBuffer)); 	
  hWnd = CreateWindow ("PipeWClass",
                       lpBuffer,
                       WS_OVERLAPPEDWINDOW,
                       CW_USEDEFAULT,
                       CW_USEDEFAULT,
                       CW_USEDEFAULT,
                       CW_USEDEFAULT,
                       NULL,
                       NULL,
                       hInstance,
                       NULL);


  ShowWindow (hWnd, nCmdShow);

  while (GetMessage (&msg, NULL, 0, 0))
    DispatchMessage (&msg);

  return (msg.wParam);

}

LONG CALLBACK MainWndProc (HWND   hwnd,
                           UINT   message,
                           WPARAM wParam,
                           LPARAM lParam)
{

  LONG        lpServerThreadID;
  PAINTSTRUCT paintStruct;
  HDC         hDC;

  switch (message)
      {
        case WM_PAINT:
           // DrawBranch is used to paint the spools and text to the window.
           hDC = BeginPaint (hwnd, &paintStruct);
           DrawBranch (hDC);
           EndPaint (hwnd, &paintStruct);
           return(0);

        case WM_CREATE :
           // Create the first instance of a server side of the pipe.
           CreateThread ((LPSECURITY_ATTRIBUTES)NULL,       // No security.
                         (DWORD)0,                          // Same stack size.
                         (LPTHREAD_START_ROUTINE)ServerProc,// Thread procedure.
                         (LPVOID)&hwnd,                     // Parameter.
                         (DWORD)0,                          // Start immediatly.
                         (LPDWORD)&lpServerThreadID);       // Thread ID.
           return (0);

        case WM_DESTROY :
           PostQuitMessage (0);
           return (0);
       }
    return DefWindowProc (hwnd, message, wParam, lParam);
}



/*************************************************************************\
*
*  PROCEDURE: ServerProc (HWND *hWnd)
*
*    A thread procedure, which creates an instance of the server side of
*    the named pipe, and then blocks waiting for a client to connect.
*    Once the client connects, a global array is updated with the specific
*    clients information, and this procedure is called again
*    to launch another waiting server thread.  After launching the new
*    thread, this thread begins to loop, reading the named pipe.  When
*    a message comes from its client, it uses TellAll() to broadcast
*    the message to the other clients in the array.
*
*  CALLED BY:
*
*    ServerProc();
*    WinMain();
*
*  CALLS TO:
*
*    TellAll();
*    ServerProc().
*
*  COMMENTS:
*
*    Clients is a global array which hold information on each client
*    connected to the named pipe.  This procedure recieves a buffer.
*    It then steps through this global array, and for each client it
*    writes the buffer.
*
\*************************************************************************/

VOID ServerProc(HWND *hWnd)
 {
   HANDLE hPipe;                       // Pipe handle.
   CHAR   inBuf[IN_BUF_SIZE] = "";     // Input buffer for pipe.
   DWORD  ServerThreadID;              // Used for CreateThread().

   CHAR   errorBuf[LINE_LEN] = "";     // Used for error messages.
   DWORD  bytesRead;                   // Used in ReadFile().
   DWORD  retCode;                     // Used to trap return codes.
   DWORD  clientIndex;                 // Index into global array, for this
                                       // instances client.
   DWORD  lastError;                   // Traps returns from GetLastError().
   BOOL   ExitLoop = FALSE;            // Boolean Flag to exit loop.

   OVERLAPPED OverLapWrt;              // Overlapped structure for writing.
   HANDLE     hEventWrt;               // Event handle for overlapped write.

   OVERLAPPED OverLapRd;               // Overlapped structure for reading.
   HANDLE     hEventRd;                // Event handle for overlapped reads.
   DWORD        bytesTransRd;          // Bytes transferred by overlapped.
   PSECURITY_DESCRIPTOR    pSD;
   SECURITY_ATTRIBUTES     sa;

                                       // create a security NULL security
                                       // descriptor, one that allows anyone
                                       // to write to the pipe... WARNING
                                       // entering NULL as the last attribute
                                       // of the CreateNamedPipe() will
                                       // indicate that you wish all
                                       // clients connecting to it to have
                                       // all of the same security attributes
                                       // as the user that started the
                                       // pipe server.

   pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR,
               SECURITY_DESCRIPTOR_MIN_LENGTH);

   if (pSD == NULL)
     {
     MessageBox (*hWnd, "Error in LocalAlloc for pSD",
                 "Debug: ServerProc()", MB_OK);
     return;
     }

   if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION))
     {
     wsprintf (errorBuf, "Error: InitializeSecurityDescriptor() %d",
               GetLastError());
     MessageBox (*hWnd, errorBuf, "Debug: ServerProc()", MB_OK);
       LocalFree((HLOCAL)pSD);
       return;
     }

                                       // add a NULL disc. ACL to the
                                       // security descriptor.

   if (!SetSecurityDescriptorDacl(pSD, TRUE, (PACL) NULL, FALSE))
     {
     wsprintf (errorBuf, "Error: SetSecurityDescriptorDacl() %d",
                GetLastError());
     MessageBox (*hWnd, errorBuf, "Debug: ServerProc()", MB_OK);
     LocalFree((HLOCAL)pSD);
     return;
     }

   sa.nLength = sizeof(sa);
   sa.lpSecurityDescriptor = pSD;
   sa.bInheritHandle = TRUE;

                                       // Create a local named pipe with
                                       // the name '\\.\PIPE\test'.  The
                                       // '.' signifies local pipe.
   hPipe = CreateNamedPipe ("\\\\.\\PIPE\\test", // Pipe name = 'test'.
               PIPE_ACCESS_DUPLEX                // 2 way pipe.
               | FILE_FLAG_OVERLAPPED,           // Use overlapped structure.
               PIPE_WAIT                         // Wait on messages.
               | PIPE_READMODE_MESSAGE           // Specify message mode pipe.
               | PIPE_TYPE_MESSAGE,
               MAX_PIPE_INSTANCES,               // Maximum instance limit.
               OUT_BUF_SIZE,                     // Buffer sizes.
               IN_BUF_SIZE,
               TIME_OUT,                         // Specify time out.
               &sa);                             // Security attributes.

                                       // Check Errors.
    if ((DWORD)hPipe == 0xFFFFFFFF)
     {

     retCode = GetLastError();         // Report any error, it should always succeed.
     LoadString(hInst, IDS_ERRORCODE, lpBuffer, sizeof(lpBuffer));
     wsprintf (errorBuf, lpBuffer, retCode);
     LoadString(hInst, IDS_DEBUGTITLE, lpBuffer, sizeof(lpBuffer));

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久伊99综合婷婷久久伊| av高清不卡在线| 亚洲一区影音先锋| 亚洲欧美在线aaa| 国产精品久久久久永久免费观看| 精品久久人人做人人爽| 欧美一个色资源| 在线91免费看| 精品久久国产老人久久综合| 日韩精品一区二区三区在线| 欧美精品一区二区久久婷婷| 国产亚洲精品超碰| 国产校园另类小说区| 国产精品久久久99| 亚洲人午夜精品天堂一二香蕉| 亚洲日本在线a| 亚洲电影一级黄| 亚洲一二三区在线观看| 亚洲一级不卡视频| 奇米777欧美一区二区| 国产真实乱子伦精品视频| 成人在线视频一区二区| eeuss影院一区二区三区| 91蜜桃在线观看| 欧美精品视频www在线观看| 日韩一级成人av| 国产欧美一区二区精品婷婷| 亚洲日本在线天堂| 日韩—二三区免费观看av| 国内精品国产三级国产a久久| 丁香天五香天堂综合| 欧洲精品一区二区三区在线观看| 91麻豆精品国产91久久久使用方法 | 色综合久久久网| 91麻豆精品国产91久久久使用方法 | 亚洲国产日产av| 激情综合色播激情啊| 成人av在线看| 欧美日韩成人综合在线一区二区| 久久亚洲私人国产精品va媚药| 婷婷中文字幕综合| 久草中文综合在线| 91美女精品福利| 久久婷婷久久一区二区三区| 一区二区三区在线观看动漫| 免费成人在线观看视频| 91美女片黄在线观看91美女| 精品精品欲导航| 亚洲午夜视频在线观看| 高清国产午夜精品久久久久久| 欧美日韩一区二区三区四区| 国产精品女人毛片| 老司机午夜精品99久久| 91成人看片片| 国产精品久久一卡二卡| 国内精品写真在线观看| 欧美精品亚洲二区| 一个色综合av| 91丨九色丨蝌蚪丨老版| 国产欧美日韩另类一区| 日本欧美加勒比视频| 欧美在线一区二区三区| 国产精品盗摄一区二区三区| 国产精品亚洲一区二区三区在线| 欧美人牲a欧美精品| 亚洲精品国产一区二区精华液 | 麻豆国产一区二区| 欧美午夜免费电影| 亚洲综合另类小说| 99久久国产免费看| 国产精品美女www爽爽爽| 国产真实乱对白精彩久久| 日韩视频免费观看高清完整版| 亚洲综合男人的天堂| 91福利小视频| 一区二区成人在线| 欧美日韩综合在线免费观看| 亚洲国产aⅴ成人精品无吗| 色综合久久99| 亚洲综合清纯丝袜自拍| 欧美视频在线一区| 亚洲午夜免费福利视频| 欧美日本视频在线| 青青草97国产精品免费观看无弹窗版 | 国产综合色视频| 久久久精品欧美丰满| 国产精品一区专区| 中文字幕精品三区| 91老司机福利 在线| 亚洲国产精品一区二区尤物区| 欧美午夜理伦三级在线观看| 日韩电影免费一区| 日韩三级伦理片妻子的秘密按摩| 麻豆一区二区在线| 国产欧美一区视频| 91久久一区二区| 午夜精品久久久久影视| 欧美mv日韩mv| av电影在线观看完整版一区二区| 一区二区成人在线| 日韩欧美国产成人一区二区| 国产精品亚洲综合一区在线观看| 中文字幕人成不卡一区| 欧美午夜精品电影| 国内成+人亚洲+欧美+综合在线| 国产精品欧美一级免费| 欧美精品一二三| 国产成人免费在线视频| 亚洲综合网站在线观看| 精品国产一区二区三区av性色| 成人av一区二区三区| 亚洲国产精品久久久久秋霞影院| 欧美岛国在线观看| av男人天堂一区| 精品一二三四在线| 一区二区三区在线播放| 久久免费电影网| 欧美午夜电影网| 成人性生交大片免费看中文| 午夜视频在线观看一区| 欧美国产国产综合| 欧美成人免费网站| 在线亚洲欧美专区二区| 国产成人在线视频网站| 亚洲午夜国产一区99re久久| 久久久精品黄色| 欧美狂野另类xxxxoooo| 99久久综合狠狠综合久久| 蜜乳av一区二区| 亚洲图片欧美综合| 亚洲免费观看高清完整版在线观看 | 中文字幕高清一区| 欧美一区二区三区影视| 91丨九色porny丨蝌蚪| 国产在线视频不卡二| 国产一区二区三区高清播放| 一区二区三区成人| 欧美国产日产图区| 久久午夜色播影院免费高清 | 精品久久久久久无| 精品视频在线看| 色美美综合视频| 91在线视频在线| 99久久国产综合精品麻豆 | 国产精品高清亚洲| 精品女同一区二区| 欧美一区二区三区爱爱| 欧美日韩成人综合在线一区二区| 在线观看视频一区二区欧美日韩| www.亚洲人| 福利一区二区在线| 国产传媒一区在线| 国产一区二区三区在线观看免费| 日本美女视频一区二区| 日韩极品在线观看| 蜜桃视频一区二区| 蜜臀va亚洲va欧美va天堂| 日韩黄色免费电影| 美美哒免费高清在线观看视频一区二区| 亚洲国产视频直播| 亚洲国产日日夜夜| 午夜电影一区二区| 精品一区免费av| 国产精品白丝jk黑袜喷水| 国产成人综合网站| av中文字幕不卡| 在线视频你懂得一区| 欧美日韩另类国产亚洲欧美一级| 欧美久久婷婷综合色| 欧美草草影院在线视频| 久久只精品国产| 国产精品九色蝌蚪自拍| 一级特黄大欧美久久久| 日韩成人一区二区| 国产电影一区二区三区| 91网站视频在线观看| 欧美日韩综合不卡| 精品国内二区三区| 亚洲欧美怡红院| 日韩成人午夜精品| 国产精品资源网站| 欧美午夜精品久久久久久孕妇| 欧美丰满嫩嫩电影| 欧美经典一区二区三区| 亚洲免费观看高清| 久久99精品一区二区三区三区| 成人动漫视频在线| 91精品国产欧美一区二区18| 国产亚洲美州欧州综合国| 亚洲一区二区综合| 精品中文av资源站在线观看| jlzzjlzz欧美大全| 日韩欧美国产小视频| 国产日本欧美一区二区| 性久久久久久久久| 成人v精品蜜桃久久一区| 欧美一级黄色录像| 亚洲品质自拍视频网站| 国产麻豆成人精品| 欧美精品少妇一区二区三区|