DavidNorgren

Untitled

Feb 25th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. // Main entry of the program.
  2. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) {
  3.     MSG msg;
  4.     char mailslotName[50];
  5.     curId = 0;
  6.  
  7.     // Set up mailslots
  8.     serverMailSlot = mailslotConnect("serverMailSlot");
  9.     if (serverMailSlot == INVALID_HANDLE_VALUE) {
  10.         MessageBox(NULL, "Failed to get a handle to the mailslot!!\nHave you started the server?", "Error", 0);
  11.         return TRUE;
  12.     }
  13.  
  14.     sprintf_s(mailslotName, sizeof(mailslotName), "clientMailSlot%d", GetCurrentProcessId());
  15.     clientMailSlot = mailslotCreate(mailslotName);
  16.     mailslotConnect(mailslotName);
  17.  
  18.     // Create lists
  19.     localList = LL_Create();
  20.     serverList = LL_Create();
  21.  
  22.     // Start up dialogs
  23.     dialogMain = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(dlgMain), 0, dialogMainProc);
  24.     if (dialogMain != NULL)
  25.         ShowWindow(dialogMain, SW_SHOW);
  26.  
  27.     dialogAdd = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(dlgAdd), 0, dialogAddProc);
  28.     if (dialogAdd != NULL)
  29.         ShowWindow(dialogAdd, SW_HIDE);
  30.  
  31.     while (GetMessage(&msg, NULL, 0, 0)) {
  32.         if (!IsDialogMessage(dialogMain, &msg) && !IsDialogMessage(dialogAdd, &msg)) {
  33.             TranslateMessage(&msg);
  34.             DispatchMessage(&msg);
  35.         }
  36.     }
  37.     return 1;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment