├── README.TXT ├── README.md ├── WinMTR.ico ├── WinMTR.rc ├── WinMTR.sln ├── WinMTR.suo ├── WinMTR.v12.suo ├── WinMTR.vcxproj ├── WinMTRDialog.cpp ├── WinMTRDialog.h ├── WinMTRGlobal.cpp ├── WinMTRGlobal.h ├── WinMTRHelp.cpp ├── WinMTRHelp.h ├── WinMTRLicense.cpp ├── WinMTRLicense.h ├── WinMTRMain.cpp ├── WinMTRMain.h ├── WinMTRNet.cpp ├── WinMTRNet.h ├── WinMTROptions.cpp ├── WinMTROptions.h ├── WinMTRProperties.cpp ├── WinMTRProperties.h ├── WinMTRStatusBar.cpp ├── WinMTRStatusBar.h └── resource.h /README.TXT: -------------------------------------------------------------------------------- 1 | WinMTR – Appnor's Free Network Diagnostic Tool - http://winmtr.net 2 | 3 | Thank you for downloading WinMTR v0.91! 4 | 5 | *** About *** 6 | 7 | WinMTR is a free MS Windows visual application that combines the functionality of the traceroute and ping in a single network diagnostic tool. WinMTR is Open Source Software, maintained by Appnor MSP, a fully managed hosting & cloud provider. 8 | 9 | It was started in 2000 by Vasile Laurentiu Stanimir as a clone for the popular Matt’s Traceroute (hence MTR) Linux/UNIX utility. 10 | Read more about WinMTR’s history: http://winmtr.net/history/ 11 | 12 | *** License & Redistribution *** 13 | 14 | WinMTR is offered as Open Source Software under GPL v2. 15 | Read more about the licensing conditions: http://www.gnu.org/licenses/gpl-2.0.html 16 | Download the code from: http://sourceforge.net/projects/winmtr/ 17 | 18 | *** Installation *** 19 | 20 | You will get a .zip archive containing two folders WinMTR-32 and WinMTR-64. 21 | Both contain two files: WinMTR.exe and README.TXT. 22 | Just extract the WinMTR.exe for your platform (32 or 64 bit) and click to run it. 23 | If you don’t know what version you need, just click on both files and see which one works ;-) 24 | As you can see, WinMTR requires no other installation effort. 25 | 26 | Trick: You can copy the WinMTR.exe file in Windows/System32 so it’s accessible via the command line – cmd! 27 | 28 | *** Usage *** 29 | 30 | Visual: 31 | 32 | * Start WinMTR. 33 | * Write the name or IP of the host (e.g. google.com) 34 | * Press the Options button to configure ping size, maximum hops and ping interval (the defaults are OK). 35 | * Push the Start button and wait. 36 | * Copy or export the results in text or HTML format. Useful if you want to document or file a complaint with your ISP. 37 | * Click on Clear History to remove the hosts you have previously traced. 38 | 39 | Command line: 40 | 41 | * Run winmtr.exe --help to see what are the options 42 | * Run winmtr hostname (e.g. winmtr www.yahoo.com) 43 | 44 | *** Troubleshooting *** 45 | 46 | a) I type in the address and nothing happens. 47 | 48 | Usually this has to do with lame anti-virus or firewall applications. Stop all that when doing debugging or when using WinMTR. Or, configure them properly. 49 | 50 | b) I get an error saying the program cannot be executed. 51 | 52 | You are running the 64 bit version on a 32 bit platform. Try the WinMTR.exe stored in the WinMTR_x32 folder. 53 | 54 | c) I get an error unspecified here. 55 | 56 | Please report it to us to make sure it’s not a bug in the application. 57 | 58 | 59 | *** Changelog *** 60 | 31.01.2011 - Version v0.92 is out, fixing reporting errors for very slow connections. 61 | 11.01.2011 - Version v0.91 is out under GPL v2, by popular request. 62 | 24.12.2010 - New version! for 32 and 64 bit Operating Systems. Now works on Windows 7 as a regular user. Various bug fixes. License changed from GPL to commercial, but not for long ;-) (v0.9) 63 | 20.01.2002 - Last entered hosts an options are now hold in registry. Home page and development moved to Sourceforge. 64 | 05.09.2001 - Replace edit box with combo box which hold last entered host names. Fixed a memory leak which caused program to crash after a long time running. (v0.7) 65 | 11.27.2000 - Added resizing support and flat buttons. (v0.6) 66 | 11.26.2000 - Added copy data to clipboard and possibility to save data to file as text or HTML.(v0.5) 67 | 08.03.2000 - Added double-click on host name in list for detailed information. (v0.4) 68 | 08.02.2000 - Fixed ICMP error codes handling. Print an error message corresponding to ICP_HOST_UNREACHABLE error code instead of a empty line. (v0.3) 69 | 08.01.2000 - Support for full command-line operations. (v0.2) 70 | 07.28.2000 - First release. (v0.1) 71 | 72 | *** Bug Reports **** 73 | 74 | Let us know if you identify bugs. Make sure you mention the WinMTR version. Also, we need as much info as possible about your Operating System and current setup. 75 | Before submitting a bug make sure it is not something related to your own specific configurations (e.g. anti-viruses, firewalls). 76 | 77 | *** Feature requests *** 78 | 79 | If you need some functionality from which others can also benefit, please let us know. We will try to integrate your request on our future releases. 80 | Specific features can be implemented on request under a commercial support agreement. Costs depend on complexity and timing. Contact us for a custom quotation. 81 | If you are a developer planning to extend the current open source code, please let us know, so we can integrate it in the official tree 82 | 83 | 84 | *** Contact *** 85 | 86 | Use the form available at http://winmtr.net or write to us contact AT winmtr DOT net 87 | 88 | (c) GPL v2 - 2010-2010 Appnor MSP S.A. - http://www.appnor.com 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WinMTR 显 ip 所在地版 2 | 3 | ## 用法 4 | 5 | 下载,编译,放入纯真ip库,运行。 6 | 7 | ## 瞩目 8 | 9 | 1. 本项目已经有编译好的版本,参见 [Releases](https://github.com/oott123/WinMTR/releases) 页面。 10 | 2. 要想自己编译的,可以参考 [这条V2EX上的相关讨论](https://www.v2ex.com/t/176537#reply10) 的 6#。 11 | -------------------------------------------------------------------------------- /WinMTR.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oott123/WinMTR/cf8f6833537ee3e91be54d5822bf36ac49015462/WinMTR.ico -------------------------------------------------------------------------------- /WinMTR.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "afxres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (United States) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 20 | #pragma code_page(1252) 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""afxres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "#define _AFX_NO_SPLITTER_RESOURCES\r\n" 42 | "#define _AFX_NO_OLE_RESOURCES\r\n" 43 | "#define _AFX_NO_TRACKER_RESOURCES\r\n" 44 | "#define _AFX_NO_PROPERTY_RESOURCES\r\n" 45 | "\r\n" 46 | "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" 47 | "#ifdef _WIN32\r\n" 48 | "LANGUAGE 9, 1\r\n" 49 | "#pragma code_page(1252)\r\n" 50 | "#endif //_WIN32\r\n" 51 | "#include ""afxres.rc"" // Standard components\r\n" 52 | "#endif\r\n" 53 | "\0" 54 | END 55 | 56 | #endif // APSTUDIO_INVOKED 57 | 58 | 59 | ///////////////////////////////////////////////////////////////////////////// 60 | // 61 | // Icon 62 | // 63 | 64 | // Icon with lowest ID value placed first to ensure application icon 65 | // remains consistent on all systems. 66 | IDR_MAINFRAME ICON "WinMTR.ico" 67 | 68 | ///////////////////////////////////////////////////////////////////////////// 69 | // 70 | // Dialog 71 | // 72 | 73 | IDD_WINMTR_DIALOG DIALOGEX 0, 0, 550, 340 74 | STYLE DS_SETFONT | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME 75 | EXSTYLE WS_EX_APPWINDOW 76 | FONT 9, "Microsoft YaHei", 0, 0, 0x1 77 | BEGIN 78 | DEFPUSHBUTTON "&Start",ID_RESTART,203,12,50,14,BS_FLAT 79 | PUSHBUTTON "&Options",ID_OPTIONS,270,12,51,14,BS_FLAT 80 | PUSHBUTTON "E&xit",IDCANCEL,328,12,49,14,BS_FLAT 81 | PUSHBUTTON "&Copy Text to clipboard",ID_CTTC,14,39,89,14,BS_FLAT 82 | PUSHBUTTON "Co&py HTML to clipboard",ID_CHTC,113,39,89,14,BS_FLAT 83 | PUSHBUTTON "Export &TEXT",ID_EXPT,270,39,51,14,BS_FLAT 84 | PUSHBUTTON "Export &HTML",ID_EXPH,328,39,49,14,BS_FLAT 85 | CONTROL "List1",IDC_LIST_MTR,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,60,376,126 86 | LTEXT "Host:",IDC_STATIC,13,12,20,13,SS_CENTERIMAGE 87 | GROUPBOX "",IDC_STATIC,7,3,251,29,BS_FLAT 88 | GROUPBOX "",IDC_STATICS,263,3,120,29,BS_FLAT 89 | GROUPBOX "",IDC_STATICJ,7,31,376,26,BS_FLAT 90 | COMBOBOX IDC_COMBO_HOST,35,12,164,73,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP 91 | END 92 | 93 | IDD_DIALOG_OPTIONS DIALOGEX 0, 0, 251, 164 94 | STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU 95 | CAPTION "Options" 96 | FONT 9, "Microsoft YaHei", 0, 0, 0x0 97 | BEGIN 98 | DEFPUSHBUTTON "&OK",IDOK,53,143,50,14,BS_FLAT 99 | PUSHBUTTON "&Cancel",IDCANCEL,141,143,50,14,BS_FLAT 100 | GROUPBOX "",IDC_STATIC,7,91,237,46,BS_FLAT 101 | ICON IDR_MAINFRAME,IDC_STATIC,15,12,20,20 102 | LTEXT "Interval (sec):",IDC_STATIC,15,102,45,10,NOT WS_GROUP 103 | EDITTEXT IDC_EDIT_INTERVAL,71,99,34,13,ES_AUTOHSCROLL 104 | LTEXT "Ping size (bytes):",IDC_STATIC,139,102,53,10,NOT WS_GROUP 105 | EDITTEXT IDC_EDIT_SIZE,196,99,34,13,ES_AUTOHSCROLL | ES_NUMBER 106 | CONTROL "Resolve names",IDC_CHECK_DNS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,119,63,8 107 | GROUPBOX "",IDC_STATIC,7,7,237,82,BS_FLAT 108 | CTEXT "Get Fully Managed Dedicated and Cloud hosting in Europe and USA at killer prices.",IDC_STATIC,31,35,201,17 109 | CTEXT "WinMTR v0.92 is offered under GPL V2 by Appnor MSP",IDC_STATIC,42,14,194,17 110 | PUSHBUTTON "&License and Credits",ID_LICENSE,81,67,94,14,BS_FLAT 111 | LTEXT "Max. hosts in LRU list:",IDC_STATIC,15,119,74,10,NOT WS_GROUP 112 | EDITTEXT IDC_EDIT_MAX_LRU,90,116,34,13,ES_AUTOHSCROLL 113 | CONTROL "www.appnor.com",IDC_MFCLINK1,"MfcLink",WS_TABSTOP,102,51,60,11 114 | END 115 | 116 | IDD_DIALOG_LICENSE DIALOGEX 0, 0, 175, 70 117 | STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU 118 | CAPTION "License & Credits" 119 | FONT 9, "Microsoft YaHei", 0, 0, 0x0 120 | BEGIN 121 | DEFPUSHBUTTON "OK",IDOK,59,43,50,14 122 | LTEXT "Read more on",IDC_STATIC,36,27,46,8 123 | CONTROL "www.winmtr.net",IDC_MFCLINK1,"MfcLink",WS_TABSTOP,83,26,60,14 124 | LTEXT "WinMTR is licensed under GPL V2.",IDC_STATIC,33,14,113,8 125 | END 126 | 127 | IDD_DIALOG_PROPERTIES DIALOG 0, 0, 201, 159 128 | STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU 129 | CAPTION "Host properties" 130 | FONT 9, "Microsoft YaHei" 131 | BEGIN 132 | DEFPUSHBUTTON "OK",IDOK,71,138,50,14,BS_FLAT 133 | LTEXT "Name:",IDC_STATIC,15,18,24,8 134 | EDITTEXT IDC_EDIT_PHOST,48,16,136,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY 135 | LTEXT "IP Address:",IDC_STATIC,14,32,40,9 136 | EDITTEXT IDC_EDIT_PIP,58,31,126,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY 137 | GROUPBOX "Packets",IDC_STATIC,7,74,89,60,BS_FLAT 138 | GROUPBOX "Ping time",IDC_STATIC,108,74,86,60,BS_FLAT 139 | GROUPBOX "Host",IDC_STATIC,7,7,187,62,BS_FLAT 140 | LTEXT "Loss (%):",IDC_STATIC,13,117,31,9 141 | LTEXT "Received:",IDC_STATIC,13,101,36,9 142 | LTEXT "Sent:",IDC_STATIC,13,85,21,9 143 | LTEXT "Last:",IDC_STATIC,114,84,18,9 144 | LTEXT "Best:",IDC_STATIC,114,96,20,8 145 | LTEXT "Average:",IDC_STATIC,114,107,32,8 146 | LTEXT "Worst:",IDC_STATIC,114,118,23,8 147 | EDITTEXT IDC_EDIT_PSENT,53,82,35,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER 148 | EDITTEXT IDC_EDIT_PRECV,53,99,35,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER 149 | EDITTEXT IDC_EDIT_PLOSS,53,116,35,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER 150 | EDITTEXT IDC_EDIT_PLAST,150,81,34,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY 151 | EDITTEXT IDC_EDIT_PBEST,150,94,34,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY 152 | EDITTEXT IDC_EDIT_PAVRG,150,106,34,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY 153 | EDITTEXT IDC_EDIT_PWORST,150,118,34,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY 154 | EDITTEXT IDC_EDIT_PCOMMENT,14,50,170,12,ES_AUTOHSCROLL | ES_READONLY 155 | END 156 | 157 | IDD_DIALOG_HELP DIALOGEX 0, 0, 256, 122 158 | STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU 159 | CAPTION "WinMTR" 160 | FONT 8, "MS Shell Dlg", 400, 0, 0x1 161 | BEGIN 162 | DEFPUSHBUTTON "OK",IDOK,144,101,50,14 163 | CONTROL "www.appnor.com",IDC_MFCLINK1,"MfcLink",WS_TABSTOP,187,8,60,11 164 | LTEXT "WinMTR v0.92 is offered under GPL V2 by Appnor MSP",IDC_STATIC,7,9,176,10 165 | LTEXT "Usage: WinMTR [options] target_host_name",IDC_STATIC,7,29,144,8 166 | LTEXT "Options:",IDC_STATIC,7,39,28,8 167 | LTEXT " --interval, -i VALUE. Set ping interval.",IDC_STATIC,26,47,131,8 168 | LTEXT " --size, -s VALUE. Set ping size.",IDC_STATIC,26,57,109,8 169 | LTEXT " --maxLRU, -m VALUE. Set max hosts in LRU list.",IDC_STATIC,26,67,163,8 170 | LTEXT " --help, -h. Print this help.",IDC_STATIC,26,89,92,8 171 | LTEXT " --numeric, -n. Do not resolve names.",IDC_STATIC,26,78,129,8 172 | END 173 | 174 | 175 | ///////////////////////////////////////////////////////////////////////////// 176 | // 177 | // Version 178 | // 179 | 180 | VS_VERSION_INFO VERSIONINFO 181 | FILEVERSION 0,9,0,2 182 | PRODUCTVERSION 0,9,0,2 183 | FILEFLAGSMASK 0x3fL 184 | #ifdef _DEBUG 185 | FILEFLAGS 0x1L 186 | #else 187 | FILEFLAGS 0x0L 188 | #endif 189 | FILEOS 0x4L 190 | FILETYPE 0x1L 191 | FILESUBTYPE 0x0L 192 | BEGIN 193 | BLOCK "StringFileInfo" 194 | BEGIN 195 | BLOCK "040904b0" 196 | BEGIN 197 | VALUE "FileDescription", "WinMTR by Appnor MSP - www.winmtr.net" 198 | VALUE "FileVersion", "0.9.0.2" 199 | VALUE "InternalName", "WinMTR" 200 | VALUE "LegalCopyright", "WinMTR 0.9 (c) 2010-2011 Appnor MSP - Fully Managed Hosting & Cloud Provider www.appnor.com" 201 | VALUE "OriginalFilename", "WinMTR.EXE" 202 | VALUE "ProductName", "WinMTR Application" 203 | VALUE "ProductVersion", "0.9.0.2" 204 | END 205 | END 206 | BLOCK "VarFileInfo" 207 | BEGIN 208 | VALUE "Translation", 0x409, 1200 209 | END 210 | END 211 | 212 | 213 | ///////////////////////////////////////////////////////////////////////////// 214 | // 215 | // DESIGNINFO 216 | // 217 | 218 | #ifdef APSTUDIO_INVOKED 219 | GUIDELINES DESIGNINFO 220 | BEGIN 221 | IDD_WINMTR_DIALOG, DIALOG 222 | BEGIN 223 | LEFTMARGIN, 7 224 | RIGHTMARGIN, 383 225 | VERTGUIDE, 270 226 | VERTGUIDE, 321 227 | VERTGUIDE, 328 228 | VERTGUIDE, 377 229 | TOPMARGIN, 7 230 | BOTTOMMARGIN, 186 231 | HORZGUIDE, 12 232 | HORZGUIDE, 39 233 | END 234 | 235 | IDD_DIALOG_OPTIONS, DIALOG 236 | BEGIN 237 | LEFTMARGIN, 7 238 | RIGHTMARGIN, 244 239 | TOPMARGIN, 7 240 | BOTTOMMARGIN, 157 241 | END 242 | 243 | IDD_DIALOG_LICENSE, DIALOG 244 | BEGIN 245 | LEFTMARGIN, 7 246 | RIGHTMARGIN, 168 247 | TOPMARGIN, 7 248 | BOTTOMMARGIN, 63 249 | END 250 | 251 | IDD_DIALOG_PROPERTIES, DIALOG 252 | BEGIN 253 | LEFTMARGIN, 7 254 | RIGHTMARGIN, 194 255 | TOPMARGIN, 7 256 | BOTTOMMARGIN, 152 257 | END 258 | 259 | IDD_DIALOG_HELP, DIALOG 260 | BEGIN 261 | LEFTMARGIN, 7 262 | RIGHTMARGIN, 249 263 | VERTGUIDE, 26 264 | TOPMARGIN, 7 265 | BOTTOMMARGIN, 115 266 | END 267 | END 268 | #endif // APSTUDIO_INVOKED 269 | 270 | 271 | ///////////////////////////////////////////////////////////////////////////// 272 | // 273 | // Dialog Info 274 | // 275 | 276 | IDD_DIALOG_HELP DLGINIT 277 | BEGIN 278 | IDC_MFCLINK1, 0x37c, 238, 0 279 | 0x4d3c, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x683e, 0x7474, 0x3a70, 280 | 0x2f2f, 0x7777, 0x2e77, 0x7061, 0x6e70, 0x726f, 0x632e, 0x6d6f, 0x3f2f, 281 | 0x7475, 0x5f6d, 0x6f73, 0x7275, 0x6563, 0x773d, 0x6e69, 0x746d, 0x2672, 282 | 0x7475, 0x5f6d, 0x656d, 0x6964, 0x6d75, 0x643d, 0x7365, 0x746b, 0x706f, 283 | 0x7526, 0x6d74, 0x635f, 0x6d61, 0x6170, 0x6769, 0x3d6e, 0x6f73, 0x7466, 284 | 0x6177, 0x6572, 0x2f3c, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 0x7255, 0x3e6c, 285 | 0x4d3c, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x7250, 0x6665, 0x7869, 286 | 0x3c3e, 0x4d2f, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x7250, 0x6665, 287 | 0x7869, 0x3c3e, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 0x6f54, 0x6c6f, 0x6974, 288 | 0x3e70, 0x2f3c, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 0x6f54, 0x6c6f, 0x6974, 289 | 0x3e70, 0x4d3c, 0x4346, 0x694c, 0x6b6e, 0x465f, 0x6c75, 0x546c, 0x7865, 290 | 0x5474, 0x6f6f, 0x746c, 0x7069, 0x463e, 0x4c41, 0x4553, 0x2f3c, 0x464d, 291 | 0x4c43, 0x6e69, 0x5f6b, 0x7546, 0x6c6c, 0x6554, 0x7478, 0x6f54, 0x6c6f, 292 | 0x6974, 0x3e70, 293 | 0 294 | END 295 | 296 | IDD_DIALOG_OPTIONS DLGINIT 297 | BEGIN 298 | IDC_MFCLINK1, 0x37c, 238, 0 299 | 0x4d3c, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x683e, 0x7474, 0x3a70, 300 | 0x2f2f, 0x7777, 0x2e77, 0x7061, 0x6e70, 0x726f, 0x632e, 0x6d6f, 0x3f2f, 301 | 0x7475, 0x5f6d, 0x6f73, 0x7275, 0x6563, 0x773d, 0x6e69, 0x746d, 0x2672, 302 | 0x7475, 0x5f6d, 0x656d, 0x6964, 0x6d75, 0x643d, 0x7365, 0x746b, 0x706f, 303 | 0x7526, 0x6d74, 0x635f, 0x6d61, 0x6170, 0x6769, 0x3d6e, 0x6f73, 0x7466, 304 | 0x6177, 0x6572, 0x2f3c, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 0x7255, 0x3e6c, 305 | 0x4d3c, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x7250, 0x6665, 0x7869, 306 | 0x3c3e, 0x4d2f, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x7250, 0x6665, 307 | 0x7869, 0x3c3e, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 0x6f54, 0x6c6f, 0x6974, 308 | 0x3e70, 0x2f3c, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 0x6f54, 0x6c6f, 0x6974, 309 | 0x3e70, 0x4d3c, 0x4346, 0x694c, 0x6b6e, 0x465f, 0x6c75, 0x546c, 0x7865, 310 | 0x5474, 0x6f6f, 0x746c, 0x7069, 0x463e, 0x4c41, 0x4553, 0x2f3c, 0x464d, 311 | 0x4c43, 0x6e69, 0x5f6b, 0x7546, 0x6c6c, 0x6554, 0x7478, 0x6f54, 0x6c6f, 312 | 0x6974, 0x3e70, 313 | 0 314 | END 315 | 316 | IDD_DIALOG_LICENSE DLGINIT 317 | BEGIN 318 | IDC_MFCLINK1, 0x37c, 157, 0 319 | 0x4d3c, 0x4346, 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x3c3e, 0x4d2f, 0x4346, 320 | 0x694c, 0x6b6e, 0x555f, 0x6c72, 0x3c3e, 0x464d, 0x4c43, 0x6e69, 0x5f6b, 321 | 0x7255, 0x506c, 0x6572, 0x6966, 0x3e78, 0x2f3c, 0x464d, 0x4c43, 0x6e69, 322 | 0x5f6b, 0x7255, 0x506c, 0x6572, 0x6966, 0x3e78, 0x4d3c, 0x4346, 0x694c, 323 | 0x6b6e, 0x545f, 0x6f6f, 0x746c, 0x7069, 0x3c3e, 0x4d2f, 0x4346, 0x694c, 324 | 0x6b6e, 0x545f, 0x6f6f, 0x746c, 0x7069, 0x3c3e, 0x464d, 0x4c43, 0x6e69, 325 | 0x5f6b, 0x7546, 0x6c6c, 0x6554, 0x7478, 0x6f54, 0x6c6f, 0x6974, 0x3e70, 326 | 0x4146, 0x534c, 0x3c45, 0x4d2f, 0x4346, 0x694c, 0x6b6e, 0x465f, 0x6c75, 327 | 0x546c, 0x7865, 0x5474, 0x6f6f, 0x746c, 0x7069, "\076" 328 | 0 329 | END 330 | 331 | 332 | ///////////////////////////////////////////////////////////////////////////// 333 | // 334 | // String Table 335 | // 336 | 337 | STRINGTABLE 338 | BEGIN 339 | IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed." 340 | IDS_STRING_SB_NAME "WinMTR v0.92 GPL V2 by Appnor MSP - Fully Managed Hosting & Cloud Provider" 341 | IDS_STRING_SB_PING "0000000" 342 | IDS_STRING_CLEAR_HISTORY "Clear History" 343 | END 344 | 345 | #endif // English (United States) resources 346 | ///////////////////////////////////////////////////////////////////////////// 347 | 348 | 349 | 350 | #ifndef APSTUDIO_INVOKED 351 | ///////////////////////////////////////////////////////////////////////////// 352 | // 353 | // Generated from the TEXTINCLUDE 3 resource. 354 | // 355 | #define _AFX_NO_SPLITTER_RESOURCES 356 | #define _AFX_NO_OLE_RESOURCES 357 | #define _AFX_NO_TRACKER_RESOURCES 358 | #define _AFX_NO_PROPERTY_RESOURCES 359 | 360 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 361 | #ifdef _WIN32 362 | LANGUAGE 9, 1 363 | #pragma code_page(1252) 364 | #endif //_WIN32 365 | #include "afxres.rc" // Standard components 366 | #endif 367 | 368 | ///////////////////////////////////////////////////////////////////////////// 369 | #endif // not APSTUDIO_INVOKED 370 | 371 | -------------------------------------------------------------------------------- /WinMTR.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinMTR", "WinMTR.vcxproj", "{EE7B51B5-96FC-BED3-F2A6-0713CECBB579}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {EE7B51B5-96FC-BED3-F2A6-0713CECBB579}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {EE7B51B5-96FC-BED3-F2A6-0713CECBB579}.Debug|Win32.Build.0 = Debug|Win32 16 | {EE7B51B5-96FC-BED3-F2A6-0713CECBB579}.Debug|x64.ActiveCfg = Debug|x64 17 | {EE7B51B5-96FC-BED3-F2A6-0713CECBB579}.Debug|x64.Build.0 = Debug|x64 18 | {EE7B51B5-96FC-BED3-F2A6-0713CECBB579}.Release|Win32.ActiveCfg = Release|Win32 19 | {EE7B51B5-96FC-BED3-F2A6-0713CECBB579}.Release|Win32.Build.0 = Release|Win32 20 | {EE7B51B5-96FC-BED3-F2A6-0713CECBB579}.Release|x64.ActiveCfg = Release|x64 21 | {EE7B51B5-96FC-BED3-F2A6-0713CECBB579}.Release|x64.Build.0 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /WinMTR.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oott123/WinMTR/cf8f6833537ee3e91be54d5822bf36ac49015462/WinMTR.suo -------------------------------------------------------------------------------- /WinMTR.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oott123/WinMTR/cf8f6833537ee3e91be54d5822bf36ac49015462/WinMTR.v12.suo -------------------------------------------------------------------------------- /WinMTR.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | 24 | {EE7B51B5-96FC-BED3-F2A6-0713CECBB579} 25 | 26 | 27 | 28 | Application 29 | false 30 | MultiByte 31 | v120 32 | 33 | 34 | Application 35 | false 36 | MultiByte 37 | v120 38 | 39 | 40 | Application 41 | false 42 | MultiByte 43 | v120 44 | 45 | 46 | Application 47 | false 48 | MultiByte 49 | v120 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | .\Release_x32\ 73 | .\Release_x32\ 74 | false 75 | 76 | 77 | .\Release_x64\ 78 | .\Release_x64\ 79 | false 80 | 81 | 82 | .\Debug_x32\ 83 | .\Debug_x32\ 84 | true 85 | 86 | 87 | .\Debug_x64\ 88 | .\Debug_x64\ 89 | true 90 | 91 | 92 | 93 | MultiThreaded 94 | OnlyExplicitInline 95 | true 96 | true 97 | MaxSpeed 98 | true 99 | Level3 100 | WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 101 | .\Release\ 102 | .\Release\WinMTR.pch 103 | .\Release\ 104 | .\Release\ 105 | 106 | 107 | true 108 | NDEBUG;%(PreprocessorDefinitions) 109 | .\Release\WinMTR.tlb 110 | true 111 | Win32 112 | 113 | 114 | 0x0409 115 | NDEBUG;%(PreprocessorDefinitions) 116 | 117 | 118 | true 119 | .\Release\WinMTR.bsc 120 | 121 | 122 | true 123 | Windows 124 | .\Release_x32\WinMTR.exe 125 | odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 126 | AsInvoker 127 | false 128 | true 129 | 130 | 131 | 132 | 133 | MultiThreaded 134 | OnlyExplicitInline 135 | true 136 | true 137 | MaxSpeed 138 | true 139 | Level3 140 | WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 141 | .\Release\ 142 | .\Release\WinMTR.pch 143 | .\Release\ 144 | .\Release\ 145 | 146 | 147 | true 148 | NDEBUG;%(PreprocessorDefinitions) 149 | .\Release\WinMTR.tlb 150 | true 151 | 152 | 153 | 0x0409 154 | NDEBUG;%(PreprocessorDefinitions) 155 | 156 | 157 | true 158 | .\Release\WinMTR.bsc 159 | 160 | 161 | true 162 | Windows 163 | .\Release_x64\WinMTR.exe 164 | odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 165 | AsInvoker 166 | false 167 | true 168 | 169 | 170 | 171 | 172 | MultiThreadedDebug 173 | Default 174 | false 175 | Disabled 176 | true 177 | Level3 178 | true 179 | EditAndContinue 180 | WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 181 | .\Debug\ 182 | .\Debug\WinMTR.pch 183 | .\Debug\ 184 | .\Debug\ 185 | EnableFastChecks 186 | 187 | 188 | true 189 | _DEBUG;%(PreprocessorDefinitions) 190 | .\Debug\WinMTR.tlb 191 | true 192 | Win32 193 | 194 | 195 | 0x0409 196 | _DEBUG;%(PreprocessorDefinitions) 197 | 198 | 199 | true 200 | .\Debug\WinMTR.bsc 201 | 202 | 203 | true 204 | true 205 | Windows 206 | .\Debug_x32\WinMTR.exe 207 | odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 208 | AsInvoker 209 | false 210 | true 211 | 212 | 213 | 214 | 215 | MultiThreadedDebug 216 | Default 217 | false 218 | Disabled 219 | true 220 | Level3 221 | ProgramDatabase 222 | WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 223 | .\Debug\ 224 | .\Debug\WinMTR.pch 225 | .\Debug\ 226 | .\Debug\ 227 | EnableFastChecks 228 | 229 | 230 | true 231 | _DEBUG;%(PreprocessorDefinitions) 232 | .\Debug\WinMTR.tlb 233 | true 234 | 235 | 236 | 0x0409 237 | _DEBUG;%(PreprocessorDefinitions) 238 | 239 | 240 | true 241 | .\Debug\WinMTR.bsc 242 | 243 | 244 | true 245 | true 246 | Windows 247 | .\Debug_x64\WinMTR.exe 248 | nafxcwd.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 249 | AsInvoker 250 | false 251 | true 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | -------------------------------------------------------------------------------- /WinMTRDialog.cpp: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // FILE: WinMTRDialog.cpp 3 | // 4 | // 5 | //***************************************************************************** 6 | 7 | #include "WinMTRGlobal.h" 8 | #include "WinMTRDialog.h" 9 | #include "WinMTROptions.h" 10 | #include "WinMTRProperties.h" 11 | #include "WinMTRNet.h" 12 | #include 13 | #include 14 | #include "afxlinkctrl.h" 15 | 16 | #define TRACE_MSG(msg) \ 17 | { \ 18 | std::ostringstream dbg_msg(std::ostringstream::out); \ 19 | dbg_msg << msg << std::endl; \ 20 | OutputDebugString(dbg_msg.str().c_str()); \ 21 | } 22 | 23 | #ifdef _DEBUG 24 | #define new DEBUG_NEW 25 | #undef THIS_FILE 26 | static char THIS_FILE[] = __FILE__; 27 | #endif 28 | 29 | void PingThread(void *p); 30 | 31 | //***************************************************************************** 32 | // BEGIN_MESSAGE_MAP 33 | // 34 | // 35 | //***************************************************************************** 36 | BEGIN_MESSAGE_MAP(WinMTRDialog, CDialog) 37 | ON_WM_PAINT() 38 | ON_WM_SIZE() 39 | ON_WM_SIZING() 40 | ON_WM_QUERYDRAGICON() 41 | ON_BN_CLICKED(ID_RESTART, OnRestart) 42 | ON_BN_CLICKED(ID_OPTIONS, OnOptions) 43 | ON_BN_CLICKED(ID_CTTC, OnCTTC) 44 | ON_BN_CLICKED(ID_CHTC, OnCHTC) 45 | ON_BN_CLICKED(ID_EXPT, OnEXPT) 46 | ON_BN_CLICKED(ID_EXPH, OnEXPH) 47 | ON_NOTIFY(NM_DBLCLK, IDC_LIST_MTR, OnDblclkList) 48 | ON_CBN_SELCHANGE(IDC_COMBO_HOST, &WinMTRDialog::OnCbnSelchangeComboHost) 49 | ON_CBN_SELENDOK(IDC_COMBO_HOST, &WinMTRDialog::OnCbnSelendokComboHost) 50 | ON_CBN_CLOSEUP(IDC_COMBO_HOST, &WinMTRDialog::OnCbnCloseupComboHost) 51 | ON_WM_TIMER() 52 | ON_WM_CLOSE() 53 | ON_BN_CLICKED(IDCANCEL, &WinMTRDialog::OnBnClickedCancel) 54 | END_MESSAGE_MAP() 55 | 56 | 57 | //***************************************************************************** 58 | // WinMTRDialog::WinMTRDialog 59 | // 60 | // 61 | //***************************************************************************** 62 | WinMTRDialog::WinMTRDialog(CWnd* pParent) 63 | : CDialog(WinMTRDialog::IDD, pParent), 64 | state(IDLE), 65 | transition(IDLE_TO_IDLE) 66 | { 67 | m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); 68 | m_autostart = 0; 69 | useDNS = DEFAULT_DNS; 70 | interval = DEFAULT_INTERVAL; 71 | pingsize = DEFAULT_PING_SIZE; 72 | maxLRU = DEFAULT_MAX_LRU; 73 | nrLRU = 0; 74 | 75 | hasIntervalFromCmdLine = false; 76 | hasPingsizeFromCmdLine = false; 77 | hasMaxLRUFromCmdLine = false; 78 | hasUseDNSFromCmdLine = false; 79 | 80 | traceThreadMutex = CreateMutex(NULL, FALSE, NULL); 81 | wmtrnet = new WinMTRNet(this); 82 | } 83 | 84 | WinMTRDialog::~WinMTRDialog() 85 | { 86 | delete wmtrnet; 87 | CloseHandle(traceThreadMutex); 88 | } 89 | 90 | //***************************************************************************** 91 | // WinMTRDialog::DoDataExchange 92 | // 93 | // 94 | //***************************************************************************** 95 | void WinMTRDialog::DoDataExchange(CDataExchange* pDX) 96 | { 97 | CDialog::DoDataExchange(pDX); 98 | DDX_Control(pDX, ID_OPTIONS, m_buttonOptions); 99 | DDX_Control(pDX, IDCANCEL, m_buttonExit); 100 | DDX_Control(pDX, ID_RESTART, m_buttonStart); 101 | DDX_Control(pDX, IDC_COMBO_HOST, m_comboHost); 102 | DDX_Control(pDX, IDC_LIST_MTR, m_listMTR); 103 | DDX_Control(pDX, IDC_STATICS, m_staticS); 104 | DDX_Control(pDX, IDC_STATICJ, m_staticJ); 105 | DDX_Control(pDX, ID_EXPH, m_buttonExpH); 106 | DDX_Control(pDX, ID_EXPT, m_buttonExpT); 107 | } 108 | 109 | 110 | //***************************************************************************** 111 | // WinMTRDialog::OnInitDialog 112 | // 113 | // 114 | //***************************************************************************** 115 | BOOL WinMTRDialog::OnInitDialog() 116 | { 117 | CDialog::OnInitDialog(); 118 | 119 | #ifndef _WIN64 120 | char caption[] = {"WinMTR v0.92 32 bit by Appnor MSP - www.winmtr.net"}; 121 | #else 122 | char caption[] = {"WinMTR v0.92 64 bit by Appnor MSP - www.winmtr.net"}; 123 | #endif 124 | 125 | SetTimer(1, WINMTR_DIALOG_TIMER, NULL); 126 | SetWindowText(caption); 127 | 128 | SetIcon(m_hIcon, TRUE); 129 | SetIcon(m_hIcon, FALSE); 130 | 131 | if(!statusBar.Create( this )) 132 | AfxMessageBox("Error creating status bar"); 133 | statusBar.GetStatusBarCtrl().SetMinHeight(23); 134 | 135 | UINT sbi[1]; 136 | sbi[0] = IDS_STRING_SB_NAME; 137 | statusBar.SetIndicators( sbi,1); 138 | statusBar.SetPaneInfo(0, statusBar.GetItemID(0),SBPS_STRETCH, NULL ); 139 | { // Add appnor URL 140 | CMFCLinkCtrl* m_pWndButton = new CMFCLinkCtrl; 141 | if (!m_pWndButton->Create(_T("www.appnor.com"), WS_CHILD|WS_VISIBLE|WS_TABSTOP, CRect(0,0,0,0), &statusBar, 1234)) { 142 | TRACE(_T("Failed to create button control.\n")); 143 | return FALSE; 144 | } 145 | 146 | m_pWndButton->SetURL("http://www.appnor.com/?utm_source=winmtr&utm_medium=desktop&utm_campaign=software"); 147 | 148 | if(!statusBar.AddPane(1234,1)) { 149 | AfxMessageBox(_T("Pane index out of range\nor pane with same ID already exists in the status bar"), MB_ICONERROR); 150 | return FALSE; 151 | } 152 | 153 | statusBar.SetPaneWidth(statusBar.CommandToIndex(1234), 100); 154 | statusBar.AddPaneControl(m_pWndButton, 1234, true); 155 | } 156 | 157 | for(int i = 0; i< MTR_NR_COLS; i++) 158 | m_listMTR.InsertColumn(i, MTR_COLS[i], LVCFMT_LEFT, MTR_COL_LENGTH[i] , -1); 159 | 160 | m_comboHost.SetFocus(); 161 | 162 | // We need to resize the dialog to make room for control bars. 163 | // First, figure out how big the control bars are. 164 | CRect rcClientStart; 165 | CRect rcClientNow; 166 | GetClientRect(rcClientStart); 167 | RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 168 | 0, reposQuery, rcClientNow); 169 | 170 | // Now move all the controls so they are in the same relative 171 | // position within the remaining client area as they would be 172 | // with no control bars. 173 | CPoint ptOffset(rcClientNow.left - rcClientStart.left, 174 | rcClientNow.top - rcClientStart.top); 175 | 176 | CRect rcChild; 177 | CWnd* pwndChild = GetWindow(GW_CHILD); 178 | while (pwndChild) 179 | { 180 | pwndChild->GetWindowRect(rcChild); 181 | ScreenToClient(rcChild); 182 | rcChild.OffsetRect(ptOffset); 183 | pwndChild->MoveWindow(rcChild, FALSE); 184 | pwndChild = pwndChild->GetNextWindow(); 185 | } 186 | 187 | // Adjust the dialog window dimensions 188 | CRect rcWindow; 189 | GetWindowRect(rcWindow); 190 | rcWindow.right += rcClientStart.Width() - rcClientNow.Width(); 191 | rcWindow.bottom += rcClientStart.Height() - rcClientNow.Height(); 192 | MoveWindow(rcWindow, FALSE); 193 | 194 | // And position the control bars 195 | RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); 196 | 197 | InitRegistry(); 198 | 199 | if (m_autostart) { 200 | m_comboHost.SetWindowText(msz_defaulthostname); 201 | OnRestart(); 202 | } 203 | 204 | return FALSE; 205 | } 206 | 207 | //***************************************************************************** 208 | // WinMTRDialog::InitRegistry 209 | // 210 | // 211 | //***************************************************************************** 212 | BOOL WinMTRDialog::InitRegistry() 213 | { 214 | HKEY hKey, hKey_v; 215 | DWORD res, tmp_dword, value_size; 216 | LONG r; 217 | 218 | r = RegCreateKeyEx( HKEY_CURRENT_USER, 219 | "Software", 220 | 0, 221 | NULL, 222 | REG_OPTION_NON_VOLATILE, 223 | KEY_ALL_ACCESS, 224 | NULL, 225 | &hKey, 226 | &res); 227 | if( r != ERROR_SUCCESS) 228 | return FALSE; 229 | 230 | r = RegCreateKeyEx( hKey, 231 | "WinMTR", 232 | 0, 233 | NULL, 234 | REG_OPTION_NON_VOLATILE, 235 | KEY_ALL_ACCESS, 236 | NULL, 237 | &hKey, 238 | &res); 239 | if( r != ERROR_SUCCESS) 240 | return FALSE; 241 | 242 | RegSetValueEx(hKey,"Version", 0, REG_SZ, (const unsigned char *)WINMTR_VERSION, sizeof(WINMTR_VERSION)+1); 243 | RegSetValueEx(hKey,"License", 0, REG_SZ, (const unsigned char *)WINMTR_LICENSE, sizeof(WINMTR_LICENSE)+1); 244 | RegSetValueEx(hKey,"HomePage", 0, REG_SZ, (const unsigned char *)WINMTR_HOMEPAGE, sizeof(WINMTR_HOMEPAGE)+1); 245 | 246 | r = RegCreateKeyEx( hKey, 247 | "Config", 248 | 0, 249 | NULL, 250 | REG_OPTION_NON_VOLATILE, 251 | KEY_ALL_ACCESS, 252 | NULL, 253 | &hKey_v, 254 | &res); 255 | if( r != ERROR_SUCCESS) 256 | return FALSE; 257 | 258 | if(RegQueryValueEx(hKey_v, "PingSize", 0, NULL, (unsigned char *)&tmp_dword, &value_size) != ERROR_SUCCESS) { 259 | tmp_dword = pingsize; 260 | RegSetValueEx(hKey_v,"PingSize", 0, REG_DWORD, (const unsigned char *)&tmp_dword, sizeof(DWORD)); 261 | } else { 262 | if(!hasPingsizeFromCmdLine) pingsize = tmp_dword; 263 | } 264 | 265 | if(RegQueryValueEx(hKey_v, "MaxLRU", 0, NULL, (unsigned char *)&tmp_dword, &value_size) != ERROR_SUCCESS) { 266 | tmp_dword = maxLRU; 267 | RegSetValueEx(hKey_v,"MaxLRU", 0, REG_DWORD, (const unsigned char *)&tmp_dword, sizeof(DWORD)); 268 | } else { 269 | if(!hasMaxLRUFromCmdLine) maxLRU = tmp_dword; 270 | } 271 | 272 | if(RegQueryValueEx(hKey_v, "UseDNS", 0, NULL, (unsigned char *)&tmp_dword, &value_size) != ERROR_SUCCESS) { 273 | tmp_dword = useDNS ? 1 : 0; 274 | RegSetValueEx(hKey_v,"UseDNS", 0, REG_DWORD, (const unsigned char *)&tmp_dword, sizeof(DWORD)); 275 | } else { 276 | if(!hasUseDNSFromCmdLine) useDNS = (BOOL)tmp_dword; 277 | } 278 | 279 | if(RegQueryValueEx(hKey_v, "Interval", 0, NULL, (unsigned char *)&tmp_dword, &value_size) != ERROR_SUCCESS) { 280 | tmp_dword = (DWORD)(interval * 1000); 281 | RegSetValueEx(hKey_v,"Interval", 0, REG_DWORD, (const unsigned char *)&tmp_dword, sizeof(DWORD)); 282 | } else { 283 | if(!hasIntervalFromCmdLine) interval = (float)tmp_dword / 1000.0; 284 | } 285 | 286 | r = RegCreateKeyEx( hKey, 287 | "LRU", 288 | 0, 289 | NULL, 290 | REG_OPTION_NON_VOLATILE, 291 | KEY_ALL_ACCESS, 292 | NULL, 293 | &hKey_v, 294 | &res); 295 | if( r != ERROR_SUCCESS) 296 | return FALSE; 297 | if(RegQueryValueEx(hKey_v, "NrLRU", 0, NULL, (unsigned char *)&tmp_dword, &value_size) != ERROR_SUCCESS) { 298 | tmp_dword = nrLRU; 299 | RegSetValueEx(hKey_v,"NrLRU", 0, REG_DWORD, (const unsigned char *)&tmp_dword, sizeof(DWORD)); 300 | } else { 301 | char key_name[20]; 302 | unsigned char str_host[255]; 303 | nrLRU = tmp_dword; 304 | for(int i=0;iright)-(pRect->left); 330 | int iHeight = (pRect->bottom)-(pRect->top); 331 | 332 | if (iWidth < 600) 333 | pRect->right = pRect->left + 600; 334 | if (iHeight <250) 335 | pRect->bottom = pRect->top + 250; 336 | } 337 | 338 | 339 | //***************************************************************************** 340 | // WinMTRDialog::OnSize 341 | // 342 | // 343 | //***************************************************************************** 344 | void WinMTRDialog::OnSize(UINT nType, int cx, int cy) 345 | { 346 | CDialog::OnSize(nType, cx, cy); 347 | CRect r; 348 | GetClientRect(&r); 349 | CRect lb; 350 | 351 | if (::IsWindow(m_staticS.m_hWnd)) { 352 | m_staticS.GetWindowRect(&lb); 353 | ScreenToClient(&lb); 354 | m_staticS.SetWindowPos(NULL, lb.TopLeft().x, lb.TopLeft().y, r.Width()-lb.TopLeft().x-10, lb.Height() , SWP_NOMOVE | SWP_NOZORDER); 355 | } 356 | 357 | if (::IsWindow(m_staticJ.m_hWnd)) { 358 | m_staticJ.GetWindowRect(&lb); 359 | ScreenToClient(&lb); 360 | m_staticJ.SetWindowPos(NULL, lb.TopLeft().x, lb.TopLeft().y, r.Width() - 21, lb.Height(), SWP_NOMOVE | SWP_NOZORDER); 361 | } 362 | 363 | if (::IsWindow(m_buttonExit.m_hWnd)) { 364 | m_buttonExit.GetWindowRect(&lb); 365 | ScreenToClient(&lb); 366 | m_buttonExit.SetWindowPos(NULL, r.Width() - lb.Width()-21, lb.TopLeft().y, lb.Width(), lb.Height() , SWP_NOSIZE | SWP_NOZORDER); 367 | } 368 | 369 | if (::IsWindow(m_buttonExpH.m_hWnd)) { 370 | m_buttonExpH.GetWindowRect(&lb); 371 | ScreenToClient(&lb); 372 | m_buttonExpH.SetWindowPos(NULL, r.Width() - lb.Width()-21, lb.TopLeft().y, lb.Width(), lb.Height() , SWP_NOSIZE | SWP_NOZORDER); 373 | } 374 | if (::IsWindow(m_buttonExpT.m_hWnd)) { 375 | m_buttonExpT.GetWindowRect(&lb); 376 | ScreenToClient(&lb); 377 | m_buttonExpT.SetWindowPos(NULL, r.Width() - lb.Width()- 103, lb.TopLeft().y, lb.Width(), lb.Height() , SWP_NOSIZE | SWP_NOZORDER); 378 | } 379 | 380 | if (::IsWindow(m_listMTR.m_hWnd)) { 381 | m_listMTR.GetWindowRect(&lb); 382 | ScreenToClient(&lb); 383 | m_listMTR.SetWindowPos(NULL, lb.TopLeft().x, lb.TopLeft().y, r.Width() - 21, r.Height() - lb.top - 25, SWP_NOMOVE | SWP_NOZORDER); 384 | } 385 | 386 | RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 387 | 0, reposQuery, r); 388 | 389 | RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); 390 | 391 | } 392 | 393 | 394 | //***************************************************************************** 395 | // WinMTRDialog::OnPaint 396 | // 397 | // 398 | //***************************************************************************** 399 | void WinMTRDialog::OnPaint() 400 | { 401 | if (IsIconic()) 402 | { 403 | CPaintDC dc(this); 404 | 405 | SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); 406 | 407 | int cxIcon = GetSystemMetrics(SM_CXICON); 408 | int cyIcon = GetSystemMetrics(SM_CYICON); 409 | CRect rect; 410 | GetClientRect(&rect); 411 | int x = (rect.Width() - cxIcon + 1) / 2; 412 | int y = (rect.Height() - cyIcon + 1) / 2; 413 | 414 | dc.DrawIcon(x, y, m_hIcon); 415 | } 416 | else 417 | { 418 | CDialog::OnPaint(); 419 | } 420 | } 421 | 422 | 423 | //***************************************************************************** 424 | // WinMTRDialog::OnQueryDragIcon 425 | // 426 | // 427 | //***************************************************************************** 428 | HCURSOR WinMTRDialog::OnQueryDragIcon() 429 | { 430 | return (HCURSOR) m_hIcon; 431 | } 432 | 433 | 434 | //***************************************************************************** 435 | // WinMTRDialog::OnDblclkList 436 | // 437 | //***************************************************************************** 438 | void WinMTRDialog::OnDblclkList(NMHDR* pNMHDR, LRESULT* pResult) 439 | { 440 | *pResult = 0; 441 | 442 | if(state == TRACING) { 443 | 444 | POSITION pos = m_listMTR.GetFirstSelectedItemPosition(); 445 | if(pos!=NULL) { 446 | int nItem = m_listMTR.GetNextSelectedItem(pos); 447 | WinMTRProperties wmtrprop; 448 | 449 | if(wmtrnet->GetAddr(nItem)==0) { 450 | strcpy(wmtrprop.host,""); 451 | strcpy(wmtrprop.ip,""); 452 | wmtrnet->GetName(nItem, wmtrprop.comment); 453 | 454 | wmtrprop.pck_loss = wmtrprop.pck_sent = wmtrprop.pck_recv = 0; 455 | 456 | wmtrprop.ping_avrg = wmtrprop.ping_last = 0.0; 457 | wmtrprop.ping_best = wmtrprop.ping_worst = 0.0; 458 | } else { 459 | wmtrnet->GetName(nItem, wmtrprop.host); 460 | int addr = wmtrnet->GetAddr(nItem); 461 | sprintf ( wmtrprop.ip , "%d.%d.%d.%d", 462 | (addr >> 24) & 0xff, 463 | (addr >> 16) & 0xff, 464 | (addr >> 8) & 0xff, 465 | addr & 0xff 466 | ); 467 | strcpy(wmtrprop.comment , "Host alive."); 468 | 469 | wmtrprop.ping_avrg = (float)wmtrnet->GetAvg(nItem); 470 | wmtrprop.ping_last = (float)wmtrnet->GetLast(nItem); 471 | wmtrprop.ping_best = (float)wmtrnet->GetBest(nItem); 472 | wmtrprop.ping_worst = (float)wmtrnet->GetWorst(nItem); 473 | 474 | wmtrprop.pck_loss = wmtrnet->GetPercent(nItem); 475 | wmtrprop.pck_recv = wmtrnet->GetReturned(nItem); 476 | wmtrprop.pck_sent = wmtrnet->GetXmit(nItem); 477 | } 478 | 479 | wmtrprop.DoModal(); 480 | } 481 | } 482 | } 483 | 484 | 485 | //***************************************************************************** 486 | // WinMTRDialog::SetHostName 487 | // 488 | //***************************************************************************** 489 | void WinMTRDialog::SetHostName(const char *host) 490 | { 491 | m_autostart = 1; 492 | strncpy(msz_defaulthostname,host,1000); 493 | } 494 | 495 | 496 | //***************************************************************************** 497 | // WinMTRDialog::SetPingSize 498 | // 499 | //***************************************************************************** 500 | void WinMTRDialog::SetPingSize(int ps) 501 | { 502 | pingsize = ps; 503 | } 504 | 505 | //***************************************************************************** 506 | // WinMTRDialog::SetMaxLRU 507 | // 508 | //***************************************************************************** 509 | void WinMTRDialog::SetMaxLRU(int mlru) 510 | { 511 | maxLRU = mlru; 512 | } 513 | 514 | 515 | //***************************************************************************** 516 | // WinMTRDialog::SetInterval 517 | // 518 | //***************************************************************************** 519 | void WinMTRDialog::SetInterval(float i) 520 | { 521 | interval = i; 522 | } 523 | 524 | //***************************************************************************** 525 | // WinMTRDialog::SetUseDNS 526 | // 527 | //***************************************************************************** 528 | void WinMTRDialog::SetUseDNS(BOOL udns) 529 | { 530 | useDNS = udns; 531 | } 532 | 533 | 534 | 535 | 536 | //***************************************************************************** 537 | // WinMTRDialog::OnRestart 538 | // 539 | // 540 | //***************************************************************************** 541 | void WinMTRDialog::OnRestart() 542 | { 543 | // If clear history is selected, just clear the registry and listbox and return 544 | if(m_comboHost.GetCurSel() == m_comboHost.GetCount() - 1) { 545 | ClearHistory(); 546 | return; 547 | } 548 | 549 | CString sHost; 550 | 551 | if(state == IDLE) { 552 | m_comboHost.GetWindowText(sHost); 553 | sHost.TrimLeft(); 554 | sHost.TrimLeft(); 555 | 556 | if(sHost.IsEmpty()) { 557 | AfxMessageBox("No host specified!"); 558 | m_comboHost.SetFocus(); 559 | return ; 560 | } 561 | m_listMTR.DeleteAllItems(); 562 | } 563 | 564 | if(state == IDLE) { 565 | 566 | if(InitMTRNet()) { 567 | if(m_comboHost.FindString(-1, sHost) == CB_ERR) { 568 | m_comboHost.InsertString(m_comboHost.GetCount() - 1,sHost); 569 | 570 | HKEY hKey; 571 | DWORD tmp_dword; 572 | LONG r; 573 | char key_name[20]; 574 | 575 | r = RegOpenKeyEx( HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS,&hKey); 576 | r = RegOpenKeyEx( hKey, "WinMTR", 0, KEY_ALL_ACCESS, &hKey); 577 | r = RegOpenKeyEx( hKey, "LRU", 0, KEY_ALL_ACCESS, &hKey); 578 | 579 | if(nrLRU >= maxLRU) 580 | nrLRU = 0; 581 | 582 | nrLRU++; 583 | sprintf(key_name, "Host%d", nrLRU); 584 | r = RegSetValueEx(hKey,key_name, 0, REG_SZ, (const unsigned char *)(LPCTSTR)sHost, strlen((LPCTSTR)sHost)+1); 585 | tmp_dword = nrLRU; 586 | r = RegSetValueEx(hKey,"NrLRU", 0, REG_DWORD, (const unsigned char *)&tmp_dword, sizeof(DWORD)); 587 | RegCloseKey(hKey); 588 | } 589 | Transit(TRACING); 590 | } 591 | } else { 592 | Transit(STOPPING); 593 | } 594 | } 595 | 596 | 597 | //***************************************************************************** 598 | // WinMTRDialog::OnOptions 599 | // 600 | // 601 | //***************************************************************************** 602 | void WinMTRDialog::OnOptions() 603 | { 604 | WinMTROptions optDlg; 605 | 606 | optDlg.SetPingSize(pingsize); 607 | optDlg.SetInterval(interval); 608 | optDlg.SetMaxLRU(maxLRU); 609 | optDlg.SetUseDNS(useDNS); 610 | 611 | if(IDOK == optDlg.DoModal()) { 612 | 613 | pingsize = optDlg.GetPingSize(); 614 | interval = optDlg.GetInterval(); 615 | maxLRU = optDlg.GetMaxLRU(); 616 | useDNS = optDlg.GetUseDNS(); 617 | 618 | HKEY hKey; 619 | DWORD tmp_dword; 620 | LONG r; 621 | char key_name[20]; 622 | 623 | r = RegOpenKeyEx( HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS,&hKey); 624 | r = RegOpenKeyEx( hKey, "WinMTR", 0, KEY_ALL_ACCESS, &hKey); 625 | r = RegOpenKeyEx( hKey, "Config", 0, KEY_ALL_ACCESS, &hKey); 626 | tmp_dword = pingsize; 627 | RegSetValueEx(hKey,"PingSize", 0, REG_DWORD, (const unsigned char *)&tmp_dword, sizeof(DWORD)); 628 | tmp_dword = maxLRU; 629 | RegSetValueEx(hKey,"MaxLRU", 0, REG_DWORD, (const unsigned char *)&tmp_dword, sizeof(DWORD)); 630 | tmp_dword = useDNS ? 1 : 0; 631 | RegSetValueEx(hKey,"UseDNS", 0, REG_DWORD, (const unsigned char *)&tmp_dword, sizeof(DWORD)); 632 | tmp_dword = (DWORD)(interval * 1000); 633 | RegSetValueEx(hKey,"Interval", 0, REG_DWORD, (const unsigned char *)&tmp_dword, sizeof(DWORD)); 634 | RegCloseKey(hKey); 635 | if(maxLRUGetMax(); 663 | 664 | //strcpy(f_buf, "|------------------------------------------------------------------------------------------|\r\n"); 665 | //sprintf(t_buf, "| WinMTR statistics |\r\n"); 666 | //strcat(f_buf, t_buf); 667 | //sprintf(t_buf, "| Host - %% | Sent | Recv | Best | Avrg | Wrst | Last |\r\n" ); 668 | //strcat(f_buf, t_buf); 669 | //sprintf(t_buf, "|------------------------------------------------|------|------|------|------|------|------|\r\n" ); 670 | //strcat(f_buf, t_buf); 671 | sprintf(t_buf, "Host Lost Sent Recv Best Avrg Wrst Last\r\n"); 672 | strcat(f_buf, t_buf); 673 | for(int i=0;i GetName(i, buf); 675 | if(strcmp(buf,"")==0) strcpy(buf,"No response from host"); 676 | 677 | sprintf(t_buf, "%s %4d %4d %4d %4d %4d %4d %4d\r\n" , 678 | buf, wmtrnet->GetPercent(i), 679 | wmtrnet->GetXmit(i), wmtrnet->GetReturned(i), wmtrnet->GetBest(i), 680 | wmtrnet->GetAvg(i), wmtrnet->GetWorst(i), wmtrnet->GetLast(i)); 681 | strcat(f_buf, t_buf); 682 | } 683 | 684 | //sprintf(t_buf, "|________________________________________________|______|______|______|______|______|______|\r\n" ); 685 | //strcat(f_buf, t_buf); 686 | 687 | CString cs_tmp((LPCSTR)IDS_STRING_SB_NAME); 688 | strcat(f_buf, " "); 689 | strcat(f_buf, (LPCTSTR)cs_tmp); 690 | 691 | CString source(f_buf); 692 | 693 | HGLOBAL clipbuffer; 694 | char * buffer; 695 | 696 | OpenClipboard(); 697 | EmptyClipboard(); 698 | 699 | clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength()+1); 700 | buffer = (char*)GlobalLock(clipbuffer); 701 | strcpy(buffer, LPCSTR(source)); 702 | GlobalUnlock(clipbuffer); 703 | 704 | SetClipboardData(CF_TEXT,clipbuffer); 705 | CloseClipboard(); 706 | } 707 | 708 | 709 | //***************************************************************************** 710 | // WinMTRDialog::OnCHTC 711 | // 712 | // 713 | //***************************************************************************** 714 | void WinMTRDialog::OnCHTC() 715 | { 716 | char buf[255], t_buf[1000], f_buf[255*100]; 717 | 718 | int nh = wmtrnet->GetMax(); 719 | 720 | strcpy(f_buf, "WinMTR Statistics\r\n"); 721 | sprintf(t_buf, "

