add winpcap 4.0.2 from url http://www.winpcap.org/
[natblaster.git] / winpcap / Examples / NETMETER / NETMETER.CPP
bloba572e2914d2ed7824828a1260ce66ce80188ce06
1 /*\r
2  * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy)\r
3  * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California)\r
4  * All rights reserved.\r
5  *\r
6  * Redistribution and use in source and binary forms, with or without\r
7  * modification, are permitted provided that the following conditions\r
8  * are met:\r
9  *\r
10  * 1. Redistributions of source code must retain the above copyright\r
11  * notice, this list of conditions and the following disclaimer.\r
12  * 2. Redistributions in binary form must reproduce the above copyright\r
13  * notice, this list of conditions and the following disclaimer in the\r
14  * documentation and/or other materials provided with the distribution.\r
15  * 3. Neither the name of the Politecnico di Torino, CACE Technologies \r
16  * nor the names of its contributors may be used to endorse or promote \r
17  * products derived from this software without specific prior written \r
18  * permission.\r
19  *\r
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
31  *\r
32  */\r
34 #include "stdafx.h"\r
35 #include "netmeter.h"\r
37 #include "MainFrm.h"\r
38 #include "netmeterDoc.h"\r
39 #include "netmeterView.h"\r
41 #ifdef _DEBUG\r
42 #define new DEBUG_NEW\r
43 #undef THIS_FILE\r
44 static char THIS_FILE[] = __FILE__;\r
45 #endif\r
47 /////////////////////////////////////////////////////////////////////////////\r
48 // CNetmeterApp\r
50 BEGIN_MESSAGE_MAP(CNetmeterApp, CWinApp)\r
51         //{{AFX_MSG_MAP(CNetmeterApp)\r
52         ON_COMMAND(ID_APP_ABOUT, OnAppAbout)\r
53         //}}AFX_MSG_MAP\r
54         // Standard file based document commands\r
55 END_MESSAGE_MAP()\r
57 /////////////////////////////////////////////////////////////////////////////\r
58 // CNetmeterApp construction\r
60 CNetmeterApp::CNetmeterApp()\r
61 {\r
62 }\r
64 /////////////////////////////////////////////////////////////////////////////\r
65 // The one and only CNetmeterApp object\r
67 CNetmeterApp theApp;\r
69 /////////////////////////////////////////////////////////////////////////////\r
70 // CNetmeterApp initialization\r
72 BOOL CNetmeterApp::InitInstance()\r
73 {\r
74         // Standard initialization\r
76         // Change the registry key under which our settings are stored.\r
77         SetRegistryKey(_T("Local AppWizard-Generated Applications"));\r
79         LoadStdProfileSettings();  // Load standard INI file options (including MRU)\r
81         // Register document templates\r
83         CSingleDocTemplate* pDocTemplate;\r
84         pDocTemplate = new CSingleDocTemplate(\r
85                 IDR_MAINFRAME,\r
86                 RUNTIME_CLASS(CNetmeterDoc),\r
87                 RUNTIME_CLASS(CMainFrame),       // main SDI frame window\r
88                 RUNTIME_CLASS(CNetmeterView));\r
89         AddDocTemplate(pDocTemplate);\r
91 //      CNetmeterView\r
93         // Parse command line for standard shell commands, DDE, file open\r
94         CCommandLineInfo cmdInfo;\r
95         ParseCommandLine(cmdInfo);\r
97         // Dispatch commands specified on the command line\r
98         if (!ProcessShellCommand(cmdInfo))\r
99                 return FALSE;\r
100         m_pMainWnd->ShowWindow(SW_SHOW);\r
101         m_pMainWnd->UpdateWindow();\r
103         return TRUE;\r
107 /////////////////////////////////////////////////////////////////////////////\r
108 // CAboutDlg dialog used for App About\r
110 class CAboutDlg : public CDialog\r
112 public:\r
113         CAboutDlg();\r
115 // Dialog Data\r
116         //{{AFX_DATA(CAboutDlg)\r
117         enum { IDD = IDD_ABOUTBOX };\r
118         //}}AFX_DATA\r
120         // ClassWizard generated virtual function overrides\r
121         //{{AFX_VIRTUAL(CAboutDlg)\r
122         protected:\r
123         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
124         //}}AFX_VIRTUAL\r
126 // Implementation\r
127 protected:\r
128         //{{AFX_MSG(CAboutDlg)\r
129                 // No message handlers\r
130         //}}AFX_MSG\r
131         DECLARE_MESSAGE_MAP()\r
132 };\r
134 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)\r
136         //{{AFX_DATA_INIT(CAboutDlg)\r
137         //}}AFX_DATA_INIT\r
140 void CAboutDlg::DoDataExchange(CDataExchange* pDX)\r
142         CDialog::DoDataExchange(pDX);\r
143         //{{AFX_DATA_MAP(CAboutDlg)\r
144         //}}AFX_DATA_MAP\r
147 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)\r
148         //{{AFX_MSG_MAP(CAboutDlg)\r
149                 // No message handlers\r
150         //}}AFX_MSG_MAP\r
151 END_MESSAGE_MAP()\r
153 // App command to run the dialog\r
154 void CNetmeterApp::OnAppAbout()\r
156         CAboutDlg aboutDlg;\r
157         aboutDlg.DoModal();\r
160 /////////////////////////////////////////////////////////////////////////////\r
161 // CNetmeterApp message handlers\r