home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / netds / winsock / ipxchat / winmain.c < prev   
C/C++ Source or Header  |  1997-10-05  |  3KB  |  91 lines

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (C) 1993-1997  Microsoft Corporation.  All Rights Reserved.
  7. //
  8. //  MODULE:   winmain.c
  9. //
  10. //  PURPOSE:   Calls initialization functions and processes the message loop
  11. //
  12. //
  13. //  PLATFORMS: Windows 95, Windows NT
  14. //
  15. //  FUNCTIONS:
  16. //    WinMain() - calls initialization functions, processes message loop
  17. //
  18. //  COMMENTS:
  19. //
  20. //
  21.  
  22. #include <windows.h>            // required for all Windows applications
  23. #include <wsipx.h>              // IPX Socket defs
  24. #include "globals.h"            // prototypes specific to this application
  25.  
  26. //
  27. //  FUNCTION: WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  28. //
  29. //  PURPOSE: calls initialization function, processes message loop
  30. //
  31. //  PARAMETERS:
  32. //
  33. //    hInstance - The handle to the instance of this application that
  34. //          is currently being executed.
  35. //
  36. //    hPrevInstance - This parameter is always NULL in Win32
  37. //          applications.
  38. //
  39. //    lpCmdLine - A pointer to a null terminated string specifying the
  40. //          command line of the application.
  41. //
  42. //    nCmdShow - Specifies how the main window is to be diplayed.
  43. //
  44. //  RETURN VALUE:
  45. //    If the function terminates before entering the message loop,
  46. //    return FALSE.
  47. //    Otherwise, return the WPARAM value sent by the WM_QUIT message.
  48. //
  49. //
  50. //  COMMENTS:
  51. //
  52. //    Windows recognizes this function by name as the initial entry point
  53. //    for the program.  This function calls the initialization routine
  54. //    It then executes a message retrieval and dispatch loop that is the
  55. //    top-level control structure for the remainder of execution.  The
  56. //    loop is terminated when a WM_QUIT  message is received, at which
  57. //    time this function exits the application instance by returning the
  58. //    value passed by PostQuitMessage().
  59. //
  60. //    If this function must abort before entering the message loop, it
  61. //    returns the conventional value NULL.
  62. //
  63.  
  64. int APIENTRY WinMain(HINSTANCE hInstance,
  65.                      HINSTANCE hPrevInstance, 
  66.                      LPSTR     lpCmdLine, 
  67.                      int       nCmdShow)
  68. {
  69.     MSG msg;
  70.     HANDLE hAccelTable;
  71.  
  72.     // Initialize application by setting up the main window.
  73.     if (!InitApplication(hInstance, nCmdShow))
  74.     {
  75.         return FALSE;           // Exits if unable to initialize
  76.     }
  77.  
  78.     hAccelTable = LoadAccelerators(hInstance, szAppName);
  79.  
  80.     // Acquire and dispatch messages until a WM_QUIT message is received.
  81.     while (GetMessage(&msg, NULL, 0, 0))
  82.     {
  83.         if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
  84.         {
  85.             TranslateMessage(&msg);  // Translates virtual key codes
  86.             DispatchMessage(&msg);   // Dispatches message to window
  87.         }
  88.     }
  89.     return msg.wParam;  // Returns the value from PostQuitMessage
  90. }
  91.