WinMTR statistics

\r\n"); 722 | strcat(f_buf, t_buf); 723 | 724 | sprintf(t_buf, "

\r\n" ); 725 | strcat(f_buf, t_buf); 726 | 727 | sprintf(t_buf, "\r\n" ); 728 | strcat(f_buf, t_buf); 729 | 730 | for(int i=0;i GetName(i, buf); 732 | if( strcmp(buf,"")==0 ) strcpy(buf,"No response from host"); 733 | 734 | sprintf(t_buf, "\r\n" , 735 | buf, wmtrnet->GetPercent(i), 736 | wmtrnet->GetXmit(i), wmtrnet->GetReturned(i), wmtrnet->GetBest(i), 737 | wmtrnet->GetAvg(i), wmtrnet->GetWorst(i), wmtrnet->GetLast(i)); 738 | strcat(f_buf, t_buf); 739 | } 740 | 741 | sprintf(t_buf, "
Host %% Sent Recv Best Avrg Wrst Last
%s %4d %4d %4d %4d %4d %4d %4d
\r\n"); 742 | strcat(f_buf, t_buf); 743 | 744 | CString source(f_buf); 745 | 746 | HGLOBAL clipbuffer; 747 | char * buffer; 748 | 749 | OpenClipboard(); 750 | EmptyClipboard(); 751 | 752 | clipbuffer = GlobalAlloc(GMEM_DDESHARE, source.GetLength()+1); 753 | buffer = (char*)GlobalLock(clipbuffer); 754 | strcpy(buffer, LPCSTR(source)); 755 | GlobalUnlock(clipbuffer); 756 | 757 | SetClipboardData(CF_TEXT,clipbuffer); 758 | CloseClipboard(); 759 | } 760 | 761 | 762 | //***************************************************************************** 763 | // WinMTRDialog::OnEXPT 764 | // 765 | // 766 | //***************************************************************************** 767 | void WinMTRDialog::OnEXPT() 768 | { 769 | TCHAR BASED_CODE szFilter[] = _T("Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"); 770 | 771 | CFileDialog dlg(FALSE, 772 | _T("TXT"), 773 | NULL, 774 | OFN_HIDEREADONLY | OFN_EXPLORER, 775 | szFilter, 776 | this); 777 | if(dlg.DoModal() == IDOK) { 778 | 779 | char buf[255], t_buf[1000], f_buf[255*100]; 780 | 781 | int nh = wmtrnet->GetMax(); 782 | 783 | strcpy(f_buf, "|------------------------------------------------------------------------------------------|\r\n"); 784 | sprintf(t_buf, "| WinMTR statistics |\r\n"); 785 | strcat(f_buf, t_buf); 786 | sprintf(t_buf, "| Host - %% | Sent | Recv | Best | Avrg | Wrst | Last |\r\n" ); 787 | strcat(f_buf, t_buf); 788 | sprintf(t_buf, "|------------------------------------------------|------|------|------|------|------|------|\r\n" ); 789 | strcat(f_buf, t_buf); 790 | 791 | for(int i=0;i GetName(i, buf); 793 | if( strcmp(buf,"")==0 ) strcpy(buf,"No response from host"); 794 | 795 | sprintf(t_buf, "|%40s - %4d | %4d | %4d | %4d | %4d | %4d | %4d |\r\n" , 796 | buf, wmtrnet->GetPercent(i), 797 | wmtrnet->GetXmit(i), wmtrnet->GetReturned(i), wmtrnet->GetBest(i), 798 | wmtrnet->GetAvg(i), wmtrnet->GetWorst(i), wmtrnet->GetLast(i)); 799 | strcat(f_buf, t_buf); 800 | } 801 | 802 | sprintf(t_buf, "|________________________________________________|______|______|______|______|______|______|\r\n" ); 803 | strcat(f_buf, t_buf); 804 | 805 | 806 | CString cs_tmp((LPCSTR)IDS_STRING_SB_NAME); 807 | strcat(f_buf, " "); 808 | strcat(f_buf, (LPCTSTR)cs_tmp); 809 | 810 | FILE *fp = fopen(dlg.GetPathName(), "wt"); 811 | if(fp != NULL) { 812 | fprintf(fp, "%s", f_buf); 813 | fclose(fp); 814 | } 815 | } 816 | } 817 | 818 | 819 | //***************************************************************************** 820 | // WinMTRDialog::OnEXPH 821 | // 822 | // 823 | //***************************************************************************** 824 | void WinMTRDialog::OnEXPH() 825 | { 826 | TCHAR BASED_CODE szFilter[] = _T("HTML Files (*.htm, *.html)|*.htm;*.html|All Files (*.*)|*.*||"); 827 | 828 | CFileDialog dlg(FALSE, 829 | _T("HTML"), 830 | NULL, 831 | OFN_HIDEREADONLY | OFN_EXPLORER, 832 | szFilter, 833 | this); 834 | 835 | if(dlg.DoModal() == IDOK) { 836 | 837 | char buf[255], t_buf[1000], f_buf[255*100]; 838 | 839 | int nh = wmtrnet->GetMax(); 840 | 841 | strcpy(f_buf, "WinMTR Statistics\r\n"); 842 | sprintf(t_buf, "

