Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1995-1996 Microsoft Corporation
  3. Module Name:
  4. main
  5. Abstract:
  6. Trivial WinMain() function, creates tabbed dialog "property pages"
  7. and then creates the dialog... interesting code is in dialog procedures.
  8. Author:
  9. Steve Firebaugh (stevefir) 31-Dec-1995
  10. Revision History:
  11. SPORDER.EXE, DLL, & LIB were shipped in Win32 SDK along with NT4.
  12. Comments:
  13. Code is generally ready to be compiled with UNICODE defined, however,
  14. we do not make use of this because EXE and DLL must also work on
  15. Windows 95.
  16. --*/
  17. #include <windows.h>
  18. #include <winsock2.h>
  19. #include <commctrl.h>
  20. #include "globals.h"
  21. HINSTANCE ghInst;
  22. int
  23. APIENTRY
  24. WinMain(
  25. HINSTANCE hInstance,
  26. HINSTANCE hPrevInstance,
  27. LPSTR lpCmdLine,
  28. int nCmdShow
  29. )
  30. {
  31. PROPSHEETPAGE psp[3];
  32. PROPSHEETHEADER psh;
  33. WSADATA WSAData;
  34. int iTab = 0;
  35. int r;
  36. DWORD dwWait;
  37. HANDLE hMutex;
  38. TCHAR pszMutextName[] = TEXT("sporder.exe");
  39. DBGOUT((TEXT("checked build.\n")));
  40. //
  41. // It is possible that we will have multiple instances running at the
  42. // same time... what we really want is the first to finish before the
  43. // second really gets going... for that reason, wait here on mutex
  44. //
  45. hMutex = CreateMutex (NULL, FALSE, pszMutextName);
  46. hMutex = OpenMutex (SYNCHRONIZE, FALSE, pszMutextName);
  47. dwWait = WaitForSingleObject (hMutex, 0);
  48. if (dwWait == WAIT_TIMEOUT)
  49. {
  50. OutputDebugString (TEXT("WaitForSingleObject, WAIT_TIMEOUT\n"));
  51. return TRUE;
  52. }
  53. //
  54. // Do global initializations.
  55. //
  56. ghInst = hInstance;
  57. InitCommonControls();
  58. memset (psp, 0, sizeof (psp));
  59. memset (&psh, 0, sizeof (psh));
  60. if (WSAStartup(MAKEWORD (2,2),&WSAData) == SOCKET_ERROR) {
  61. OutputDebugString (TEXT("WSAStartup failed\n"));
  62. return -1;
  63. }
  64. psp[iTab].dwSize = sizeof(PROPSHEETPAGE);
  65. psp[iTab].dwFlags = PSP_USETITLE;
  66. psp[iTab].hInstance = ghInst;
  67. psp[iTab].pszTemplate = TEXT("WS2SPDlg");
  68. psp[iTab].pszIcon = TEXT("");
  69. psp[iTab].pfnDlgProc = SortDlgProc;
  70. psp[iTab].pszTitle = TEXT("Service Providers");
  71. psp[iTab].lParam = 0;
  72. iTab++;
  73. psp[iTab].dwSize = sizeof(PROPSHEETPAGE);
  74. psp[iTab].dwFlags = PSP_USETITLE;
  75. psp[iTab].hInstance = ghInst;
  76. psp[iTab].pszTemplate = TEXT("RNRSPDlg");
  77. psp[iTab].pszIcon = TEXT("");
  78. psp[iTab].pfnDlgProc = RNRDlgProc;
  79. psp[iTab].pszTitle = TEXT("Name Resolution ");
  80. psp[iTab].lParam = 0;
  81. iTab++;
  82. psh.dwSize = sizeof(PROPSHEETHEADER);
  83. psh.dwFlags = PSH_PROPSHEETPAGE ; // | PSH_NOAPPLYNOW ; // | PSH_HASHELP ;
  84. psh.hwndParent = NULL;
  85. psh.hInstance = ghInst;
  86. psh.pszIcon = TEXT("");
  87. psh.pszCaption = TEXT("Windows Sockets Configuration");
  88. psh.nPages = iTab;
  89. psh.ppsp = (LPCPROPSHEETPAGE) &psp;
  90. //
  91. // Finally display the dialog with the property sheets.
  92. //
  93. //
  94. // Sundown: Possible truncation here from INT_PTR to int in the return value.
  95. // However, WinMain returns an exit value which is still a 32bit value.
  96. //
  97. r = (int)PropertySheet(&psh);
  98. //
  99. // Cleanup sockets, release mutex, and close handle
  100. //
  101. WSACleanup ();
  102. ReleaseMutex (hMutex);
  103. CloseHandle (hMutex);
  104. return r;
  105. }
  106. #if DBG
  107. void
  108. _cdecl
  109. DbgPrint(
  110. PTCH Format,
  111. ...
  112. )
  113. /*++
  114. Write debug output messages if compiled with DEBUG
  115. --*/
  116. {
  117. TCHAR buffer[MAX_PATH];
  118. va_list marker;
  119. va_start (marker,Format);
  120. wvsprintf (buffer,Format, marker);
  121. OutputDebugString (TEXT("SPORDER.EXE: "));
  122. OutputDebugString (buffer);
  123. return;
  124. }
  125. #endif