Source code of Windows XP (NT5)
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.

190 lines
5.4 KiB

  1. // C RunTime Header Files
  2. #include <windows.h>
  3. #include <commctrl.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <malloc.h>
  7. #include <memory.h>
  8. #include <tchar.h>
  9. #include <winbase.h>
  10. #include <shellapi.h>
  11. #include <Wtsapi32.h>
  12. #include <winuser.h>
  13. #include <winsta.h>
  14. // Local Header Files
  15. #include "resource.h"
  16. #define MAX_STATIONS 1024
  17. // Foward declarations
  18. //////////////////////////////////////////////////////////////////////////////
  19. ATOM MyRegisterClass(HINSTANCE hInstance);
  20. BOOL InitInstance(HINSTANCE, int);
  21. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  22. LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
  23. LRESULT CALLBACK SndMsg(HWND, UINT, WPARAM, LPARAM);
  24. int CALLBACK Sort(LPARAM lParam1, LPARAM lParam2, LPARAM lParamColumn);
  25. int CDECL MessageBoxPrintf(TCHAR *szCaption, TCHAR *szFormat, ...);
  26. int FillList(int nMcIndex);
  27. BOOL MyInitDialog(HWND hwnd);
  28. void SetRegKey(int i, LONG * nKeyValue);
  29. void DeleteRegKey(int i);
  30. BOOL CheckForRegKey(int i);
  31. int GetRegKeyValue(int i);
  32. void ShowMyIcon();
  33. //////////////////////////////////////////////////////////////////////////////
  34. //////////////////////////////////////////////////////////////////////////////
  35. #define MAX_LEN (MAX_PATH + 1)
  36. #define MAX_LOADSTRING 200
  37. #define COLUMNONEWIDTH 175
  38. #define COLUMNTWOWIDTH 100
  39. #define COLUMNTHREEWIDTH 124
  40. #define COLUMNFOURWIDTH 100
  41. //{"left", "top", "right", "bottom"};
  42. #define LEFT 0
  43. #define TOP 1
  44. #define RIGHT 2
  45. #define BOTTOM 3
  46. #define GREEN 0
  47. #define YELLOW 1
  48. #define RED 2
  49. //#define NONE 3
  50. // Global Variables:
  51. //////////////////////////////////////////////////////////////////////////////
  52. extern HINSTANCE hInst; // current instance
  53. extern TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
  54. extern TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
  55. extern TCHAR szAppName[];
  56. extern HWND hWnd;
  57. extern HWND g_hListView;
  58. extern int g_ColumnOneIndex;
  59. extern int g_ColumnTwoIndex;
  60. extern int g_ColumnThreeIndex;
  61. extern int g_ColumnFourIndex;
  62. extern TCHAR * pszColumn;
  63. extern TCHAR * pszColumn2;
  64. extern TCHAR * pszColumn3;
  65. extern TCHAR * pszColumn4;
  66. extern TCHAR szMcNames [MAX_STATIONS][MAX_LEN];
  67. extern TCHAR szMcAddress[MAX_STATIONS][MAX_LEN];
  68. extern TCHAR szMcID [MAX_STATIONS][MAX_LEN];
  69. extern TCHAR szBuild [MAX_STATIONS][MAX_LEN];
  70. extern TCHAR tmp[sizeof(TCHAR) * 50];
  71. extern TCHAR buf[sizeof(TCHAR) * 50];
  72. extern TCHAR *DayOfWeek[];
  73. extern TCHAR *KeyName[];
  74. extern const TCHAR szWinStaKey[];
  75. extern SYSTEMTIME lpSystemTime;
  76. extern HANDLE m_hThread;
  77. extern FILE *stream1;
  78. extern HMENU g_hMenu;
  79. //////////////////////////////////////////////////////////////////////////////
  80. // tray stuff
  81. //////////////////////////////////////////////////////////////////////////////
  82. #define ARRAYSIZE(x) ((sizeof(x) / sizeof(x[0])))
  83. #define PM_QUITTRAYTHREAD WM_USER
  84. #define PWM_TRAYICON WM_USER + 1
  85. #define PM_NOTIFYWAITING WM_USER + 2
  86. #define PWM_ACTIVATE WM_USER + 3
  87. #define PM_WINSTA WM_USER + 4
  88. #define PM_REMOVEWINSTA WM_USER + 5
  89. #define IDM_SYS_SHOW_ALL WM_USER + 6
  90. #define IDM_SYS_ABOUT WM_USER + 7
  91. #define FIND_TIMEOUT 5000 // Wait to to 5 seconds for a response
  92. //
  93. // Class to encapsulate all of the info needed to do a tray notification
  94. class CTrayNotification
  95. {
  96. public:
  97. CTrayNotification()
  98. {
  99. //ASSERT(0 && "Someone is using the default constuctor for CTrayNotification");
  100. ZeroMemory(this, sizeof(*this));
  101. }
  102. CTrayNotification(HWND hWnd,
  103. UINT uCallbackMessage,
  104. DWORD Message,
  105. HICON hIcon,
  106. LPTSTR pszTip)
  107. {
  108. m_hWnd = hWnd;
  109. m_uCallbackMessage = uCallbackMessage;
  110. m_Message = Message;
  111. m_hIcon = hIcon;
  112. if (pszTip)
  113. lstrcpyn(m_szTip, pszTip, ARRAYSIZE(m_szTip));
  114. else
  115. m_szTip[0] = TEXT('\0');
  116. }
  117. HWND m_hWnd;
  118. UINT m_uCallbackMessage;
  119. DWORD m_Message;
  120. HICON m_hIcon;
  121. TCHAR m_szTip[MAX_PATH];
  122. };
  123. extern CRITICAL_SECTION g_CSTrayThread;
  124. extern DWORD g_idTrayThread;
  125. extern HANDLE g_hTrayThread;
  126. extern HICON g_TrayIcons[];
  127. extern UINT g_cTrayIcons;
  128. extern const UINT idTrayIcons[];
  129. extern NOTIFYICONDATA NotifyIconData;
  130. extern DWORD g_idWinstaThread;
  131. extern HANDLE g_hWinstaThread;
  132. BOOL DeliverTrayNotification(CTrayNotification * pNot);
  133. DWORD TrayThreadMessageLoop(LPVOID);
  134. DWORD WinstaThreadMessageLoop(LPVOID);
  135. void GetWinStationInfo(void);
  136. void Tray_NotifyIcon(HWND hWnd,
  137. UINT uCallbackMessage,
  138. DWORD Message,
  139. HICON hIcon,
  140. LPCTSTR lpTip);
  141. void Tray_Notify(HWND hWnd, WPARAM wParam, LPARAM lParam);
  142. void ShowRunningInstance();
  143. HMENU LoadPopupMenu(HINSTANCE hinst, UINT id);
  144. //////////////////////////////////////////////////////////////////////////////
  145. // TS Session stuff
  146. //////////////////////////////////////////////////////////////////////////////
  147. extern WTS_SESSION_INFO *ppSessionInfo;
  148. extern TCHAR *ppBuffer;
  149. extern DWORD pBytesReturned;
  150. extern DWORD pCount;