WinMTR statistics

\r\n"); 843 | strcat(f_buf, t_buf); 844 | 845 | sprintf(t_buf, "

\r\n" ); 846 | strcat(f_buf, t_buf); 847 | 848 | sprintf(t_buf, "\r\n" ); 849 | strcat(f_buf, t_buf); 850 | 851 | for(int i=0;i GetName(i, buf); 853 | if( strcmp(buf,"")==0 ) strcpy(buf,"No response from host"); 854 | 855 | sprintf(t_buf, "\r\n" , 856 | buf, wmtrnet->GetPercent(i), 857 | wmtrnet->GetXmit(i), wmtrnet->GetReturned(i), wmtrnet->GetBest(i), 858 | wmtrnet->GetAvg(i), wmtrnet->GetWorst(i), wmtrnet->GetLast(i)); 859 | strcat(f_buf, t_buf); 860 | } 861 | 862 | sprintf(t_buf, "
Host %% Sent Recv Best Avrg Wrst Last
%s %4d %4d %4d %4d %4d %4d %4d
\r\n"); 863 | strcat(f_buf, t_buf); 864 | 865 | FILE *fp = fopen(dlg.GetPathName(), "wt"); 866 | if(fp != NULL) { 867 | fprintf(fp, "%s", f_buf); 868 | fclose(fp); 869 | } 870 | } 871 | 872 | 873 | } 874 | 875 | 876 | //***************************************************************************** 877 | // WinMTRDialog::WinMTRDialog 878 | // 879 | // 880 | //***************************************************************************** 881 | void WinMTRDialog::OnCancel() 882 | { 883 | } 884 | 885 | 886 | //***************************************************************************** 887 | // WinMTRDialog::DisplayRedraw 888 | // 889 | // 890 | //***************************************************************************** 891 | int WinMTRDialog::DisplayRedraw() 892 | { 893 | char buf[255], nr_crt[255]; 894 | int nh = wmtrnet->GetMax(); 895 | while( m_listMTR.GetItemCount() > nh ) m_listMTR.DeleteItem(m_listMTR.GetItemCount() - 1); 896 | 897 | for(int i=0;i GetName(i, buf); 900 | if( strcmp(buf,"")==0 ) strcpy(buf,"No response from host"); 901 | 902 | sprintf(nr_crt, "%d", i+1); 903 | if(m_listMTR.GetItemCount() <= i ) 904 | m_listMTR.InsertItem(i, buf); 905 | else 906 | m_listMTR.SetItem(i, 0, LVIF_TEXT, buf, 0, 0, 0, 0); 907 | 908 | m_listMTR.SetItem(i, 1, LVIF_TEXT, nr_crt, 0, 0, 0, 0); 909 | 910 | sprintf(buf, "%d", wmtrnet->GetPercent(i)); 911 | m_listMTR.SetItem(i, 2, LVIF_TEXT, buf, 0, 0, 0, 0); 912 | 913 | sprintf(buf, "%d", wmtrnet->GetXmit(i)); 914 | m_listMTR.SetItem(i, 3, LVIF_TEXT, buf, 0, 0, 0, 0); 915 | 916 | sprintf(buf, "%d", wmtrnet->GetReturned(i)); 917 | m_listMTR.SetItem(i, 4, LVIF_TEXT, buf, 0, 0, 0, 0); 918 | 919 | sprintf(buf, "%d", wmtrnet->GetBest(i)); 920 | m_listMTR.SetItem(i, 5, LVIF_TEXT, buf, 0, 0, 0, 0); 921 | 922 | sprintf(buf, "%d", wmtrnet->GetAvg(i)); 923 | m_listMTR.SetItem(i, 6, LVIF_TEXT, buf, 0, 0, 0, 0); 924 | 925 | sprintf(buf, "%d", wmtrnet->GetWorst(i)); 926 | m_listMTR.SetItem(i, 7, LVIF_TEXT, buf, 0, 0, 0, 0); 927 | 928 | sprintf(buf, "%d", wmtrnet->GetLast(i)); 929 | m_listMTR.SetItem(i, 8, LVIF_TEXT, buf, 0, 0, 0, 0); 930 | 931 | 932 | } 933 | 934 | return 0; 935 | } 936 | 937 | 938 | //***************************************************************************** 939 | // WinMTRDialog::InitMTRNet 940 | // 941 | // 942 | //***************************************************************************** 943 | int WinMTRDialog::InitMTRNet() 944 | { 945 | char strtmp[255]; 946 | char *Hostname = strtmp; 947 | char buf[255]; 948 | struct hostent *host; 949 | m_comboHost.GetWindowText(strtmp, 255); 950 | 951 | if (Hostname == NULL) Hostname = "localhost"; 952 | 953 | int isIP=1; 954 | char *t = Hostname; 955 | while(*t) { 956 | if(!isdigit(*t) && *t!='.') { 957 | isIP=0; 958 | break; 959 | } 960 | t++; 961 | } 962 | 963 | if(!isIP) { 964 | sprintf(buf, "Resolving host %s...", strtmp); 965 | statusBar.SetPaneText(0,buf); 966 | host = gethostbyname(Hostname); 967 | if(host == NULL) { 968 | statusBar.SetPaneText(0, CString((LPCSTR)IDS_STRING_SB_NAME) ); 969 | AfxMessageBox("Unable to resolve hostname."); 970 | return 0; 971 | } 972 | } 973 | 974 | return 1; 975 | } 976 | 977 | 978 | //***************************************************************************** 979 | // PingThread 980 | // 981 | // 982 | //***************************************************************************** 983 | void PingThread(void *p) 984 | { 985 | WinMTRDialog *wmtrdlg = (WinMTRDialog *)p; 986 | WaitForSingleObject(wmtrdlg->traceThreadMutex, INFINITE); 987 | 988 | struct hostent *host, *lhost; 989 | char strtmp[255]; 990 | char *Hostname = strtmp; 991 | int traddr; 992 | int localaddr; 993 | 994 | wmtrdlg->m_comboHost.GetWindowText(strtmp, 255); 995 | 996 | if (Hostname == NULL) Hostname = "localhost"; 997 | 998 | int isIP=1; 999 | char *t = Hostname; 1000 | while(*t) { 1001 | if(!isdigit(*t) && *t!='.') { 1002 | isIP=0; 1003 | break; 1004 | } 1005 | t++; 1006 | } 1007 | 1008 | if(!isIP) { 1009 | host = gethostbyname(Hostname); 1010 | traddr = *(int *)host->h_addr; 1011 | } else 1012 | traddr = inet_addr(Hostname); 1013 | 1014 | lhost = gethostbyname("localhost"); 1015 | if(lhost == NULL) { 1016 | AfxMessageBox("Unable to get local IP address."); 1017 | ReleaseMutex(wmtrdlg->traceThreadMutex); 1018 | return; 1019 | } 1020 | localaddr = *(int *)lhost->h_addr; 1021 | 1022 | wmtrdlg->wmtrnet->DoTrace(traddr); 1023 | 1024 | ReleaseMutex(wmtrdlg->traceThreadMutex); 1025 | _endthread(); 1026 | } 1027 | 1028 | 1029 | 1030 | void WinMTRDialog::OnCbnSelchangeComboHost() 1031 | { 1032 | } 1033 | 1034 | void WinMTRDialog::ClearHistory() 1035 | { 1036 | HKEY hKey; 1037 | DWORD tmp_dword; 1038 | LONG r; 1039 | char key_name[20]; 1040 | 1041 | r = RegOpenKeyEx( HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS,&hKey); 1042 | r = RegOpenKeyEx( hKey, "WinMTR", 0, KEY_ALL_ACCESS, &hKey); 1043 | r = RegOpenKeyEx( hKey, "LRU", 0, KEY_ALL_ACCESS, &hKey); 1044 | 1045 | for(int i = 0; i<=nrLRU; i++) { 1046 | sprintf(key_name, "Host%d", i); 1047 | r = RegDeleteValue(hKey,key_name); 1048 | } 1049 | nrLRU = 0; 1050 | tmp_dword = nrLRU; 1051 | r = RegSetValueEx(hKey,"NrLRU", 0, REG_DWORD, (const unsigned char *)&tmp_dword, sizeof(DWORD)); 1052 | RegCloseKey(hKey); 1053 | 1054 | m_comboHost.Clear(); 1055 | m_comboHost.ResetContent(); 1056 | m_comboHost.AddString(CString((LPCSTR)IDS_STRING_CLEAR_HISTORY)); 1057 | } 1058 | 1059 | void WinMTRDialog::OnCbnSelendokComboHost() 1060 | { 1061 | } 1062 | 1063 | 1064 | void WinMTRDialog::OnCbnCloseupComboHost() 1065 | { 1066 | if(m_comboHost.GetCurSel() == m_comboHost.GetCount() - 1) { 1067 | ClearHistory(); 1068 | } 1069 | } 1070 | 1071 | void WinMTRDialog::Transit(STATES new_state) 1072 | { 1073 | switch(new_state) { 1074 | case IDLE: 1075 | switch (state) { 1076 | case STOPPING: 1077 | transition = STOPPING_TO_IDLE; 1078 | break; 1079 | case IDLE: 1080 | transition = IDLE_TO_IDLE; 1081 | break; 1082 | default: 1083 | TRACE_MSG("Received state IDLE after " << state); 1084 | return; 1085 | } 1086 | state = IDLE; 1087 | break; 1088 | case TRACING: 1089 | switch (state) { 1090 | case IDLE: 1091 | transition = IDLE_TO_TRACING; 1092 | break; 1093 | case TRACING: 1094 | transition = TRACING_TO_TRACING; 1095 | break; 1096 | default: 1097 | TRACE_MSG("Received state TRACING after " << state); 1098 | return; 1099 | } 1100 | state = TRACING; 1101 | break; 1102 | case STOPPING: 1103 | switch (state) { 1104 | case STOPPING: 1105 | transition = STOPPING_TO_STOPPING; 1106 | break; 1107 | case TRACING: 1108 | transition = TRACING_TO_STOPPING; 1109 | break; 1110 | default: 1111 | TRACE_MSG("Received state STOPPING after " << state); 1112 | return; 1113 | } 1114 | state = STOPPING; 1115 | break; 1116 | case EXIT: 1117 | switch (state) { 1118 | case IDLE: 1119 | transition = IDLE_TO_EXIT; 1120 | break; 1121 | case STOPPING: 1122 | transition = STOPPING_TO_EXIT; 1123 | break; 1124 | case TRACING: 1125 | transition = TRACING_TO_EXIT; 1126 | break; 1127 | case EXIT: 1128 | break; 1129 | default: 1130 | TRACE_MSG("Received state EXIT after " << state); 1131 | return; 1132 | } 1133 | state = EXIT; 1134 | break; 1135 | default: 1136 | TRACE_MSG("Received state " << state); 1137 | } 1138 | 1139 | // modify controls according to new state 1140 | switch(transition) { 1141 | case IDLE_TO_TRACING: 1142 | m_buttonStart.EnableWindow(FALSE); 1143 | m_buttonStart.SetWindowText("Stop"); 1144 | m_comboHost.EnableWindow(FALSE); 1145 | m_buttonOptions.EnableWindow(FALSE); 1146 | statusBar.SetPaneText(0, "Double click on host name for more information."); 1147 | _beginthread(PingThread, 0 , this); 1148 | m_buttonStart.EnableWindow(TRUE); 1149 | break; 1150 | case IDLE_TO_IDLE: 1151 | // nothing to be done 1152 | break; 1153 | case STOPPING_TO_IDLE: 1154 | m_buttonStart.EnableWindow(TRUE); 1155 | statusBar.SetPaneText(0, CString((LPCSTR)IDS_STRING_SB_NAME) ); 1156 | m_buttonStart.SetWindowText("Start"); 1157 | m_comboHost.EnableWindow(TRUE); 1158 | m_buttonOptions.EnableWindow(TRUE); 1159 | m_comboHost.SetFocus(); 1160 | break; 1161 | case STOPPING_TO_STOPPING: 1162 | DisplayRedraw(); 1163 | break; 1164 | case TRACING_TO_TRACING: 1165 | DisplayRedraw(); 1166 | break; 1167 | case TRACING_TO_STOPPING: 1168 | m_buttonStart.EnableWindow(FALSE); 1169 | m_comboHost.EnableWindow(FALSE); 1170 | m_buttonOptions.EnableWindow(FALSE); 1171 | wmtrnet->StopTrace(); 1172 | statusBar.SetPaneText(0, "Waiting for last packets in order to stop trace ..."); 1173 | DisplayRedraw(); 1174 | break; 1175 | case IDLE_TO_EXIT: 1176 | m_buttonStart.EnableWindow(FALSE); 1177 | m_comboHost.EnableWindow(FALSE); 1178 | m_buttonOptions.EnableWindow(FALSE); 1179 | break; 1180 | case TRACING_TO_EXIT: 1181 | m_buttonStart.EnableWindow(FALSE); 1182 | m_comboHost.EnableWindow(FALSE); 1183 | m_buttonOptions.EnableWindow(FALSE); 1184 | wmtrnet->StopTrace(); 1185 | statusBar.SetPaneText(0, "Waiting for last packets in order to stop trace ..."); 1186 | break; 1187 | case STOPPING_TO_EXIT: 1188 | m_buttonStart.EnableWindow(FALSE); 1189 | m_comboHost.EnableWindow(FALSE); 1190 | m_buttonOptions.EnableWindow(FALSE); 1191 | break; 1192 | default: 1193 | TRACE_MSG("Unknown transition " << transition); 1194 | } 1195 | } 1196 | 1197 | 1198 | void WinMTRDialog::OnTimer(UINT_PTR nIDEvent) 1199 | { 1200 | static unsigned int call_count = 0; 1201 | static unsigned int trace_count = 0; 1202 | call_count += 1; 1203 | 1204 | if(state == EXIT && WaitForSingleObject(traceThreadMutex, 0) == WAIT_OBJECT_0) { 1205 | ReleaseMutex(traceThreadMutex); 1206 | OnOK(); 1207 | } 1208 | 1209 | 1210 | if( WaitForSingleObject(traceThreadMutex, 0) == WAIT_OBJECT_0 ) { 1211 | ReleaseMutex(traceThreadMutex); 1212 | Transit(IDLE); 1213 | } else if ((call_count % 10 == 0) && (WaitForSingleObject(traceThreadMutex, 0) == WAIT_TIMEOUT)) { 1214 | ReleaseMutex(traceThreadMutex); 1215 | if (state == TRACING) { 1216 | Transit(TRACING); 1217 | trace_count++; 1218 | } 1219 | else if (state == STOPPING) { 1220 | Transit(STOPPING); 1221 | trace_count = 0; 1222 | } 1223 | } 1224 | if (trace_count > 5) { 1225 | Transit(STOPPING); 1226 | trace_count = 0; 1227 | } 1228 | CDialog::OnTimer(nIDEvent); 1229 | } 1230 | 1231 | 1232 | void WinMTRDialog::OnClose() 1233 | { 1234 | Transit(EXIT); 1235 | } 1236 | 1237 | 1238 | void WinMTRDialog::OnBnClickedCancel() 1239 | { 1240 | Transit(EXIT); 1241 | } 1242 | -------------------------------------------------------------------------------- /WinMTRDialog.h: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // FILE: WinMTRDialog.h 3 | // 4 | // 5 | // DESCRIPTION: 6 | // 7 | // 8 | // NOTES: 9 | // 10 | // 11 | //***************************************************************************** 12 | 13 | #ifndef WINMTRDIALOG_H_ 14 | #define WINMTRDIALOG_H_ 15 | 16 | #define WINMTR_DIALOG_TIMER 100 17 | 18 | #include "WinMTRStatusBar.h" 19 | #include "WinMTRNet.h" 20 | 21 | //***************************************************************************** 22 | // CLASS: WinMTRDialog 23 | // 24 | // 25 | //***************************************************************************** 26 | 27 | class WinMTRDialog : public CDialog 28 | { 29 | public: 30 | WinMTRDialog(CWnd* pParent = NULL); 31 | ~WinMTRDialog(); 32 | 33 | enum { IDD = IDD_WINMTR_DIALOG }; 34 | 35 | afx_msg BOOL InitRegistry(); 36 | 37 | WinMTRStatusBar statusBar; 38 | 39 | enum STATES { 40 | IDLE, 41 | TRACING, 42 | STOPPING, 43 | EXIT 44 | }; 45 | 46 | enum STATE_TRANSITIONS { 47 | IDLE_TO_IDLE, 48 | IDLE_TO_TRACING, 49 | IDLE_TO_EXIT, 50 | TRACING_TO_TRACING, 51 | TRACING_TO_STOPPING, 52 | TRACING_TO_EXIT, 53 | STOPPING_TO_IDLE, 54 | STOPPING_TO_STOPPING, 55 | STOPPING_TO_EXIT 56 | }; 57 | 58 | CButton m_buttonOptions; 59 | CButton m_buttonExit; 60 | CButton m_buttonStart; 61 | CComboBox m_comboHost; 62 | CListCtrl m_listMTR; 63 | 64 | CStatic m_staticS; 65 | CStatic m_staticJ; 66 | 67 | CButton m_buttonExpT; 68 | CButton m_buttonExpH; 69 | 70 | int InitMTRNet(); 71 | 72 | int DisplayRedraw(); 73 | void Transit(STATES new_state); 74 | 75 | STATES state; 76 | STATE_TRANSITIONS transition; 77 | HANDLE traceThreadMutex; 78 | double interval; 79 | bool hasIntervalFromCmdLine; 80 | int pingsize; 81 | bool hasPingsizeFromCmdLine; 82 | int maxLRU; 83 | bool hasMaxLRUFromCmdLine; 84 | int nrLRU; 85 | BOOL useDNS; 86 | bool hasUseDNSFromCmdLine; 87 | WinMTRNet* wmtrnet; 88 | 89 | void SetHostName(const char *host); 90 | void SetInterval(float i); 91 | void SetPingSize(int ps); 92 | void SetMaxLRU(int mlru); 93 | void SetUseDNS(BOOL udns); 94 | 95 | protected: 96 | virtual void DoDataExchange(CDataExchange* pDX); 97 | 98 | int m_autostart; 99 | char msz_defaulthostname[1000]; 100 | 101 | HICON m_hIcon; 102 | 103 | virtual BOOL OnInitDialog(); 104 | afx_msg void OnPaint(); 105 | afx_msg void OnSize(UINT, int, int); 106 | afx_msg void OnSizing(UINT, LPRECT); 107 | afx_msg HCURSOR OnQueryDragIcon(); 108 | afx_msg void OnRestart(); 109 | afx_msg void OnOptions(); 110 | virtual void OnCancel(); 111 | 112 | afx_msg void OnCTTC(); 113 | afx_msg void OnCHTC(); 114 | afx_msg void OnEXPT(); 115 | afx_msg void OnEXPH(); 116 | 117 | afx_msg void OnDblclkList(NMHDR* pNMHDR, LRESULT* pResult); 118 | 119 | DECLARE_MESSAGE_MAP() 120 | public: 121 | afx_msg void OnCbnSelchangeComboHost(); 122 | afx_msg void OnCbnSelendokComboHost(); 123 | private: 124 | void ClearHistory(); 125 | public: 126 | afx_msg void OnCbnCloseupComboHost(); 127 | afx_msg void OnTimer(UINT_PTR nIDEvent); 128 | afx_msg void OnClose(); 129 | afx_msg void OnBnClickedCancel(); 130 | }; 131 | 132 | #endif // ifndef WINMTRDIALOG_H_ 133 | -------------------------------------------------------------------------------- /WinMTRGlobal.cpp: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // FILE: WinMTRGlobal.cpp 3 | // 4 | // 5 | //***************************************************************************** 6 | 7 | #include "WinMTRGlobal.h" 8 | 9 | //***************************************************************************** 10 | // gettimeofday 11 | // 12 | // win32 port of unix gettimeofday 13 | //***************************************************************************** 14 | int gettimeofday(struct timeval* tv, struct timezone *tz) 15 | { 16 | if(!tv) 17 | return -1; 18 | struct _timeb timebuffer; 19 | 20 | _ftime(&timebuffer); 21 | 22 | tv->tv_sec = timebuffer.time; 23 | tv->tv_usec = timebuffer.millitm * 1000 + 500; 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /WinMTRGlobal.h: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // FILE: WinMTRGlobal.h 3 | // 4 | // 5 | // DESCRIPTION: 6 | // 7 | // 8 | // NOTES: 9 | // 10 | // 11 | //***************************************************************************** 12 | 13 | #ifndef GLOBAL_H_ 14 | #define GLOBAL_H_ 15 | 16 | #ifndef _WIN64 17 | #define _USE_32BIT_TIME_T 18 | #endif 19 | 20 | #define VC_EXTRALEAN 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #ifndef _AFX_NO_AFXCMN_SUPPORT 28 | #include 29 | #endif 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | #include "resource.h" 48 | 49 | #define WINMTR_VERSION "0.9" 50 | #define WINMTR_LICENSE "GPL - GNU Public License" 51 | #define WINMTR_COPYRIGHT "WinMTR 0.9 (c) 2010-2011 Appnor MSP - Fully Managed Hosting & Cloud Provider www.appnor.com" 52 | #define WINMTR_HOMEPAGE "http://WinMTR.sourceforge.net" 53 | 54 | #define DEFAULT_PING_SIZE 64 55 | #define DEFAULT_INTERVAL 1.0 56 | #define DEFAULT_MAX_LRU 128 57 | #define DEFAULT_DNS TRUE 58 | 59 | #define SAVED_PINGS 100 60 | #define MaxHost 256 61 | //#define MaxSequence 65536 62 | #define MaxSequence 32767 63 | //#define MaxSequence 5 64 | 65 | #define MAXPACKET 4096 66 | #define MINPACKET 64 67 | 68 | #define MaxTransit 4 69 | 70 | 71 | #define ICMP_ECHO 8 72 | #define ICMP_ECHOREPLY 0 73 | 74 | #define ICMP_TSTAMP 13 75 | #define ICMP_TSTAMPREPLY 14 76 | 77 | #define ICMP_TIME_EXCEEDED 11 78 | 79 | #define ICMP_HOST_UNREACHABLE 3 80 | 81 | #define MAX_UNKNOWN_HOSTS 10 82 | 83 | #define IP_HEADER_LENGTH 20 84 | 85 | 86 | #define MTR_NR_COLS 9 87 | 88 | const char MTR_COLS[ MTR_NR_COLS ][10] = { 89 | "Hostname", 90 | "Nr", 91 | "Loss %", 92 | "Sent", 93 | "Recv", 94 | "Best", 95 | "Avrg", 96 | "Worst", 97 | "Last" 98 | }; 99 | 100 | const int MTR_COL_LENGTH[ MTR_NR_COLS ] = { 101 | 390, 30, 50, 40, 40, 50, 50, 50, 50 102 | }; 103 | 104 | int gettimeofday(struct timeval* tv, struct timezone *tz); 105 | 106 | #endif // ifndef GLOBAL_H_ 107 | -------------------------------------------------------------------------------- /WinMTRHelp.cpp: -------------------------------------------------------------------------------- 1 | // WinMTRHelp.cpp : implementation file 2 | // 3 | 4 | #include "WinMTRGlobal.h" 5 | #include "WinMTRHelp.h" 6 | #include "afxdialogex.h" 7 | 8 | 9 | // WinMTRHelp dialog 10 | 11 | IMPLEMENT_DYNAMIC(WinMTRHelp, CDialog) 12 | 13 | WinMTRHelp::WinMTRHelp(CWnd* pParent /*=NULL*/) 14 | : CDialog(WinMTRHelp::IDD, pParent) 15 | { 16 | 17 | } 18 | 19 | WinMTRHelp::~WinMTRHelp() 20 | { 21 | } 22 | 23 | void WinMTRHelp::DoDataExchange(CDataExchange* pDX) 24 | { 25 | CDialog::DoDataExchange(pDX); 26 | } 27 | 28 | 29 | BEGIN_MESSAGE_MAP(WinMTRHelp, CDialog) 30 | ON_BN_CLICKED(IDOK, &WinMTRHelp::OnBnClickedOk) 31 | END_MESSAGE_MAP() 32 | 33 | 34 | // WinMTRHelp message handlers 35 | 36 | 37 | void WinMTRHelp::OnBnClickedOk() 38 | { 39 | // TODO: Add your control notification handler code here 40 | CDialog::OnOK(); 41 | } 42 | -------------------------------------------------------------------------------- /WinMTRHelp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // WinMTRHelp dialog 4 | 5 | class WinMTRHelp : public CDialog 6 | { 7 | DECLARE_DYNAMIC(WinMTRHelp) 8 | 9 | public: 10 | WinMTRHelp(CWnd* pParent = NULL); // standard constructor 11 | virtual ~WinMTRHelp(); 12 | 13 | // Dialog Data 14 | enum { IDD = IDD_DIALOG_HELP }; 15 | 16 | protected: 17 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 18 | 19 | DECLARE_MESSAGE_MAP() 20 | public: 21 | afx_msg void OnBnClickedOk(); 22 | }; 23 | -------------------------------------------------------------------------------- /WinMTRLicense.cpp: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // FILE: WinMTRLicense.cpp 3 | // 4 | // 5 | //***************************************************************************** 6 | 7 | #include "WinMTRGlobal.h" 8 | #include "WinMTRLicense.h" 9 | 10 | #ifdef _DEBUG 11 | #define new DEBUG_NEW 12 | #undef THIS_FILE 13 | static char THIS_FILE[] = __FILE__; 14 | #endif 15 | 16 | static const char LICENCE_TEXT_1[]={ 17 | " GNU GENERAL PUBLIC LICENSE\r\n\ 18 | Version 2, June 1991\r\n\ 19 | \r\n\ 20 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.\r\n\ 21 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r\n\ 22 | Everyone is permitted to copy and distribute verbatim copies\r\n\ 23 | of this license document, but changing it is not allowed.\r\n\ 24 | \r\n\ 25 | Preamble\r\n\ 26 | \r\n\ 27 | The licenses for most software are designed to take away your\r\n\ 28 | freedom to share and change it. By contrast, the GNU General Public\r\n\ 29 | License is intended to guarantee your freedom to share and change free\r\n\ 30 | software--to make sure the software is free for all its users. This\r\n\ 31 | General Public License applies to most of the Free Software\r\n\ 32 | Foundation's software and to any other program whose authors commit to\r\n\ 33 | using it. (Some other Free Software Foundation software is covered by\r\n\ 34 | the GNU Library General Public License instead.) You can apply it to\r\n\ 35 | your programs, too.\r\n\ 36 | \r\n\ 37 | When we speak of free software, we are referring to freedom, not\r\n\ 38 | price. Our General Public Licenses are designed to make sure that you\r\n\ 39 | have the freedom to distribute copies of free software (and charge for\r\n\ 40 | this service if you wish), that you receive source code or can get it\r\n\ 41 | if you want it, that you can change the software or use pieces of it\r\n\ 42 | in new free programs; and that you know you can do these things.\r\n\ 43 | \r\n\ 44 | To protect your rights, we need to make restrictions that forbid\r\n\ 45 | anyone to deny you these rights or to ask you to surrender the rights.\r\n\ 46 | These restrictions translate to certain responsibilities for you if you\r\n\ 47 | distribute copies of the software, or if you modify it.\r\n\ 48 | \r\n\ 49 | For example, if you distribute copies of such a program, whether\r\n\ 50 | gratis or for a fee, you must give the recipients all the rights that\r\n\ 51 | you have. You must make sure that they, too, receive or can get the\r\n\ 52 | source code. And you must show them these terms so they know their\r\n\ 53 | rights.\r\n\ 54 | \r\n\ 55 | We protect your rights with two steps: (1) copyright the software, and\r\n\ 56 | (2) offer you this license which gives you legal permission to copy,\r\n\ 57 | distribute and/or modify the software.\r\n\ 58 | \r\n\ 59 | Also, for each author's protection and ours, we want to make certain\r\n\ 60 | that everyone understands that there is no warranty for this free\r\n\ 61 | software. If the software is modified by someone else and passed on, we\r\n\ 62 | want its recipients to know that what they have is not the original, so\r\n\ 63 | that any problems introduced by others will not reflect on the original\r\n\ 64 | authors' reputations.\r\n\ 65 | \r\n\ 66 | Finally, any free program is threatened constantly by software\r\n\ 67 | patents. We wish to avoid the danger that redistributors of a free\r\n\ 68 | program will individually obtain patent licenses, in effect making the\r\n\ 69 | program proprietary. To prevent this, we have made it clear that any\r\n\ 70 | patent must be licensed for everyone's free use or not licensed at all.\r\n\ 71 | \r\n\ 72 | The precise terms and conditions for copying, distribution and\r\n\ 73 | modification follow.\r\n\ 74 | \r\n\ 75 | GNU GENERAL PUBLIC LICENSE\r\n\ 76 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\r\n\ 77 | \r\n\ 78 | 0. This License applies to any program or other work which contains\r\n\ 79 | a notice placed by the copyright holder saying it may be distributed\r\n\ 80 | under the terms of this General Public License. The \"Program\", below,\r\n\ 81 | refers to any such program or work, and a \"work based on the Program\"\r\n\ 82 | means either the Program or any derivative work under copyright law:\r\n\ 83 | that is to say, a work containing the Program or a portion of it,\r\n\ 84 | either verbatim or with modifications and/or translated into another\r\n\ 85 | language. (Hereinafter, translation is included without limitation in\r\n\ 86 | the term \"modification\".) Each licensee is addressed as \"you\".\r\n\ 87 | \r\n\ 88 | Activities other than copying, distribution and modification are not\r\n\ 89 | covered by this License; they are outside its scope. The act of\r\n\ 90 | running the Program is not restricted, and the output from the Program\r\n\ 91 | is covered only if its contents constitute a work based on the\r\n\ 92 | Program (independent of having been made by running the Program).\r\n\ 93 | Whether that is true depends on what the Program does.\r\n\ 94 | \r\n\ 95 | 1. You may copy and distribute verbatim copies of the Program's\r\n\ 96 | source code as you receive it, in any medium, provided that you\r\n\ 97 | conspicuously and appropriately publish on each copy an appropriate\r\n\ 98 | copyright notice and disclaimer of warranty; keep intact all the\r\n\ 99 | notices that refer to this License and to the absence of any warranty;\r\n\ 100 | and give any other recipients of the Program a copy of this License\r\n\ 101 | along with the Program.\r\n\ 102 | \r\n\ 103 | You may charge a fee for the physical act of transferring a copy, and\r\n\ 104 | you may at your option offer warranty protection in exchange for a fee.\r\n\ 105 | \r\n\ 106 | 2. You may modify your copy or copies of the Program or any portion\r\n\ 107 | of it, thus forming a work based on the Program, and copy and\r\n\ 108 | distribute such modifications or work under the terms of Section 1\r\n\ 109 | above, provided that you also meet all of these conditions:\r\n\ 110 | \r\n\ 111 | a) You must cause the modified files to carry prominent notices\r\n\ 112 | stating that you changed the files and the date of any change.\r\n\ 113 | \r\n\ 114 | b) You must cause any work that you distribute or publish, that in\r\n\ 115 | whole or in part contains or is derived from the Program or any\r\n\ 116 | part thereof, to be licensed as a whole at no charge to all third\r\n\ 117 | parties under the terms of this License.\r\n\ 118 | \r\n\ 119 | c) If the modified program normally reads commands interactively\r\n\ 120 | when run, you must cause it, when started running for such\r\n\ 121 | interactive use in the most ordinary way, to print or display an\r\n\ 122 | announcement including an appropriate copyright notice and a\r\n\ 123 | notice that there is no warranty (or else, saying that you provide\r\n\ 124 | a warranty) and that users may redistribute the program under\r\n\ 125 | these conditions, and telling the user how to view a copy of this\r\n\ 126 | License. (Exception: if the Program itself is interactive but\r\n\ 127 | does not normally print such an announcement, your work based on\r\n\ 128 | the Program is not required to print an announcement.)\r\n\ 129 | \r\n\ 130 | These requirements apply to the modified work as a whole. If\r\n\ 131 | identifiable sections of that work are not derived from the Program,\r\n\ 132 | and can be reasonably considered independent and separate works in\r\n\ 133 | themselves, then this License, and its terms, do not apply to those\r\n\ 134 | sections when you distribute them as separate works. But when you\r\n\ 135 | distribute the same sections as part of a whole which is a work based\r\n\ 136 | on the Program, the distribution of the whole must be on the terms of\r\n\ 137 | this License, whose permissions for other licensees extend to the\r\n\ 138 | entire whole, and thus to each and every part regardless of who wrote it.\r\n\ 139 | \r\n\ 140 | Thus, it is not the intent of this section to claim rights or contest\r\n\ 141 | your rights to work written entirely by you; rather, the intent is to\r\n\ 142 | exercise the right to control the distribution of derivative or\r\n\ 143 | collective works based on the Program.\r\n\ 144 | \r\n\ 145 | In addition, mere aggregation of another work not based on the Program\r\n\ 146 | with the Program (or with a work based on the Program) on a volume of\r\n\ 147 | a storage or distribution medium does not bring the other work under\r\n\ 148 | the scope of this License.\r\n\ 149 | \r\n\ 150 | 3. You may copy and distribute the Program (or a work based on it,\r\n\ 151 | under Section 2) in object code or executable form under the terms of\r\n\ 152 | Sections 1 and 2 above provided that you also do one of the following:\r\n\ 153 | \r\n\ 154 | a) Accompany it with the complete corresponding machine-readable\r\n\ 155 | source code, which must be distributed under the terms of Sections\r\n\ 156 | 1 and 2 above on a medium customarily used for software interchange; or,\r\n\ 157 | \r\n\ 158 | b) Accompany it with a written offer, valid for at least three\r\n\ 159 | years, to give any third party, for a charge no more than your\r\n\ 160 | cost of physically performing source distribution, a complete\r\n\ 161 | machine-readable copy of the corresponding source code, to be\r\n\ 162 | distributed under the terms of Sections 1 and 2 above on a medium\r\n\ 163 | customarily used for software interchange; or,\r\n\ 164 | \r\n\ 165 | c) Accompany it with the information you received as to the offer\r\n\ 166 | to distribute corresponding source code. (This alternative is\r\n\ 167 | allowed only for noncommercial distribution and only if you\r\n\ 168 | received the program in object code or executable form with such\r\n\ 169 | an offer, in accord with Subsection b above.)\r\n\ 170 | \r\n\ 171 | The source code for a work means the preferred form of the work for\r\n\ 172 | making modifications to it. For an executable work, complete source\r\n\ 173 | code means all the source code for all modules it contains, plus any\r\n\ 174 | associated interface definition files, plus the scripts used to\r\n\ 175 | control compilation and installation of the executable. However, as a\r\n\ 176 | special exception, the source code distributed need not include\r\n\ 177 | anything that is normally distributed (in either source or binary\r\n\ 178 | form) with the major components (compiler, kernel, and so on) of the\r\n\ 179 | operating system on which the executable runs, unless that component\r\n\ 180 | itself accompanies the executable.\r\n\ 181 | \r\n\ 182 | If distribution of executable or object code is made by offering\r\n\ 183 | access to copy from a designated place, then offering equivalent\r\n\ 184 | access to copy the source code from the same place counts as\r\n\ 185 | distribution of the source code, even though third parties are not\r\n\ 186 | compelled to copy the source along with the object code.\r\n\ 187 | \r\n\ 188 | 4. You may not copy, modify, sublicense, or distribute the Program\r\n\ 189 | except as expressly provided under this License. Any attempt\r\n\ 190 | otherwise to copy, modify, sublicense or distribute the Program is\r\n\ 191 | void, and will automatically terminate your rights under this License.\r\n\ 192 | However, parties who have received copies, or rights, from you under\r\n\ 193 | this License will not have their licenses terminated so long as such\r\n\ 194 | parties remain in full compliance.\r\n\ 195 | \r\n\ 196 | 5. You are not required to accept this License, since you have not\r\n\ 197 | signed it. However, nothing else grants you permission to modify or\r\n\ 198 | distribute the Program or its derivative works. These actions are\r\n\ 199 | prohibited by law if you do not accept this License. Therefore, by\r\n\ 200 | modifying or distributing the Program (or any work based on the\r\n\ 201 | Program), you indicate your acceptance of this License to do so, and\r\n\ 202 | all its terms and conditions for copying, distributing or modifying\r\n\ 203 | the Program or works based on it.\r\n\ 204 | \r\n\ 205 | 6. Each time you redistribute the Program (or any work based on the\r\n\ 206 | Program), the recipient automatically receives a license from the\r\n\ 207 | original licensor to copy, distribute or modify the Program subject to\r\n\ 208 | these terms and conditions. You may not impose any further\r\n\ 209 | restrictions on the recipients' exercise of the rights granted herein.\r\n\ 210 | You are not responsible for enforcing compliance by third parties to\r\n\ 211 | this License.\r\n\ 212 | \r\n\ 213 | 7. If, as a consequence of a court judgment or allegation of patent\r\n\ 214 | infringement or for any other reason (not limited to patent issues),\r\n\ 215 | conditions are imposed on you (whether by court order, agreement or\r\n\ 216 | otherwise) that contradict the conditions of this License, they do not\r\n\ 217 | excuse you from the conditions of this License. If you cannot\r\n\ 218 | distribute so as to satisfy simultaneously your obligations under this\r\n\ 219 | License and any other pertinent obligations, then as a consequence you\r\n\ 220 | may not distribute the Program at all. For example, if a patent\r\n\ 221 | license would not permit royalty-free redistribution of the Program by\r\n\ 222 | all those who receive copies directly or indirectly through you, then\r\n\ 223 | the only way you could satisfy both it and this License would be to\r\n\ 224 | refrain entirely from distribution of the Program.\r\n\ 225 | \r\n\ 226 | If any portion of this section is held invalid or unenforceable under\r\n\ 227 | any particular circumstance, the balance of the section is intended to\r\n\ 228 | apply and the section as a whole is intended to apply in other\r\n\ 229 | circumstances.\r\n\ 230 | \r\n\ 231 | It is not the purpose of this section to induce you to infringe any\r\n\ 232 | patents or other property right claims or to contest validity of any\r\n\ 233 | such claims; this section has the sole purpose of protecting the\r\n\ 234 | integrity of the free software distribution system, which is\r\n\ 235 | implemented by public license practices. Many people have made\r\n\ 236 | generous contributions to the wide range of software distributed\r\n\ 237 | through that system in reliance on consistent application of that\r\n\ 238 | system; it is up to the author/donor to decide if he or she is willing\r\n\ 239 | to distribute software through any other system and a licensee cannot\r\n\ 240 | impose that choice.\r\n\ 241 | \r\n\ 242 | This section is intended to make thoroughly clear what is believed to\r\n\ 243 | be a consequence of the rest of this License.\r\n\ 244 | \r\n\ 245 | 8. If the distribution and/or use of the Program is restricted in\r\n\ 246 | certain countries either by patents or by copyrighted interfaces, the\r\n\ 247 | original copyright holder who places the Program under this License\r\n\ 248 | may add an explicit geographical distribution limitation excluding\r\n\ 249 | those countries, so that distribution is permitted only in or among\r\n\ 250 | countries not thus excluded. In such case, this License incorporates\r\n\ 251 | the limitation as if written in the body of this License.\r\n\ 252 | \r\n\ 253 | 9. The Free Software Foundation may publish revised and/or new versions\r\n\ 254 | of the General Public License from time to time. Such new versions will\r\n\ 255 | be similar in spirit to the present version, but may differ in detail to\r\n\ 256 | address new problems or concerns.\r\n\ 257 | \r\n\ 258 | Each version is given a distinguishing version number. If the Program\r\n\ 259 | specifies a version number of this License which applies to it and \"any\r\n\ 260 | later version\", you have the option of following the terms and conditions\r\n\ 261 | either of that version or of any later version published by the Free\r\n\ 262 | Software Foundation. If the Program does not specify a version number of\r\n\ 263 | this License, you may choose any version ever published by the Free Software\r\n\ 264 | Foundation.\r\n\ 265 | \r\n\ 266 | 10. If you wish to incorporate parts of the Program into other free\r\n\ 267 | programs whose distribution conditions are different, write to the author\r\n\ 268 | to ask for permission. For software which is copyrighted by the Free\r\n\ 269 | Software Foundation, write to the Free Software Foundation; we sometimes\r\n\ 270 | make exceptions for this. Our decision will be guided by the two goals\r\n\ 271 | of preserving the free status of all derivatives of our free software and\r\n\ 272 | of promoting the sharing and reuse of software generally.\r\n\ 273 | \r\n\ 274 | NO WARRANTY\r\n\ 275 | \r\n\ 276 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\r\n\ 277 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN\r\n\ 278 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\r\n\ 279 | PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\r\n\ 280 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r\n\ 281 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS\r\n\ 282 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE\r\n\ 283 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\r\n\ 284 | REPAIR OR CORRECTION.\r\n\ 285 | \r\n\ 286 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\r\n\ 287 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\r\n\ 288 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\r\n\ 289 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\r\n\ 290 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\r\n\ 291 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\r\n\ 292 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\r\n\ 293 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\r\n\ 294 | POSSIBILITY OF SUCH DAMAGES.\r\n\ 295 | \r\n\ 296 | END OF TERMS AND CONDITIONS\r\n"}; 297 | static const char LICENCE_TEXT_2[]={ 298 | "\r\n\ 299 | How to Apply These Terms to Your New Programs\r\n\ 300 | \r\n\ 301 | If you develop a new program, and you want it to be of the greatest\r\n\ 302 | possible use to the public, the best way to achieve this is to make it\r\n\ 303 | free software which everyone can redistribute and change under these terms.\r\n\ 304 | \r\n\ 305 | To do so, attach the following notices to the program. It is safest\r\n\ 306 | to attach them to the start of each source file to most effectively\r\n\ 307 | convey the exclusion of warranty; and each file should have at least\r\n\ 308 | the \"copyright\" line and a pointer to where the full notice is found.\r\n\ 309 | \r\n\ 310 | \r\n\ 311 | Copyright (C) 19yy \r\n\ 312 | \r\n\ 313 | This program is free software; you can redistribute it and/or modify\r\n\ 314 | it under the terms of the GNU General Public License as published by\r\n\ 315 | the Free Software Foundation; either version 2 of the License, or\r\n\ 316 | (at your option) any later version.\r\n\ 317 | \r\n\ 318 | This program is distributed in the hope that it will be useful,\r\n\ 319 | but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n\ 320 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n\ 321 | GNU General Public License for more details.\r\n\ 322 | \r\n\ 323 | You should have received a copy of the GNU General Public License\r\n\ 324 | along with this program; if not, write to the Free Software\r\n\ 325 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r\n\ 326 | \r\n\ 327 | \r\n\ 328 | Also add information on how to contact you by electronic and paper mail.\r\n\ 329 | \r\n\ 330 | If the program is interactive, make it output a short notice like this\r\n\ 331 | when it starts in an interactive mode:\r\n\ 332 | \r\n\ 333 | Gnomovision version 69, Copyright (C) 19yy name of author\r\n\ 334 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\r\n\ 335 | This is free software, and you are welcome to redistribute it\r\n\ 336 | under certain conditions; type `show c' for details.\r\n\ 337 | \r\n\ 338 | The hypothetical commands `show w' and `show c' should show the appropriate\r\n\ 339 | parts of the General Public License. Of course, the commands you use may\r\n\ 340 | be called something other than `show w' and `show c'; they could even be\r\n\ 341 | mouse-clicks or menu items--whatever suits your program.\r\n\ 342 | \r\n\ 343 | You should also get your employer (if you work as a programmer) or your\r\n\ 344 | school, if any, to sign a \"copyright disclaimer\" for the program, if\r\n\ 345 | necessary. Here is a sample; alter the names:\r\n\ 346 | \r\n\ 347 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program\r\n\ 348 | `Gnomovision' (which makes passes at compilers) written by James Hacker.\r\n\ 349 | \r\n\ 350 | , 1 April 1989\r\n\ 351 | Ty Coon, President of Vice\r\n\ 352 | \r\n\ 353 | This General Public License does not permit incorporating your program into\r\n\ 354 | proprietary programs. If your program is a subroutine library, you may\r\n\ 355 | consider it more useful to permit linking proprietary applications with the\r\n\ 356 | library. If this is what you want to do, use the GNU Library General\r\n\ 357 | Public License instead of this License."}; 358 | 359 | //***************************************************************************** 360 | // BEGIN_MESSAGE_MAP 361 | // 362 | // 363 | //***************************************************************************** 364 | BEGIN_MESSAGE_MAP(WinMTRLicense, CDialog) 365 | END_MESSAGE_MAP() 366 | 367 | 368 | //***************************************************************************** 369 | // WinMTRLicense::WinMTRLicense 370 | // 371 | // 372 | //***************************************************************************** 373 | WinMTRLicense::WinMTRLicense(CWnd* pParent) : CDialog(WinMTRLicense::IDD, pParent) 374 | { 375 | } 376 | 377 | 378 | //***************************************************************************** 379 | // WinMTRLicense::DoDataExchange 380 | // 381 | // 382 | //***************************************************************************** 383 | void WinMTRLicense::DoDataExchange(CDataExchange* pDX) 384 | { 385 | CDialog::DoDataExchange(pDX); 386 | } 387 | 388 | 389 | //***************************************************************************** 390 | // WinMTRLicense::OnInitDialog 391 | // 392 | // 393 | //***************************************************************************** 394 | BOOL WinMTRLicense::OnInitDialog() 395 | { 396 | CDialog::OnInitDialog(); 397 | /* 398 | m_editLicense.SetSel(-1, -1); 399 | m_editLicense.ReplaceSel(LICENCE_TEXT_1); 400 | m_editLicense.SetSel(-1, -1); 401 | m_editLicense.ReplaceSel(LICENCE_TEXT_2); 402 | */ 403 | return FALSE; 404 | } 405 | 406 | -------------------------------------------------------------------------------- /WinMTRLicense.h: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // FILE: WinMTRLicense.h 3 | // 4 | // 5 | // DESCRIPTION: 6 | // 7 | // 8 | // NOTES: 9 | // 10 | // 11 | //***************************************************************************** 12 | 13 | #ifndef WINMTRLICENSE_H_ 14 | #define WINMTRLICENSE_H_ 15 | 16 | 17 | 18 | //***************************************************************************** 19 | // CLASS: WinMTRLicense 20 | // 21 | // 22 | //***************************************************************************** 23 | 24 | class WinMTRLicense : public CDialog 25 | { 26 | public: 27 | WinMTRLicense(CWnd* pParent = NULL); 28 | 29 | 30 | enum { IDD = IDD_DIALOG_LICENSE }; 31 | 32 | protected: 33 | virtual void DoDataExchange(CDataExchange* pDX); 34 | 35 | virtual BOOL OnInitDialog(); 36 | 37 | DECLARE_MESSAGE_MAP() 38 | }; 39 | 40 | #endif // ifndef WINMTRLICENSE_H_ 41 | -------------------------------------------------------------------------------- /WinMTRMain.cpp: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // FILE: WinMTRMain.cpp 3 | // 4 | // 5 | // HISTORY: 6 | // 7 | // 8 | // -- versions 0.8 9 | // 10 | // - 01.18.2002 - Store LRU hosts in registry (v0.8) 11 | // - 05.08.2001 - Replace edit box with combo box which hold last entered hostnames. 12 | // Fixed a memory leak which caused program to crash after a long 13 | // time running. (v0.7) 14 | // - 11.27.2000 - Added resizing support and flat buttons. (v0.6) 15 | // - 11.26.2000 - Added copy data to clipboard and posibility to save data to file as text or HTML.(v0.5) 16 | // - 08.03.2000 - added double-click on hostname for detailed information (v0.4) 17 | // - 08.02.2000 - fix icmp error codes handling. (v0.3) 18 | // - 08.01.2000 - support for full command-line parameter specification (v0.2) 19 | // - 07.30.2000 - support for command-line host specification 20 | // by Silviu Simen (ssimen@ubisoft.ro) (v0.1b) 21 | // - 07.28.2000 - first release (v0.1) 22 | //***************************************************************************** 23 | 24 | #include "WinMTRGlobal.h" 25 | #include "WinMTRMain.h" 26 | #include "WinMTRDialog.h" 27 | #include "WinMTRHelp.h" 28 | #include 29 | #include 30 | 31 | #ifdef _DEBUG 32 | #define new DEBUG_NEW 33 | #undef THIS_FILE 34 | static char THIS_FILE[] = __FILE__; 35 | #endif 36 | 37 | WinMTRMain WinMTR; 38 | 39 | //***************************************************************************** 40 | // BEGIN_MESSAGE_MAP 41 | // 42 | // 43 | //***************************************************************************** 44 | BEGIN_MESSAGE_MAP(WinMTRMain, CWinApp) 45 | ON_COMMAND(ID_HELP, CWinApp::OnHelp) 46 | END_MESSAGE_MAP() 47 | 48 | //***************************************************************************** 49 | // WinMTRMain::WinMTRMain 50 | // 51 | // 52 | //***************************************************************************** 53 | WinMTRMain::WinMTRMain() 54 | { 55 | } 56 | 57 | //***************************************************************************** 58 | // WinMTRMain::InitInstance 59 | // 60 | // 61 | //***************************************************************************** 62 | BOOL WinMTRMain::InitInstance() 63 | { 64 | if (!AfxSocketInit()) 65 | { 66 | AfxMessageBox(IDP_SOCKETS_INIT_FAILED); 67 | return FALSE; 68 | } 69 | 70 | AfxEnableControlContainer(); 71 | 72 | #ifdef _AFXDLL 73 | Enable3dControls(); // Call this when using MFC in a shared DLL 74 | #endif 75 | 76 | 77 | WinMTRDialog mtrDialog; 78 | m_pMainWnd = &mtrDialog; 79 | 80 | if (strlen(m_lpCmdLine)) { 81 | strcat(m_lpCmdLine," "); 82 | ParseCommandLineParams(m_lpCmdLine, &mtrDialog); 83 | } 84 | 85 | int nResponse = mtrDialog.DoModal(); 86 | 87 | 88 | return FALSE; 89 | } 90 | 91 | 92 | //***************************************************************************** 93 | // WinMTRMain::ParseCommandLineParams 94 | // 95 | // 96 | //***************************************************************************** 97 | void WinMTRMain::ParseCommandLineParams(LPTSTR cmd, WinMTRDialog *wmtrdlg) 98 | { 99 | char value[1024]; 100 | std::string host_name = ""; 101 | 102 | if(GetParamValue(cmd, "help",'h', value)) { 103 | WinMTRHelp mtrHelp; 104 | m_pMainWnd = &mtrHelp; 105 | mtrHelp.DoModal(); 106 | exit(0); 107 | } 108 | 109 | if(GetHostNameParamValue(cmd, host_name)) { 110 | wmtrdlg->SetHostName(host_name.c_str()); 111 | } 112 | if(GetParamValue(cmd, "interval",'i', value)) { 113 | wmtrdlg->SetInterval((float)atof(value)); 114 | wmtrdlg->hasIntervalFromCmdLine = true; 115 | } 116 | if(GetParamValue(cmd, "size",'s', value)) { 117 | wmtrdlg->SetPingSize(atoi(value)); 118 | wmtrdlg->hasPingsizeFromCmdLine = true; 119 | } 120 | if(GetParamValue(cmd, "maxLRU",'m', value)) { 121 | wmtrdlg->SetMaxLRU(atoi(value)); 122 | wmtrdlg->hasMaxLRUFromCmdLine = true; 123 | } 124 | if(GetParamValue(cmd, "numeric",'n', value)) { 125 | wmtrdlg->SetUseDNS(FALSE); 126 | wmtrdlg->hasUseDNSFromCmdLine = true; 127 | } 128 | } 129 | 130 | //***************************************************************************** 131 | // WinMTRMain::GetParamValue 132 | // 133 | // 134 | //***************************************************************************** 135 | int WinMTRMain::GetParamValue(LPTSTR cmd, char * param, char sparam, char *value) 136 | { 137 | char *p; 138 | 139 | char p_long[1024]; 140 | char p_short[1024]; 141 | 142 | sprintf(p_long,"--%s ", param); 143 | sprintf(p_short,"-%c ", sparam); 144 | 145 | if( (p=strstr(cmd, p_long)) ) ; 146 | else 147 | p=strstr(cmd, p_short); 148 | 149 | if(p == NULL) 150 | return 0; 151 | 152 | if(strcmp(param,"numeric")==0) 153 | return 1; 154 | 155 | while(*p && *p!=' ') 156 | p++; 157 | while(*p==' ') p++; 158 | 159 | int i = 0; 160 | while(*p && *p!=' ') 161 | value[i++] = *p++; 162 | value[i]='\0'; 163 | 164 | return 1; 165 | } 166 | 167 | //***************************************************************************** 168 | // WinMTRMain::GetHostNameParamValue 169 | // 170 | // 171 | //***************************************************************************** 172 | int WinMTRMain::GetHostNameParamValue(LPTSTR cmd, std::string& host_name) 173 | { 174 | // WinMTR -h -i 1 -n google.com 175 | int size = strlen(cmd); 176 | std::string name = ""; 177 | while(cmd[--size] == ' '); 178 | 179 | size++; 180 | while(size-- && cmd[size] != ' ' && (cmd[size] != '-' || cmd[size - 1] != ' ')) { 181 | name = cmd[size ] + name; 182 | } 183 | 184 | if(size == -1) { 185 | if(name.length() == 0) { 186 | return 0; 187 | } else { 188 | host_name = name; 189 | return 1; 190 | } 191 | } 192 | if(cmd[size] == '-' && cmd[size - 1] == ' ') { 193 | // no target specified 194 | return 0; 195 | } 196 | 197 | std::string possible_argument = ""; 198 | 199 | while(size-- && cmd[size] != ' ') { 200 | possible_argument = cmd[size] + possible_argument; 201 | } 202 | 203 | if(possible_argument.length() && (possible_argument[0] != '-' || possible_argument == "-n" || possible_argument == "--numeric")) { 204 | host_name = name; 205 | return 1; 206 | } 207 | 208 | return 0; 209 | } 210 | -------------------------------------------------------------------------------- /WinMTRMain.h: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // FILE: WinMTRMain.h 3 | // 4 | // 5 | // DESCRIPTION: 6 | // 7 | // 8 | // NOTES: 9 | // 10 | // 11 | //***************************************************************************** 12 | 13 | #ifndef WINMTRMAIN_H_ 14 | #define WINMTRMAIN_H_ 15 | 16 | #include "WinMTRDialog.h" 17 | #include 18 | 19 | 20 | //***************************************************************************** 21 | // CLASS: WinMTRMain 22 | // 23 | // 24 | //***************************************************************************** 25 | 26 | class WinMTRMain : public CWinApp 27 | { 28 | public: 29 | WinMTRMain(); 30 | 31 | virtual BOOL InitInstance(); 32 | 33 | DECLARE_MESSAGE_MAP() 34 | 35 | private: 36 | void ParseCommandLineParams(LPTSTR cmd, WinMTRDialog *wmtrdlg); 37 | int GetParamValue(LPTSTR cmd, char * param, char sparam, char *value); 38 | int GetHostNameParamValue(LPTSTR cmd, std::string& value); 39 | 40 | }; 41 | 42 | #endif // ifndef WINMTRMAIN_H_ 43 | 44 | -------------------------------------------------------------------------------- /WinMTRNet.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oott123/WinMTR/cf8f6833537ee3e91be54d5822bf36ac49015462/WinMTRNet.cpp -------------------------------------------------------------------------------- /WinMTRNet.h: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // FILE: WinMTRNet.h 3 | // 4 | // 5 | // DESCRIPTION: 6 | // 7 | // 8 | // NOTES: 9 | // 10 | // 11 | //***************************************************************************** 12 | 13 | #ifndef WINMTRNET_H_ 14 | #define WINMTRNET_H_ 15 | 16 | 17 | class WinMTRDialog; 18 | 19 | typedef ip_option_information IPINFO, *PIPINFO, FAR *LPIPINFO; 20 | 21 | #ifdef _WIN64 22 | typedef icmp_echo_reply32 ICMPECHO, *PICMPECHO, FAR *LPICMPECHO; 23 | #else 24 | typedef icmp_echo_reply ICMPECHO, *PICMPECHO, FAR *LPICMPECHO; 25 | #endif 26 | 27 | #define ECHO_REPLY_TIMEOUT 5000 28 | 29 | struct s_nethost { 30 | __int32 addr; // IP as a decimal, big endian 31 | int xmit; // number of PING packets sent 32 | int returned; // number of ICMP echo replies received 33 | unsigned long total; // total time 34 | int last; // last time 35 | int best; // best time 36 | int worst; // worst time 37 | char name[255]; 38 | }; 39 | 40 | //***************************************************************************** 41 | // CLASS: WinMTRNet 42 | // 43 | // 44 | //***************************************************************************** 45 | 46 | class WinMTRNet { 47 | typedef HANDLE (WINAPI *LPFNICMPCREATEFILE)(VOID); 48 | typedef BOOL (WINAPI *LPFNICMPCLOSEHANDLE)(HANDLE); 49 | typedef DWORD (WINAPI *LPFNICMPSENDECHO)(HANDLE, u_long, LPVOID, WORD, LPVOID, LPVOID, DWORD, DWORD); 50 | 51 | public: 52 | 53 | WinMTRNet(WinMTRDialog *wp); 54 | ~WinMTRNet(); 55 | void DoTrace(int address); 56 | void ResetHops(); 57 | void StopTrace(); 58 | 59 | int GetAddr(int at); 60 | int GetName(int at, char *n); 61 | int GetBest(int at); 62 | int GetWorst(int at); 63 | int GetAvg(int at); 64 | int GetPercent(int at); 65 | int GetLast(int at); 66 | int GetReturned(int at); 67 | int GetXmit(int at); 68 | int GetMax(); 69 | 70 | void SetAddr(int at, __int32 addr); 71 | void SetName(int at, char *n); 72 | void SetBest(int at, int current); 73 | void SetWorst(int at, int current); 74 | void SetLast(int at, int last); 75 | void AddReturned(int at); 76 | void AddXmit(int at); 77 | 78 | WinMTRDialog *wmtrdlg; 79 | __int32 last_remote_addr; 80 | bool tracing; 81 | bool initialized; 82 | HANDLE hICMP; 83 | LPFNICMPCREATEFILE lpfnIcmpCreateFile; 84 | LPFNICMPCLOSEHANDLE lpfnIcmpCloseHandle; 85 | LPFNICMPSENDECHO lpfnIcmpSendEcho; 86 | private: 87 | HINSTANCE hICMP_DLL; 88 | 89 | struct s_nethost host[MaxHost]; 90 | HANDLE ghMutex; 91 | }; 92 | 93 | #endif // ifndef WINMTRNET_H_ 94 | -------------------------------------------------------------------------------- /WinMTROptions.cpp: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // FILE: WinMTROptions.cpp 3 | // 4 | // 5 | //***************************************************************************** 6 | 7 | #include "WinMTRGlobal.h" 8 | #include "WinMTROptions.h" 9 | #include "WinMTRLicense.h" 10 | 11 | #ifdef _DEBUG 12 | #define new DEBUG_NEW 13 | #undef THIS_FILE 14 | static char THIS_FILE[] = __FILE__; 15 | #endif 16 | 17 | 18 | //***************************************************************************** 19 | // BEGIN_MESSAGE_MAP 20 | // 21 | // 22 | //***************************************************************************** 23 | BEGIN_MESSAGE_MAP(WinMTROptions, CDialog) 24 | ON_BN_CLICKED(ID_LICENSE, OnLicense) 25 | END_MESSAGE_MAP() 26 | 27 | 28 | //***************************************************************************** 29 | // WinMTROptions::WinMTROptions 30 | // 31 | // 32 | //***************************************************************************** 33 | WinMTROptions::WinMTROptions(CWnd* pParent) : CDialog(WinMTROptions::IDD, pParent) 34 | { 35 | } 36 | 37 | 38 | //***************************************************************************** 39 | // WinMTROptions::DoDataExchange 40 | // 41 | // 42 | //***************************************************************************** 43 | void WinMTROptions::DoDataExchange(CDataExchange* pDX) 44 | { 45 | CDialog::DoDataExchange(pDX); 46 | DDX_Control(pDX, IDC_EDIT_SIZE, m_editSize); 47 | DDX_Control(pDX, IDC_EDIT_INTERVAL, m_editInterval); 48 | DDX_Control(pDX, IDC_EDIT_MAX_LRU, m_editMaxLRU); 49 | DDX_Control(pDX, IDC_CHECK_DNS, m_checkDNS); 50 | } 51 | 52 | 53 | //***************************************************************************** 54 | // WinMTROptions::OnInitDialog 55 | // 56 | // 57 | //***************************************************************************** 58 | BOOL WinMTROptions::OnInitDialog() 59 | { 60 | CDialog::OnInitDialog(); 61 | 62 | char strtmp[20]; 63 | 64 | sprintf(strtmp, "%.1f", interval); 65 | m_editInterval.SetWindowText(strtmp); 66 | 67 | sprintf(strtmp, "%d", pingsize); 68 | m_editSize.SetWindowText(strtmp); 69 | 70 | sprintf(strtmp, "%d", maxLRU); 71 | m_editMaxLRU.SetWindowText(strtmp); 72 | 73 | m_checkDNS.SetCheck(useDNS); 74 | 75 | m_editInterval.SetFocus(); 76 | return FALSE; 77 | } 78 | 79 | 80 | //***************************************************************************** 81 | // WinMTROptions::OnOK 82 | // 83 | // 84 | //***************************************************************************** 85 | void WinMTROptions::OnOK() 86 | { 87 | char tmpstr[20]; 88 | 89 | useDNS = m_checkDNS.GetCheck(); 90 | 91 | m_editInterval.GetWindowText(tmpstr, 20); 92 | interval = atof(tmpstr); 93 | 94 | m_editSize.GetWindowText(tmpstr, 20); 95 | pingsize = atoi(tmpstr); 96 | 97 | m_editMaxLRU.GetWindowText(tmpstr, 20); 98 | maxLRU = atoi(tmpstr); 99 | 100 | CDialog::OnOK(); 101 | } 102 | 103 | //***************************************************************************** 104 | // WinMTROptions::OnLicense 105 | // 106 | // 107 | //***************************************************************************** 108 | void WinMTROptions::OnLicense() 109 | { 110 | WinMTRLicense mtrlicense; 111 | mtrlicense.DoModal(); 112 | } 113 | -------------------------------------------------------------------------------- /WinMTROptions.h: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // FILE: WinMTROptions.h 3 | // 4 | // 5 | // DESCRIPTION: 6 | // 7 | // 8 | // NOTES: 9 | // 10 | // 11 | //***************************************************************************** 12 | 13 | #ifndef WINMTROPTIONS_H_ 14 | #define WINMTROPTIONS_H_ 15 | 16 | 17 | 18 | //***************************************************************************** 19 | // CLASS: WinMTROptions 20 | // 21 | // 22 | //***************************************************************************** 23 | 24 | class WinMTROptions : public CDialog 25 | { 26 | public: 27 | WinMTROptions(CWnd* pParent = NULL); 28 | 29 | void SetUseDNS(BOOL udns) { useDNS = udns; }; 30 | void SetInterval(double i) { interval = i; }; 31 | void SetPingSize(int ps) { pingsize = ps; }; 32 | void SetMaxLRU(int mlru) { maxLRU = mlru; }; 33 | 34 | double GetInterval() { return interval; }; 35 | int GetPingSize() { return pingsize; }; 36 | int GetMaxLRU() { return maxLRU; }; 37 | BOOL GetUseDNS() { return useDNS; }; 38 | 39 | enum { IDD = IDD_DIALOG_OPTIONS }; 40 | CEdit m_editSize; 41 | CEdit m_editInterval; 42 | CEdit m_editMaxLRU; 43 | CButton m_checkDNS; 44 | 45 | protected: 46 | virtual void DoDataExchange(CDataExchange* pDX); 47 | 48 | virtual BOOL OnInitDialog(); 49 | virtual void OnOK(); 50 | 51 | afx_msg void OnLicense(); 52 | 53 | DECLARE_MESSAGE_MAP() 54 | 55 | private: 56 | double interval; 57 | int pingsize; 58 | int maxLRU; 59 | BOOL useDNS; 60 | }; 61 | 62 | #endif // ifndef WINMTROPTIONS_H_ 63 | -------------------------------------------------------------------------------- /WinMTRProperties.cpp: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // FILE: WinMTRProperties.cpp 3 | // 4 | // 5 | //***************************************************************************** 6 | 7 | #include "WinMTRGlobal.h" 8 | #include "WinMTRProperties.h" 9 | 10 | #ifdef _DEBUG 11 | #define new DEBUG_NEW 12 | #undef THIS_FILE 13 | static char THIS_FILE[] = __FILE__; 14 | #endif 15 | 16 | 17 | //***************************************************************************** 18 | // BEGIN_MESSAGE_MAP 19 | // 20 | // 21 | //***************************************************************************** 22 | BEGIN_MESSAGE_MAP(WinMTRProperties, CDialog) 23 | END_MESSAGE_MAP() 24 | 25 | 26 | //***************************************************************************** 27 | // WinMTRProperties::WinMTRProperties 28 | // 29 | // 30 | //***************************************************************************** 31 | WinMTRProperties::WinMTRProperties(CWnd* pParent) : CDialog(WinMTRProperties::IDD, pParent) 32 | { 33 | } 34 | 35 | 36 | //***************************************************************************** 37 | // WinMTRroperties::DoDataExchange 38 | // 39 | // 40 | //***************************************************************************** 41 | void WinMTRProperties::DoDataExchange(CDataExchange* pDX) 42 | { 43 | CDialog::DoDataExchange(pDX); 44 | DDX_Control(pDX, IDC_EDIT_PHOST, m_editHost); 45 | DDX_Control(pDX, IDC_EDIT_PIP, m_editIP); 46 | DDX_Control(pDX, IDC_EDIT_PCOMMENT, m_editComment); 47 | 48 | DDX_Control(pDX, IDC_EDIT_PLOSS, m_editLoss); 49 | DDX_Control(pDX, IDC_EDIT_PSENT, m_editSent); 50 | DDX_Control(pDX, IDC_EDIT_PRECV, m_editRecv); 51 | 52 | DDX_Control(pDX, IDC_EDIT_PLAST, m_editLast); 53 | DDX_Control(pDX, IDC_EDIT_PBEST, m_editBest); 54 | DDX_Control(pDX, IDC_EDIT_PWORST, m_editWorst); 55 | DDX_Control(pDX, IDC_EDIT_PAVRG, m_editAvrg); 56 | } 57 | 58 | 59 | //***************************************************************************** 60 | // WinMTRProperties::OnInitDialog 61 | // 62 | // 63 | //***************************************************************************** 64 | BOOL WinMTRProperties::OnInitDialog() 65 | { 66 | CDialog::OnInitDialog(); 67 | char buf[255]; 68 | 69 | m_editIP.SetWindowText(ip); 70 | m_editHost.SetWindowText(host); 71 | m_editComment.SetWindowText(comment); 72 | 73 | sprintf(buf, "%d", pck_loss); 74 | m_editLoss.SetWindowText(buf); 75 | sprintf(buf, "%d", pck_sent); 76 | m_editSent.SetWindowText(buf); 77 | sprintf(buf, "%d", pck_recv); 78 | m_editRecv.SetWindowText(buf); 79 | 80 | sprintf(buf, "%.1f", ping_last); 81 | m_editLast.SetWindowText(buf); 82 | sprintf(buf, "%.1f", ping_best); 83 | m_editBest.SetWindowText(buf); 84 | sprintf(buf, "%.1f", ping_worst); 85 | m_editWorst.SetWindowText(buf); 86 | sprintf(buf, "%.1f", ping_avrg); 87 | m_editAvrg.SetWindowText(buf); 88 | 89 | return FALSE; 90 | } 91 | 92 | -------------------------------------------------------------------------------- /WinMTRProperties.h: -------------------------------------------------------------------------------- 1 | //***************************************************************************** 2 | // FILE: WinMTRProperties.h 3 | // 4 | // 5 | // DESCRIPTION: 6 | // 7 | // 8 | // NOTES: 9 | // 10 | // 11 | //***************************************************************************** 12 | 13 | #ifndef WINMTRPROPERTIES_H_ 14 | #define WINMTRPROPERTIES_H_ 15 | 16 | 17 | 18 | //***************************************************************************** 19 | // CLASS: WinMTRLicense 20 | // 21 | // 22 | //***************************************************************************** 23 | 24 | class WinMTRProperties : public CDialog 25 | { 26 | public: 27 | WinMTRProperties(CWnd* pParent = NULL); 28 | 29 | 30 | enum { IDD = IDD_DIALOG_PROPERTIES }; 31 | 32 | char host[255]; 33 | char ip[16]; 34 | char comment[255]; 35 | 36 | float ping_last; 37 | float ping_best; 38 | float ping_avrg; 39 | float ping_worst; 40 | 41 | int pck_sent; 42 | int pck_recv; 43 | int pck_loss; 44 | 45 | CEdit m_editHost, 46 | m_editIP, 47 | m_editComment, 48 | m_editSent, 49 | m_editRecv, 50 | m_editLoss, 51 | m_editLast, 52 | m_editBest, 53 | m_editWorst, 54 | m_editAvrg; 55 | 56 | protected: 57 | virtual void DoDataExchange(CDataExchange* pDX); 58 | 59 | virtual BOOL OnInitDialog(); 60 | 61 | DECLARE_MESSAGE_MAP() 62 | }; 63 | 64 | #endif // ifndef WINMTRLICENSE_H_ 65 | -------------------------------------------------------------------------------- /WinMTRStatusBar.cpp: -------------------------------------------------------------------------------- 1 | #include "WinMTRGlobal.h" 2 | #include "WinMTRStatusBar.h" 3 | 4 | #ifdef _DEBUG 5 | #define new DEBUG_NEW 6 | #undef THIS_FILE 7 | static char THIS_FILE[] = __FILE__; 8 | #endif 9 | 10 | WinMTRStatusBar::WinMTRStatusBar() 11 | { 12 | } 13 | 14 | WinMTRStatusBar::~WinMTRStatusBar() 15 | { 16 | for ( int i = 0; i < m_arrPaneControls.GetSize(); i++ ){ 17 | if( m_arrPaneControls[i]->hWnd && ::IsWindow(m_arrPaneControls[i]->hWnd) ) { 18 | ::ShowWindow(m_arrPaneControls[i]->hWnd, SW_HIDE); 19 | if( m_arrPaneControls[i]->bAutoDestroy ) { 20 | ::DestroyWindow(m_arrPaneControls[i]->hWnd); 21 | } 22 | } 23 | _STATUSBAR_PANE_CTRL_ *pPaneCtrl = m_arrPaneControls[i]; 24 | if( pPaneCtrl ) 25 | delete pPaneCtrl; 26 | } 27 | } 28 | 29 | BEGIN_MESSAGE_MAP(WinMTRStatusBar, CStatusBar) 30 | //{{AFX_MSG_MAP(WinMTRStatusBar) 31 | ON_WM_CREATE() 32 | //}}AFX_MSG_MAP 33 | END_MESSAGE_MAP() 34 | 35 | 36 | ///////////////////////////////////////////////////////////////////////////// 37 | // WinMTRStatusBar message handlers 38 | ////////////////////////////////////////////////////////////////////////// 39 | 40 | int WinMTRStatusBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 41 | { 42 | if( CStatusBar::OnCreate(lpCreateStruct) == -1 ) 43 | return -1; 44 | 45 | return 0; 46 | } 47 | 48 | ////////////////////////////////////////////////////////////////////////// 49 | 50 | LRESULT WinMTRStatusBar::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 51 | { 52 | LRESULT lResult =CStatusBar::WindowProc(message, wParam, lParam); 53 | if( message == WM_SIZE ){ 54 | RepositionControls(); 55 | } 56 | return lResult; 57 | } 58 | 59 | ////////////////////////////////////////////////////////////////////////// 60 | 61 | void WinMTRStatusBar::RepositionControls() 62 | { 63 | HDWP _hDWP = ::BeginDeferWindowPos( m_arrPaneControls.GetSize() ); 64 | 65 | CRect rcClient; 66 | GetClientRect(&rcClient); 67 | for (int i = 0; i < m_arrPaneControls.GetSize(); i++ ) 68 | { 69 | int iIndex = CommandToIndex(m_arrPaneControls[i]->nID); 70 | HWND hWnd = m_arrPaneControls[i]->hWnd; 71 | 72 | CRect rcPane; 73 | GetItemRect(iIndex, &rcPane); 74 | 75 | // CStatusBar::GetItemRect() sometimes returns invalid size 76 | // of the last pane - we will re-compute it 77 | int cx = ::GetSystemMetrics( SM_CXEDGE ); 78 | DWORD dwPaneStyle = GetPaneStyle( iIndex ); 79 | if( iIndex == (m_nCount-1) ) 80 | { 81 | if( (dwPaneStyle & SBPS_STRETCH ) == 0 ) 82 | { 83 | UINT nID, nStyle; 84 | int cxWidth; 85 | GetPaneInfo( iIndex, nID, nStyle, cxWidth ); 86 | rcPane.right = rcPane.left + cxWidth + cx*3; 87 | } // if( (dwPaneStyle & SBPS_STRETCH ) == 0 ) 88 | else 89 | { 90 | CRect rcClient; 91 | GetClientRect( &rcClient ); 92 | rcPane.right = rcClient.right; 93 | if( (GetStyle() & SBARS_SIZEGRIP) == SBARS_SIZEGRIP ) 94 | { 95 | int cxSmIcon = ::GetSystemMetrics( SM_CXSMICON ); 96 | rcPane.right -= cxSmIcon + cx; 97 | } // if( (GetStyle() & SBARS_SIZEGRIP) == SBARS_SIZEGRIP ) 98 | } // else from if( (dwPaneStyle & SBPS_STRETCH ) == 0 ) 99 | } // if( iIndex == (m_nCount-1) ) 100 | 101 | if ((GetPaneStyle (iIndex) & SBPS_NOBORDERS) == 0){ 102 | rcPane.DeflateRect(cx,cx); 103 | }else{ 104 | rcPane.DeflateRect(cx,1,cx,1); 105 | } 106 | 107 | if (hWnd && ::IsWindow(hWnd)){ 108 | _hDWP = ::DeferWindowPos( 109 | _hDWP, 110 | hWnd, 111 | NULL, 112 | rcPane.left, 113 | rcPane.top, 114 | rcPane.Width(), 115 | rcPane.Height(), 116 | SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_SHOWWINDOW 117 | ); 118 | 119 | ::RedrawWindow( 120 | hWnd, 121 | NULL, 122 | NULL, 123 | RDW_INVALIDATE|RDW_UPDATENOW 124 | |RDW_ERASE|RDW_ERASENOW 125 | ); 126 | 127 | } // if (hWnd && ::IsWindow(hWnd)){ 128 | } 129 | 130 | VERIFY( ::EndDeferWindowPos( _hDWP ) ); 131 | }; 132 | 133 | ////////////////////////////////////////////////////////////////////////// 134 | 135 | BOOL WinMTRStatusBar::AddPane( 136 | UINT nID, // ID of the pane 137 | int nIndex // index of the pane 138 | ) 139 | { 140 | if (nIndex < 0 || nIndex > m_nCount){ 141 | ASSERT(FALSE); 142 | return FALSE; 143 | } 144 | 145 | if (CommandToIndex(nID) != -1){ 146 | ASSERT(FALSE); 147 | return FALSE; 148 | } 149 | 150 | CArray<_STATUSBAR_PANE_*,_STATUSBAR_PANE_*> arrPanesTmp; 151 | int iIndex = 0; 152 | for (iIndex = 0; iIndex < m_nCount+1; iIndex++) 153 | { 154 | _STATUSBAR_PANE_* pNewPane = new _STATUSBAR_PANE_; 155 | 156 | if (iIndex == nIndex){ 157 | pNewPane->nID = nID; 158 | pNewPane->nStyle = SBPS_NORMAL; 159 | }else{ 160 | int idx = iIndex; 161 | if (iIndex > nIndex) idx--; 162 | 163 | _STATUSBAR_PANE_* pOldPane = GetPanePtr(idx); 164 | pNewPane->cxText = pOldPane->cxText; 165 | pNewPane->nFlags = pOldPane->nFlags; 166 | pNewPane->nID = pOldPane->nID; 167 | pNewPane->nStyle = pOldPane->nStyle; 168 | pNewPane->strText = pOldPane->strText; 169 | } 170 | arrPanesTmp.Add(pNewPane); 171 | } 172 | 173 | int nPanesCount = arrPanesTmp.GetSize(); 174 | UINT* lpIDArray = new UINT[ nPanesCount ]; 175 | for (iIndex = 0; iIndex < nPanesCount; iIndex++) { 176 | lpIDArray[iIndex] = arrPanesTmp[iIndex]->nID; 177 | } 178 | 179 | // set the indicators 180 | SetIndicators(lpIDArray, nPanesCount); 181 | // free memory 182 | for (iIndex = 0; iIndex < nPanesCount; iIndex++){ 183 | _STATUSBAR_PANE_* pPane = arrPanesTmp[iIndex]; 184 | if (iIndex != nIndex) 185 | PaneInfoSet(iIndex, pPane); 186 | if(pPane) 187 | delete pPane; 188 | } 189 | 190 | arrPanesTmp.RemoveAll(); 191 | if(lpIDArray) 192 | delete []lpIDArray; 193 | 194 | RepositionControls(); 195 | 196 | return TRUE; 197 | } 198 | 199 | ////////////////////////////////////////////////////////////////////////// 200 | 201 | BOOL WinMTRStatusBar::RemovePane( 202 | UINT nID // ID of the pane 203 | ) 204 | { 205 | if ( CommandToIndex(nID) == -1 || m_nCount == 1 ){ 206 | ASSERT(FALSE); 207 | return FALSE; 208 | } 209 | 210 | CArray<_STATUSBAR_PANE_*,_STATUSBAR_PANE_*> arrPanesTmp; 211 | int nIndex; 212 | for (nIndex = 0; nIndex < m_nCount; nIndex++) 213 | { 214 | _STATUSBAR_PANE_* pOldPane = GetPanePtr(nIndex); 215 | 216 | if (pOldPane->nID == nID) 217 | continue; 218 | 219 | _STATUSBAR_PANE_* pNewPane = new _STATUSBAR_PANE_; 220 | 221 | pNewPane->cxText = pOldPane->cxText; 222 | pNewPane->nFlags = pOldPane->nFlags; 223 | pNewPane->nID = pOldPane->nID; 224 | pNewPane->nStyle = pOldPane->nStyle; 225 | pNewPane->strText = pOldPane->strText; 226 | arrPanesTmp.Add(pNewPane); 227 | } 228 | 229 | UINT* lpIDArray = new UINT[arrPanesTmp.GetSize()]; 230 | for (nIndex = 0; nIndex < arrPanesTmp.GetSize(); nIndex++) { 231 | lpIDArray[nIndex] = arrPanesTmp[nIndex]->nID; 232 | } 233 | 234 | // set the indicators 235 | SetIndicators(lpIDArray, arrPanesTmp.GetSize()); 236 | // free memory 237 | for (nIndex = 0; nIndex < arrPanesTmp.GetSize(); nIndex++){ 238 | _STATUSBAR_PANE_* pPane = arrPanesTmp[nIndex]; 239 | PaneInfoSet(nIndex, pPane); 240 | if(pPane) 241 | delete pPane; 242 | } 243 | 244 | for ( int i = 0; i < m_arrPaneControls.GetSize(); i++ ){ 245 | if (m_arrPaneControls[i]->nID == nID){ 246 | if( m_arrPaneControls[i]->hWnd && ::IsWindow(m_arrPaneControls[i]->hWnd) ) { 247 | ::ShowWindow(m_arrPaneControls[i]->hWnd, SW_HIDE); 248 | if( m_arrPaneControls[i]->bAutoDestroy ) { 249 | ::DestroyWindow(m_arrPaneControls[i]->hWnd); 250 | } 251 | } 252 | _STATUSBAR_PANE_CTRL_ *pPaneCtrl = m_arrPaneControls[i]; 253 | if( pPaneCtrl ) 254 | delete pPaneCtrl; 255 | m_arrPaneControls.RemoveAt(i); 256 | break; 257 | } 258 | } 259 | 260 | arrPanesTmp.RemoveAll(); 261 | if(lpIDArray) 262 | delete []lpIDArray; 263 | 264 | RepositionControls(); 265 | 266 | return TRUE; 267 | } 268 | 269 | ////////////////////////////////////////////////////////////////////////// 270 | 271 | BOOL WinMTRStatusBar::AddPaneControl(HWND hWnd, UINT nID, BOOL bAutoDestroy) 272 | { 273 | if (CommandToIndex (nID) == -1) { 274 | return FALSE; 275 | } 276 | 277 | _STATUSBAR_PANE_CTRL_* pPaneCtrl = new _STATUSBAR_PANE_CTRL_; 278 | pPaneCtrl->nID = nID; 279 | pPaneCtrl->hWnd = hWnd; 280 | pPaneCtrl->bAutoDestroy = bAutoDestroy; 281 | 282 | m_arrPaneControls.Add(pPaneCtrl); 283 | 284 | RepositionControls(); 285 | return TRUE; 286 | } 287 | 288 | ////////////////////////////////////////////////////////////////////////// 289 | 290 | BOOL WinMTRStatusBar::PaneInfoGet(int nIndex, _STATUSBAR_PANE_* pPane) 291 | { 292 | if( nIndex < m_nCount && nIndex >= 0 ) 293 | { 294 | GetPaneInfo( nIndex, pPane->nID, pPane->nStyle, pPane->cxText ); 295 | CString strPaneText; 296 | GetPaneText( nIndex , strPaneText ); 297 | pPane->strText = LPCTSTR(strPaneText); 298 | return TRUE; 299 | } 300 | return FALSE; 301 | } 302 | 303 | ////////////////////////////////////////////////////////////////////////// 304 | 305 | BOOL WinMTRStatusBar::PaneInfoSet(int nIndex, _STATUSBAR_PANE_* pPane) 306 | { 307 | if( nIndex < m_nCount && nIndex >= 0 ){ 308 | SetPaneInfo( nIndex, pPane->nID, pPane->nStyle, pPane->cxText ); 309 | SetPaneText( nIndex, LPCTSTR( pPane->strText) ); 310 | return TRUE; 311 | } 312 | return FALSE; 313 | } 314 | -------------------------------------------------------------------------------- /WinMTRStatusBar.h: -------------------------------------------------------------------------------- 1 | #ifndef WINMTRSTATUSBAR_H_ 2 | #define WINMTRSTATUSBAR_H_ 3 | 4 | class WinMTRStatusBar : public CStatusBar 5 | { 6 | // Construction 7 | public: 8 | 9 | WinMTRStatusBar(); 10 | 11 | // Attributes 12 | public: 13 | 14 | // Operations 15 | public: 16 | 17 | int GetPanesCount() const{ 18 | return m_nCount; 19 | } 20 | 21 | void SetPaneWidth(int nIndex, int nWidth) 22 | { 23 | _STATUSBAR_PANE_ pane; 24 | PaneInfoGet(nIndex, &pane); 25 | pane.cxText = nWidth; 26 | PaneInfoSet(nIndex, &pane); 27 | } 28 | 29 | BOOL AddPane( 30 | UINT nID, // ID of the pane 31 | int nIndex // index of the pane 32 | ); 33 | 34 | BOOL RemovePane( 35 | UINT nID // ID of the pane 36 | ); 37 | 38 | BOOL AddPaneControl(CWnd* pWnd, UINT nID, BOOL bAutoDestroy) 39 | { 40 | return AddPaneControl( pWnd->GetSafeHwnd(), nID, bAutoDestroy); 41 | } 42 | 43 | BOOL AddPaneControl(HWND hWnd, UINT nID, BOOL bAutoDestroy); 44 | 45 | void DisableControl( int nIndex, BOOL bDisable=TRUE) 46 | { 47 | UINT uItemID = GetItemID(nIndex); 48 | for ( int i = 0; i < m_arrPaneControls.GetSize(); i++ ){ 49 | if( uItemID == m_arrPaneControls[i]->nID ){ 50 | if( m_arrPaneControls[i]->hWnd && ::IsWindow(m_arrPaneControls[i]->hWnd) ) { 51 | ::EnableWindow(m_arrPaneControls[i]->hWnd, bDisable); 52 | } 53 | } 54 | } 55 | } 56 | 57 | void SetPaneInfo(int nIndex, UINT nID, UINT nStyle, int cxWidth) 58 | { 59 | CStatusBar::SetPaneInfo(nIndex, nID, nStyle, cxWidth); 60 | BOOL bDisabled = ((nStyle&SBPS_DISABLED) == 0); 61 | DisableControl(nIndex, bDisabled); 62 | } 63 | 64 | void SetPaneStyle(int nIndex, UINT nStyle) 65 | { 66 | CStatusBar::SetPaneStyle(nIndex, nStyle); 67 | BOOL bDisabled = ((nStyle&SBPS_DISABLED) == 0); 68 | DisableControl(nIndex, bDisabled); 69 | } 70 | 71 | // Overrides 72 | // ClassWizard generated virtual function overrides 73 | //{{AFX_VIRTUAL(WinMTRStatusBar) 74 | //}}AFX_VIRTUAL 75 | 76 | // Implementation 77 | public: 78 | virtual ~WinMTRStatusBar(); 79 | 80 | protected: 81 | 82 | struct _STATUSBAR_PANE_ 83 | { 84 | _STATUSBAR_PANE_(){ 85 | nID = cxText = nStyle = nFlags = 0; 86 | } 87 | 88 | UINT nID; // IDC of indicator: 0 => normal text area 89 | int cxText; // width of string area in pixels 90 | // on both sides there is a 3 pixel gap and 91 | // a one pixel border, making a pane 6 pixels wider 92 | UINT nStyle; // style flags (SBPS_*) 93 | UINT nFlags; // state flags (SBPF_*) 94 | CString strText; // text in the pane 95 | }; 96 | 97 | struct _STATUSBAR_PANE_CTRL_ 98 | { 99 | HWND hWnd; 100 | UINT nID; 101 | BOOL bAutoDestroy; 102 | }; 103 | 104 | CArray < _STATUSBAR_PANE_CTRL_*, _STATUSBAR_PANE_CTRL_* > m_arrPaneControls; 105 | 106 | _STATUSBAR_PANE_* GetPanePtr(int nIndex) const 107 | { 108 | ASSERT((nIndex >= 0 && nIndex < m_nCount) || m_nCount == 0); 109 | return ((_STATUSBAR_PANE_*)m_pData) + nIndex; 110 | } 111 | 112 | BOOL PaneInfoGet(int nIndex, _STATUSBAR_PANE_* pPane); 113 | BOOL PaneInfoSet(int nIndex, _STATUSBAR_PANE_* pPane); 114 | 115 | void RepositionControls(); 116 | 117 | // Generated message map functions 118 | protected: 119 | //{{AFX_MSG(WinMTRStatusBar) 120 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 121 | //}}AFX_MSG 122 | DECLARE_MESSAGE_MAP() 123 | virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); 124 | }; 125 | 126 | #endif // WINMTRSTATUSBAR_H_ 127 | -------------------------------------------------------------------------------- /resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by WinMTR.rc 4 | // 5 | #define IDD_WINMTR_DIALOG 102 6 | #define IDP_SOCKETS_INIT_FAILED 103 7 | #define IDS_STRING_SB_NAME 104 8 | #define IDS_STRING_SB_PING 105 9 | #define IDS_STRING_CLEAR_HISTORY 106 10 | #define IDR_MAINFRAME 128 11 | #define IDD_DIALOG_OPTIONS 129 12 | #define IDD_DIALOG_LICENSE 130 13 | #define IDD_DIALOG_PROPERTIES 131 14 | #define IDD_DIALOG_HELP 132 15 | #define IDC_EDIT_HOST 1000 16 | #define IDC_LIST_MTR 1001 17 | #define ID_RESTART 1002 18 | #define ID_OPTIONS 1003 19 | #define IDC_EDIT_INTERVAL 1004 20 | #define ID_CTTC 1004 21 | #define IDC_EDIT_SIZE 1005 22 | #define ID_CHTC 1005 23 | #define IDC_CHECK_DNS 1006 24 | #define ID_EXPT 1006 25 | #define ID_EXPH 1007 26 | #define ID_LICENSE 1008 27 | #define IDC_EDIT_LICENSE 1011 28 | #define IDC_EDIT_PHOST 1012 29 | #define IDC_EDIT_PIP 1013 30 | #define IDC_EDIT_PSENT 1014 31 | #define IDC_EDIT_PRECV 1015 32 | #define IDC_EDIT_PLOSS 1016 33 | #define IDC_EDIT_PLAST 1017 34 | #define IDC_EDIT_PBEST 1018 35 | #define IDC_EDIT_PAVRG 1019 36 | #define IDC_EDIT_PWORST 1020 37 | #define IDC_EDIT_PCOMMENT 1021 38 | #define IDC_STATICS 1022 39 | #define IDC_STATICJ 1023 40 | #define IDC_COMBO_HOST 1024 41 | #define IDC_EDIT_MAX_LRU 1025 42 | #define IDC_MFCLINK1 1026 43 | 44 | // Next default values for new objects 45 | // 46 | #ifdef APSTUDIO_INVOKED 47 | #ifndef APSTUDIO_READONLY_SYMBOLS 48 | #define _APS_NEXT_RESOURCE_VALUE 135 49 | #define _APS_NEXT_COMMAND_VALUE 32771 50 | #define _APS_NEXT_CONTROL_VALUE 1027 51 | #define _APS_NEXT_SYMED_VALUE 101 52 | #endif 53 | #endif 54 | --------------------------------------------------------------------------------