source: trunk/Utilities/LogicalProcessorInformation/MainDialog.h @ 795

Last change on this file since 795 was 795, checked in by roman, 6 years ago
File size: 32.7 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2006-2017
3// Created by Roman Ryltsov roman@alax.info
4//
5// A permission to use the source code is granted as long as reference to
6// source website http://alax.info is retained.
7
8#pragma once
9
10#define SECURITY_WIN32
11#include <security.h>
12#include "rocrypt.h"
13#include "rowinhttp.h"
14#include "AboutDialog.h"
15//#include "..\DeflateTools\Bzip2Item.h"
16
17#pragma comment(lib, "secur32.lib")
18
19////////////////////////////////////////////////////////////
20// CMainDialog
21
22class CMainDialog : 
23        public CDialogImpl<CMainDialog>,
24        public CDialogResize<CMainDialog>
25{
26public:
27        enum { IDD = IDD_MAIN };
28
29BEGIN_MSG_MAP_EX(CMainDialog)
30        CHAIN_MSG_MAP(CDialogResize<CMainDialog>)
31        MSG_WM_INITDIALOG(OnInitDialog)
32        COMMAND_ID_HANDLER_EX(IDOK, OnCommand)
33        COMMAND_ID_HANDLER_EX(IDCANCEL, OnCommand)
34        //COMMAND_ID_HANDLER_EX(IDC_UPDATE, OnUpdate)
35        COMMAND_ID_HANDLER_EX(IDC_SUBMIT, OnSubmit)
36        COMMAND_ID_HANDLER_EX(IDC_SAVEAS, OnSaveAs)
37END_MSG_MAP()
38
39BEGIN_DLGRESIZE_MAP(CMainDialog)
40        DLGRESIZE_CONTROL(IDC_TEXT, DLSZ_SIZE_X | DLSZ_SIZE_Y)
41        //DLGRESIZE_CONTROL(IDC_UPDATE, DLSZ_MOVE_X | DLSZ_MOVE_Y)
42        DLGRESIZE_CONTROL(IDC_SUBMIT, DLSZ_MOVE_X | DLSZ_MOVE_Y)
43        DLGRESIZE_CONTROL(IDC_SAVEAS, DLSZ_MOVE_X | DLSZ_MOVE_Y)
44        DLGRESIZE_CONTROL(IDOK, DLSZ_MOVE_X | DLSZ_MOVE_Y)
45END_DLGRESIZE_MAP()
46
47public:
48
49private:
50        CDpiAwareness m_DpiAwareness;
51        CFont m_TextFont;
52        CFont m_ButtonFont;
53        CRoArrayT<CString> m_SpecifierArray;
54        CString m_sText;
55        CRoEdit m_TextEdit;
56        CButton m_UpdateButton;
57        CButton m_SubmitButton;
58        CButton m_SaveAsButton;
59        CButton m_CloseButton;
60
61public:
62// CMainDialog
63        VOID Initialize()
64        {
65                m_sText.Empty();
66                CString sText;
67                #pragma region System
68                {
69                        sText += _T("# System") _T("\r\n") _T("\r\n");
70                        #pragma region Version
71                        // NOTE: Operating system version changes in Windows 8.1 and Windows Server 2012 R2 https://msdn.microsoft.com/en-us/library/windows/desktop/dn302074
72                        {
73                                OSVERSIONINFOEX Version = { sizeof Version };
74                                #pragma warning(disable: 4996) // 'GetVersionExW': was declared deprecated
75                                _W(GetVersionEx((OSVERSIONINFO*) &Version));
76                                #pragma warning(default: 4996)
77                                CRoArrayT<CString> Array;
78                                Array.Add(AtlFormatString(_T("%d.%d.%d"), Version.dwMajorVersion, Version.dwMinorVersion, Version.dwBuildNumber));
79                                #pragma region Friendly Version
80                                {
81                                        //NOTE: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833
82                                        static const struct
83                                        {
84                                                LPCSTR pszFriendlyName;
85                                                INT nMajorVersion; // DWORD
86                                                INT nMinorVersion; // DWORD
87                                                INT wProductType; // WORD
88                                        } g_pMap[] = 
89                                        {
90                                                { "Windows 10", 10, 0, VER_NT_WORKSTATION },
91                                                { "Windows Server 2016", 10, 0, ~VER_NT_WORKSTATION },
92                                                { "Windows 8.1", 6, 3, VER_NT_WORKSTATION },
93                                                { "Windows Server 2012 R2", 6, 3, ~VER_NT_WORKSTATION },
94                                                { "Windows 8", 6, 2, VER_NT_WORKSTATION },
95                                                { "Windows Server 2012", 6, 2, ~VER_NT_WORKSTATION },
96                                                { "Windows 7", 6, 1, VER_NT_WORKSTATION },
97                                                { "Windows Server 2008 R2", 6, 1, ~VER_NT_WORKSTATION },
98                                                { "Windows Server 2008", 6, 0, ~VER_NT_WORKSTATION },
99                                                { "Windows Vista", 6, 0, VER_NT_WORKSTATION },
100                                                //{ "Windows Server 2003 R2", 5, 2, GetSystemMetrics(SM_SERVERR2) != 0
101                                                //{ "Windows Home Server", 5, 2, OSVERSIONINFOEX.wSuiteMask & VER_SUITE_WH_SERVER
102                                                //{ "Windows Server 2003", 5, 2, GetSystemMetrics(SM_SERVERR2) == 0
103                                                //{ "Windows XP Professional x64 Edition", 5, 2, (OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION) && (SYSTEM_INFO.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
104                                                { "Windows XP", 5, 1 },
105                                                { "Windows 2000", 5, 0 },
106                                        };
107                                        for(auto&& Item: g_pMap)
108                                        {
109                                                if(Item.nMajorVersion != Version.dwMajorVersion || Item.nMinorVersion != Version.dwMinorVersion)
110                                                        continue;
111                                                if(Item.wProductType == VER_NT_WORKSTATION && Version.wProductType != VER_NT_WORKSTATION)
112                                                        continue;
113                                                if(Item.wProductType == ~VER_NT_WORKSTATION && Version.wProductType == VER_NT_WORKSTATION)
114                                                        continue;
115                                                const CString sFriendlyName(Item.pszFriendlyName);
116                                                Array.Add(sFriendlyName);
117                                                #pragma region Version Specifier
118                                                if(m_SpecifierArray.IsEmpty())
119                                                {
120                                                        m_SpecifierArray.Add(sFriendlyName);
121                                                        if(Version.dwMajorVersion >= 10)
122                                                                m_SpecifierArray.Add(AtlFormatString(_T("%d.%d.%d"), Version.dwMajorVersion, Version.dwMinorVersion, Version.dwBuildNumber));
123                                                        if(Version.wServicePackMinor)
124                                                                m_SpecifierArray.Add(AtlFormatString(_T("SP %d.%d"), Version.wServicePackMajor, Version.wServicePackMinor));
125                                                        else if(Version.wServicePackMajor)
126                                                                m_SpecifierArray.Add(AtlFormatString(_T("SP %d"), Version.wServicePackMajor));
127                                                }
128                                                #pragma endregion
129                                                break;
130                                        }
131                                }
132                                #pragma endregion
133                                if(Version.wServicePackMajor > 0)
134                                        Array.Add(AtlFormatString(_T("Service Pack %d.%d"), Version.wServicePackMajor, Version.wServicePackMinor));
135                                if(Version.wSuiteMask)
136                                {
137                                        #pragma region Map
138                                        static CFlagNameT<WORD> g_pMap[] = 
139                                        {
140                                                #define A(x) { x, #x },
141                                                A(VER_SUITE_SMALLBUSINESS)
142                                                A(VER_SUITE_ENTERPRISE)
143                                                A(VER_SUITE_BACKOFFICE)
144                                                A(VER_SUITE_COMMUNICATIONS)
145                                                A(VER_SUITE_TERMINAL)
146                                                A(VER_SUITE_SMALLBUSINESS_RESTRICTED)
147                                                A(VER_SUITE_EMBEDDEDNT)
148                                                A(VER_SUITE_DATACENTER)
149                                                A(VER_SUITE_SINGLEUSERTS)
150                                                A(VER_SUITE_PERSONAL)
151                                                A(VER_SUITE_BLADE)
152                                                A(VER_SUITE_EMBEDDED_RESTRICTED)
153                                                A(VER_SUITE_SECURITY_APPLIANCE)
154                                                A(VER_SUITE_STORAGE_SERVER)
155                                                A(VER_SUITE_COMPUTE_SERVER)
156                                                A(VER_SUITE_WH_SERVER)
157                                                #undef A
158                                        };
159                                        #pragma endregion
160                                        Array.Add(FormatFlagsT(g_pMap, Version.wSuiteMask));
161                                }
162                                if(Version.wProductType)
163                                {
164                                        #pragma region Map
165                                        static CEnumerationNameT<BYTE> g_pMap[] = 
166                                        {
167                                                #define A(x) { x, #x },
168                                                A(VER_NT_WORKSTATION)
169                                                A(VER_NT_DOMAIN_CONTROLLER)
170                                                A(VER_NT_SERVER)
171                                                #undef A
172                                        };
173                                        #pragma endregion
174                                        Array.Add(FormatEnumerationT(g_pMap, Version.wProductType));
175                                }
176                                CString sTitle;
177                                // ...
178                                CString sItems = _StringHelper::Join(Array, _T(", "));
179                                if(sTitle.IsEmpty())
180                                        sTitle = sItems;
181                                else
182                                        sTitle = AtlFormatString(_T("%s (%s)"), sTitle, sItems);
183                                sText += AtlFormatString(_T(" * ") _T("Version: %s") _T("\r\n"), sTitle);
184                                _ATLTRY
185                                {
186                                        // NOTE: Requires Win Vista, Win Server 2003
187                                        typedef BOOL (WINAPI *GETPRODUCTINFO)(DWORD dwOSMajorVersion, DWORD dwOSMinorVersion, DWORD dwSpMajorVersion, DWORD dwSpMinorVersion, PDWORD pdwReturnedProductType);
188                                        GETPRODUCTINFO pGetProductInfo = (GETPRODUCTINFO) GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "GetProductInfo");
189                                        if(pGetProductInfo)
190                                        {
191                                                DWORD nProductType = 0;
192                                                __E(pGetProductInfo(Version.dwMajorVersion, Version.dwMinorVersion, Version.wServicePackMajor, Version.wServicePackMinor, &nProductType));
193                                                if(nProductType)
194                                                {
195                                                        #pragma region Map
196                                                        static CEnumerationNameT<DWORD> g_pMap[] = 
197                                                        {
198                                                                #define A(x) { x, #x },
199                                                                A(PRODUCT_UNDEFINED)
200                                                                A(PRODUCT_ULTIMATE)
201                                                                A(PRODUCT_HOME_BASIC)
202                                                                A(PRODUCT_HOME_PREMIUM)
203                                                                A(PRODUCT_ENTERPRISE)
204                                                                A(PRODUCT_HOME_BASIC_N)
205                                                                A(PRODUCT_BUSINESS)
206                                                                A(PRODUCT_STANDARD_SERVER)
207                                                                A(PRODUCT_DATACENTER_SERVER)
208                                                                A(PRODUCT_SMALLBUSINESS_SERVER)
209                                                                A(PRODUCT_ENTERPRISE_SERVER)
210                                                                A(PRODUCT_STARTER)
211                                                                A(PRODUCT_DATACENTER_SERVER_CORE)
212                                                                A(PRODUCT_STANDARD_SERVER_CORE)
213                                                                A(PRODUCT_ENTERPRISE_SERVER_CORE)
214                                                                A(PRODUCT_ENTERPRISE_SERVER_IA64)
215                                                                A(PRODUCT_BUSINESS_N)
216                                                                A(PRODUCT_WEB_SERVER)
217                                                                A(PRODUCT_CLUSTER_SERVER)
218                                                                A(PRODUCT_HOME_SERVER)
219                                                                A(PRODUCT_STORAGE_EXPRESS_SERVER)
220                                                                A(PRODUCT_STORAGE_STANDARD_SERVER)
221                                                                A(PRODUCT_STORAGE_WORKGROUP_SERVER)
222                                                                A(PRODUCT_STORAGE_ENTERPRISE_SERVER)
223                                                                A(PRODUCT_SERVER_FOR_SMALLBUSINESS)
224                                                                A(PRODUCT_SMALLBUSINESS_SERVER_PREMIUM)
225                                                                A(PRODUCT_HOME_PREMIUM_N)
226                                                                A(PRODUCT_ENTERPRISE_N)
227                                                                A(PRODUCT_ULTIMATE_N)
228                                                                A(PRODUCT_WEB_SERVER_CORE)
229                                                                A(PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT)
230                                                                A(PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY)
231                                                                A(PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING)
232                                                                A(PRODUCT_SERVER_FOUNDATION)
233                                                                A(PRODUCT_HOME_PREMIUM_SERVER)
234                                                                A(PRODUCT_SERVER_FOR_SMALLBUSINESS_V)
235                                                                A(PRODUCT_STANDARD_SERVER_V)
236                                                                A(PRODUCT_DATACENTER_SERVER_V)
237                                                                A(PRODUCT_ENTERPRISE_SERVER_V)
238                                                                A(PRODUCT_DATACENTER_SERVER_CORE_V)
239                                                                A(PRODUCT_STANDARD_SERVER_CORE_V)
240                                                                A(PRODUCT_ENTERPRISE_SERVER_CORE_V)
241                                                                A(PRODUCT_HYPERV)
242                                                                A(PRODUCT_STORAGE_EXPRESS_SERVER_CORE)
243                                                                A(PRODUCT_STORAGE_STANDARD_SERVER_CORE)
244                                                                A(PRODUCT_STORAGE_WORKGROUP_SERVER_CORE)
245                                                                A(PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE)
246                                                                A(PRODUCT_STARTER_N)
247                                                                A(PRODUCT_PROFESSIONAL)
248                                                                A(PRODUCT_PROFESSIONAL_N)
249                                                                A(PRODUCT_SB_SOLUTION_SERVER)
250                                                                A(PRODUCT_SERVER_FOR_SB_SOLUTIONS)
251                                                                A(PRODUCT_STANDARD_SERVER_SOLUTIONS)
252                                                                A(PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE)
253                                                                A(PRODUCT_SB_SOLUTION_SERVER_EM)
254                                                                A(PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM)
255                                                                A(PRODUCT_SOLUTION_EMBEDDEDSERVER)
256                                                                A(PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE)
257                                                                A(PRODUCT_PROFESSIONAL_EMBEDDED)
258                                                                A(PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT)
259                                                                A(PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL)
260                                                                A(PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC)
261                                                                A(PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC)
262                                                                A(PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE)
263                                                                A(PRODUCT_CLUSTER_SERVER_V)
264                                                                A(PRODUCT_EMBEDDED)
265                                                                A(PRODUCT_STARTER_E)
266                                                                A(PRODUCT_HOME_BASIC_E)
267                                                                A(PRODUCT_HOME_PREMIUM_E)
268                                                                A(PRODUCT_PROFESSIONAL_E)
269                                                                A(PRODUCT_ENTERPRISE_E)
270                                                                A(PRODUCT_ULTIMATE_E)
271                                                                A(PRODUCT_ENTERPRISE_EVALUATION)
272                                                                A(PRODUCT_MULTIPOINT_STANDARD_SERVER)
273                                                                A(PRODUCT_MULTIPOINT_PREMIUM_SERVER)
274                                                                A(PRODUCT_STANDARD_EVALUATION_SERVER)
275                                                                A(PRODUCT_DATACENTER_EVALUATION_SERVER)
276                                                                A(PRODUCT_ENTERPRISE_N_EVALUATION)
277                                                                A(PRODUCT_EMBEDDED_AUTOMOTIVE)
278                                                                A(PRODUCT_EMBEDDED_INDUSTRY_A)
279                                                                A(PRODUCT_THINPC)
280                                                                A(PRODUCT_EMBEDDED_A)
281                                                                A(PRODUCT_EMBEDDED_INDUSTRY)
282                                                                A(PRODUCT_EMBEDDED_E)
283                                                                A(PRODUCT_EMBEDDED_INDUSTRY_E)
284                                                                A(PRODUCT_EMBEDDED_INDUSTRY_A_E)
285                                                                A(PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER)
286                                                                A(PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER)
287                                                                A(PRODUCT_CORE_ARM)
288                                                                A(PRODUCT_CORE_N)
289                                                                A(PRODUCT_CORE_COUNTRYSPECIFIC)
290                                                                A(PRODUCT_CORE_SINGLELANGUAGE)
291                                                                A(PRODUCT_CORE)
292                                                                A(PRODUCT_PROFESSIONAL_WMC)
293                                                                A(PRODUCT_MOBILE_CORE)
294                                                                A(PRODUCT_EMBEDDED_INDUSTRY_EVAL)
295                                                                A(PRODUCT_EMBEDDED_INDUSTRY_E_EVAL)
296                                                                A(PRODUCT_EMBEDDED_EVAL)
297                                                                A(PRODUCT_EMBEDDED_E_EVAL)
298                                                                A(PRODUCT_NANO_SERVER) //A(PRODUCT_CORE_SERVER)
299                                                                A(PRODUCT_CLOUD_STORAGE_SERVER)
300                                                                A(PRODUCT_CORE_CONNECTED)
301                                                                A(PRODUCT_PROFESSIONAL_STUDENT)
302                                                                A(PRODUCT_CORE_CONNECTED_N)
303                                                                A(PRODUCT_PROFESSIONAL_STUDENT_N)
304                                                                A(PRODUCT_CORE_CONNECTED_SINGLELANGUAGE)
305                                                                A(PRODUCT_CORE_CONNECTED_COUNTRYSPECIFIC)
306                                                                A(PRODUCT_UNLICENSED)
307                                                                #undef A
308                                                        };
309                                                        #pragma endregion
310                                                        sText += AtlFormatString(_T(" * ") _T("Product: %s") _T("\r\n"), FormatEnumerationT(g_pMap, nProductType));
311                                                }
312                                        }
313                                }
314                                _ATLCATCHALL()
315                                {
316                                        _Z_EXCEPTION();
317                                }
318                        }
319                        #pragma endregion
320                        TCHAR pszComputerName[MAX_COMPUTERNAME_LENGTH] = { 0 };
321                        #if TRUE
322                                ULONG nComputerNameLength = DIM(pszComputerName);
323                                _W(GetComputerNameEx(ComputerNameDnsFullyQualified, pszComputerName, &nComputerNameLength));
324                        #else
325                                DWORD nComputerNameLength = DIM(pszComputerName);
326                                _W(GetComputerName(pszComputerName, &nComputerNameLength));
327                        #endif
328                        sText += AtlFormatString(_T(" * ") _T("Computer Name: `%s`") _T("\r\n"), pszComputerName);
329                        TCHAR pszUserName[256] = { 0 };
330                        #if TRUE
331                                ULONG nUserNameLength = DIM(pszUserName);
332                                _W(GetUserNameEx(NameSamCompatible, pszUserName, &nUserNameLength));
333                        #else
334                                DWORD nUserNameLength = DIM(pszUserName);
335                                _W(GetUserName(pszUserName, &nUserNameLength));
336                        #endif
337                        BOOL bAdministrator = FALSE;
338                        bool bIsMember = FALSE;
339                        if(CAccessToken().CheckTokenMembership(Sids::Admins(), &bIsMember) && bIsMember)
340                                bAdministrator = TRUE;
341                        sText += AtlFormatString(_T(" * ") _T("User Name: `%s` %s") _T("\r\n"), pszUserName, bAdministrator ? _T("(Administrator)") : _T(""));
342                        WCHAR pszSystemLocaleName[64] = { 0 }, pszUserLocaleName[64] = { 0 };
343                        _W(GetSystemDefaultLocaleName(pszSystemLocaleName, DIM(pszSystemLocaleName)));
344                        _W(GetUserDefaultLocaleName(pszUserLocaleName, DIM(pszUserLocaleName)));
345                        sText += AtlFormatString(_T(" * ") _T("Locale: System `%ls`, User `%ls`") _T("\r\n"), pszSystemLocaleName, pszUserLocaleName);
346                        SYSTEMTIME LocalTime;
347                        GetLocalTime(&LocalTime);
348                        sText += AtlFormatString(_T(" * ") _T("Local Time: `%s`") _T("\r\n"), _StringHelper::FormatDateTime(&LocalTime));
349                        SYSTEM_INFO SystemInformation;
350                        GetSystemInfo(&SystemInformation);
351                        #pragma region Architecture
352                        CString sArchitecture;
353                        switch(SystemInformation.wProcessorArchitecture)
354                        {
355                        case PROCESSOR_ARCHITECTURE_INTEL:
356                                sArchitecture = _T("x86");
357                                break;
358                        case PROCESSOR_ARCHITECTURE_AMD64:
359                                sArchitecture = _T("AMD/Intel x64");
360                                break;
361                        case PROCESSOR_ARCHITECTURE_IA64:
362                                sArchitecture = _T("Intel Itanium");
363                                break;
364                        default:
365                                sArchitecture = AtlFormatString(_T("`0x%04X`"), SystemInformation.wProcessorArchitecture);
366                        }
367                        #if defined(_WIN64)
368                                sText += AtlFormatString(_T(" * ") _T("Architecture: %s (x64 Application)") _T("\r\n"), sArchitecture);
369                        #else
370                                sText += AtlFormatString(_T(" * ") _T("Architecture: %s") _T("\r\n"), sArchitecture);
371                        #endif // defined(_WIN64)
372                        #pragma endregion
373                        sText += AtlFormatString(_T(" * ") _T("Processors: `%d`, Active Mask `0x%X`") _T("\r\n"), SystemInformation.dwNumberOfProcessors, SystemInformation.dwActiveProcessorMask);
374                        sText += AtlFormatString(_T(" * ") _T("Page Size: `0x%X`") _T("\r\n"), SystemInformation.dwPageSize);
375                        sText += AtlFormatString(_T(" * ") _T("Application Address Space: `0x%p`..`0x%p`") _T("\r\n"), SystemInformation.lpMinimumApplicationAddress, SystemInformation.lpMaximumApplicationAddress);
376                        #pragma region Memory
377                        MEMORYSTATUSEX MemoryStatus = { sizeof MemoryStatus };
378                        _W(GlobalMemoryStatusEx(&MemoryStatus));
379                        sText += AtlFormatString(_T(" * ") _T("Physical Memory: `%s` MB") _T("\r\n"), _StringHelper::FormatNumber((LONG) (MemoryStatus.ullTotalPhys >> 20)));
380                        sText += AtlFormatString(_T(" * ") _T("Committed Memory Limit: `%s` MB") _T("\r\n"), _StringHelper::FormatNumber((LONG) (MemoryStatus.ullTotalPageFile >> 20)));
381                        #pragma endregion
382                        sText += AtlFormatString(_T(" * ") _T("Application Version: `%s`") _T("\r\n"), _VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(_VersionInfoHelper::GetModulePath())));
383                        //sText += _T("\r\n");
384                        #pragma region CPU Identification and Features
385                        _ATLTRY
386                        {
387                                CRoArrayT<CString> Array;
388                                // NOTE: __cpuid, __cpuidex https://msdn.microsoft.com/en-us/library/hskdteyh.aspx
389                                //       http://stackoverflow.com/questions/6121792/how-to-check-if-a-cpu-supports-the-sse3-instruction-set
390                                //               https://docs.microsoft.com/en-us/cpp/intrinsics/cpuid-cpuidex
391                                //               https://en.wikipedia.org/wiki/CPUID
392                                INT pnInformation[4] = { -1 };
393                                __cpuid(pnInformation, 0);
394                                const INT nIdentifierCount = pnInformation[0];
395                                CTempBuffer<INT> pnData((nIdentifierCount + 1) * _countof(pnInformation));
396                                for(INT nIdentifierIndex = 0; nIdentifierIndex <= nIdentifierCount; nIdentifierIndex++)
397                                        __cpuidex(pnData + 4 * nIdentifierIndex, nIdentifierIndex, 0);
398                                #pragma region Vendor
399                                CHAR pszVendor[0x20];
400                                ZeroMemory(pszVendor, sizeof pszVendor);
401                                *reinterpret_cast<INT*>(pszVendor + 0) = pnData[1];
402                                *reinterpret_cast<INT*>(pszVendor + 4) = pnData[3];
403                                *reinterpret_cast<INT*>(pszVendor + 8) = pnData[2];
404                                Array.Add(AtlFormatString(_T("`%hs`"), pszVendor));
405                                #pragma endregion
406                                INT n1Ecx = 0, n1Edx = 0;
407                                if(nIdentifierCount >= 1)
408                                {
409                                        n1Ecx = pnData[1 * 4 + 2];
410                                        n1Edx = pnData[1 * 4 + 3];
411                                        if(n1Edx)
412                                        {
413                                                CRoArrayT<CString> SubArray;
414                                                if(n1Edx & (1 << 23))
415                                                        SubArray.Add(_T("MMX"));
416                                                if(n1Edx & (1 << 25))
417                                                        SubArray.Add(_T("SSE"));
418                                                if(n1Edx & (1 << 26))
419                                                        SubArray.Add(_T("SSE2"));
420                                                Array.Add(AtlFormatString(_T("0x1 EDX `0x%08X` (%s)"), n1Edx, _StringHelper::Join(SubArray, _T(", "))));
421                                        }
422                                        if(n1Ecx)
423                                        {
424                                                CRoArrayT<CString> SubArray;
425                                                if(n1Ecx & (1 << 0))
426                                                        SubArray.Add(_T("SSE3"));
427                                                if(n1Ecx & (1 << 9))
428                                                        SubArray.Add(_T("SSSE3"));
429                                                if(n1Ecx & (1 << 19))
430                                                        SubArray.Add(_T("SSE41"));
431                                                if(n1Ecx & (1 << 20))
432                                                        SubArray.Add(_T("SSE42"));
433                                                if(n1Ecx & (1 << 28))
434                                                        SubArray.Add(_T("AVX"));
435                                                Array.Add(AtlFormatString(_T("0x1 ECX `0x%08X` (%s)"), n1Ecx, _StringHelper::Join(SubArray, _T(", "))));
436                                        }
437                                }
438                                INT n7Ebx = 0, n7Ecx = 0;
439                                if(nIdentifierCount >= 7)
440                                {
441                                        n7Ebx = pnData[7 * 4 + 1];
442                                        n7Ecx = pnData[7 * 4 + 2];
443                                        if(n7Ebx)
444                                        {
445                                                CRoArrayT<CString> SubArray;
446                                                if(n7Ebx & (1 << 5))
447                                                        SubArray.Add(_T("AVX2"));
448                                                Array.Add(AtlFormatString(_T("0x7 EBX `0x%08X` (%s)"), n7Ebx, _StringHelper::Join(SubArray, _T(", "))));
449                                        }
450                                        if(n7Ecx)
451                                        {
452                                                //CRoArrayT<CString> SubArray;
453                                                //if(n7Ecx & (1 << 5))
454                                                //      SubArray.Add(_T("AVX2"));
455                                                Array.Add(AtlFormatString(_T("0x7 ECX `0x%08X`"), n7Ebx));
456                                        }
457                                }
458                                __cpuid(pnInformation, 0x80000000);
459                                const UINT nExtendedIdentifierCount = (UINT) pnInformation[0];
460                                CTempBuffer<INT> pnExtendedData((nExtendedIdentifierCount - 0x80000000 + 1) * _countof(pnInformation));
461                                for(UINT nExtendedIdentifierIndex = 0x80000000; nExtendedIdentifierIndex <= nExtendedIdentifierCount; nExtendedIdentifierIndex++)
462                                        __cpuidex(pnExtendedData + 4 * (nExtendedIdentifierIndex - 0x80000000), nExtendedIdentifierIndex, 0);
463                                INT nEx1Ecx = 0, nEx1Edx = 0;
464                                if(nExtendedIdentifierCount >= 0x80000001)
465                                {
466                                        nEx1Ecx = pnExtendedData[1 * 4 + 2];
467                                        nEx1Edx = pnExtendedData[1 * 4 + 3];
468                                }
469                                #pragma region Vendor
470                                CHAR pszBrand[0x40];
471                                ZeroMemory(pszBrand, sizeof pszBrand);
472                                if(nExtendedIdentifierCount >= 0x80000004)
473                                {
474                                        memcpy(pszBrand, pnExtendedData + 2 * 4, 3 * 4 * sizeof (INT));
475                                        sText += AtlFormatString(_T(" * ") _T("CPU Brand: %hs") _T("\r\n"), pszBrand);
476                                }
477                                #pragma endregion
478                                sText += AtlFormatString(_T(" * ") _T("CPUID: %s") _T("\r\n"), _StringHelper::Join(Array, _T(", ")));
479                        }
480                        _ATLCATCHALL()
481                        {
482                                //_Z_EXCEPTION();
483                        }
484                        #pragma endregion
485                        #pragma region IsProcessorFeaturePresent
486                        // NOTE: IsProcessorFeaturePresent function https://msdn.microsoft.com/en-us/library/windows/desktop/ms724482
487                        {
488                                static const CEnumerationNameT<DWORD> g_pMap[] = 
489                                {
490                                        #define A(x) { x, #x },
491                                        A(PF_FLOATING_POINT_PRECISION_ERRATA)
492                                        A(PF_FLOATING_POINT_EMULATED)
493                                        A(PF_COMPARE_EXCHANGE_DOUBLE)
494                                        A(PF_MMX_INSTRUCTIONS_AVAILABLE)
495                                        A(PF_PPC_MOVEMEM_64BIT_OK)
496                                        A(PF_ALPHA_BYTE_INSTRUCTIONS)
497                                        A(PF_XMMI_INSTRUCTIONS_AVAILABLE)
498                                        A(PF_3DNOW_INSTRUCTIONS_AVAILABLE)
499                                        A(PF_RDTSC_INSTRUCTION_AVAILABLE)
500                                        A(PF_PAE_ENABLED)
501                                        A(PF_XMMI64_INSTRUCTIONS_AVAILABLE)
502                                        A(PF_SSE_DAZ_MODE_AVAILABLE)
503                                        A(PF_NX_ENABLED)
504                                        A(PF_SSE3_INSTRUCTIONS_AVAILABLE)
505                                        A(PF_COMPARE_EXCHANGE128)
506                                        A(PF_COMPARE64_EXCHANGE128)
507                                        A(PF_CHANNELS_ENABLED)
508                                        A(PF_XSAVE_ENABLED)
509                                        A(PF_ARM_VFP_32_REGISTERS_AVAILABLE)
510                                        A(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE)
511                                        A(PF_SECOND_LEVEL_ADDRESS_TRANSLATION)
512                                        A(PF_VIRT_FIRMWARE_ENABLED)
513                                        A(PF_RDWRFSGSBASE_AVAILABLE)
514                                        A(PF_FASTFAIL_AVAILABLE)
515                                        A(PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE)
516                                        A(PF_ARM_64BIT_LOADSTORE_ATOMIC)
517                                        A(PF_ARM_EXTERNAL_CACHE_AVAILABLE)
518                                        A(PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE)
519                                        A(PF_RDRAND_INSTRUCTION_AVAILABLE)
520                                        A(PF_ARM_V8_INSTRUCTIONS_AVAILABLE)
521                                        A(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE)
522                                        A(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE)
523                                        A(PF_RDTSCP_INSTRUCTION_AVAILABLE)
524                                        #undef A
525                                };
526                                sText += AtlFormatString(_T(" * ") _T("IsProcessorFeaturePresent:") _T("\r\n"));
527                                for(auto&& Item: g_pMap)
528                                        if(IsProcessorFeaturePresent(Item.Value))
529                                                sText += AtlFormatString(_T("  * %hs") _T("\r\n"), Item.pszName);
530                        }
531                        #pragma endregion
532                        m_sText += sText;
533                }
534                m_sText += _T("\r\n");
535                #pragma endregion
536                DWORD nSize = 0;
537                GetLogicalProcessorInformation(NULL, &nSize);
538                CTempBuffer<SYSTEM_LOGICAL_PROCESSOR_INFORMATION> pLogicalProcessorInformation;
539                ATLVERIFY(pLogicalProcessorInformation.AllocateBytes(nSize));
540                ATLENSURE_THROW(GetLogicalProcessorInformation(pLogicalProcessorInformation, &nSize), AtlHresultFromLastError());
541                static const CEnumerationNameT<LOGICAL_PROCESSOR_RELATIONSHIP> g_pLogicalProcessorRelationshipMap[] = 
542                {
543                        #define A(x) { x, #x },
544                        A(RelationProcessorCore)
545                        A(RelationNumaNode)
546                        A(RelationCache)
547                        A(RelationProcessorPackage)
548                        A(RelationGroup)
549                        //A(RelationAll)
550                        #undef A
551                };
552                m_sText.Append(_T("## Logical Processors") _T("\r\n"));
553                m_sText.Append(_T("\r\n"));
554                _Z4(atlTraceGeneral, 4, _T("nSize %d, sizeof (SYSTEM_LOGICAL_PROCESSOR_INFORMATION) %d\n"), nSize, sizeof (SYSTEM_LOGICAL_PROCESSOR_INFORMATION));
555                CAtlMap<LOGICAL_PROCESSOR_RELATIONSHIP, UINT> RelationshipMap;
556                RelationshipMap[RelationProcessorCore] = 0;
557                RelationshipMap[RelationNumaNode] = 0;
558                RelationshipMap[RelationCache] = 0;
559                RelationshipMap[RelationProcessorPackage] = 0;
560                RelationshipMap[RelationGroup] = 0;
561                for(const SYSTEM_LOGICAL_PROCESSOR_INFORMATION* pCurrentLogicalProcessorInformation = pLogicalProcessorInformation; (const BYTE*) (pCurrentLogicalProcessorInformation + 1) <= (const BYTE*) ((const SYSTEM_LOGICAL_PROCESSOR_INFORMATION*) pLogicalProcessorInformation) + nSize; pCurrentLogicalProcessorInformation++)
562                {
563                        _Z4(atlTraceGeneral, 4, _T("pCurrentLogicalProcessorInformation 0x%p\n"), pCurrentLogicalProcessorInformation);
564                        m_sText.AppendFormat(_T("Record %s (0x%02X)") _T("\r\n"), FormatEnumerationT(g_pLogicalProcessorRelationshipMap, pCurrentLogicalProcessorInformation->Relationship), pCurrentLogicalProcessorInformation->ProcessorMask);
565                        m_sText += _T("\r\n");
566                        #pragma region RelationProcessorCore
567                        if(pCurrentLogicalProcessorInformation->Relationship == RelationProcessorCore)
568                        {
569                                static const CFlagNameT<BYTE> g_pFlagMap[] = 
570                                {
571                                        #define A(x) { x, #x },
572                                        A(LTP_PC_SMT)
573                                        #undef A
574                                };
575                                m_sText.AppendFormat(_T("  * ProcessorCore.Flags: %s") _T("\r\n"), FormatFlagsT(g_pFlagMap, pCurrentLogicalProcessorInformation->ProcessorCore.Flags));
576                                m_sText += _T("\r\n");
577                                RelationshipMap[RelationProcessorCore]++;
578                        }
579                        #pragma endregion
580                        #pragma region RelationNumaNode
581                        if(pCurrentLogicalProcessorInformation->Relationship == RelationNumaNode)
582                        {
583                                m_sText.AppendFormat(_T("  * NumaNode.NodeNumber: 0x%X\r\n"), pCurrentLogicalProcessorInformation->NumaNode.NodeNumber);
584                                m_sText += _T("\r\n");
585                                RelationshipMap[RelationNumaNode]++;
586                        }
587                        #pragma endregion
588                        #pragma region RelationCache
589                        if(pCurrentLogicalProcessorInformation->Relationship == RelationCache)
590                        {
591                                static const CEnumerationNameT<BYTE> g_pAssociativityMap[] = 
592                                {
593                                        #define A(x) { x, #x },
594                                        A(CACHE_FULLY_ASSOCIATIVE)
595                                        #undef A
596                                };
597                                static const CEnumerationNameT<PROCESSOR_CACHE_TYPE> g_pTypeMap[] = 
598                                {
599                                        #define A(x) { x, #x },
600                                        A(CacheUnified)
601                                        A(CacheInstruction)
602                                        A(CacheData)
603                                        A(CacheTrace)
604                                        #undef A
605                                };
606                                m_sText.AppendFormat(_T("  * Cache.Level: %d") _T("\r\n"), pCurrentLogicalProcessorInformation->Cache.Level);
607                                m_sText.AppendFormat(_T("  * Cache.Associativity: %s") _T("\r\n"), FormatEnumerationT(g_pAssociativityMap, pCurrentLogicalProcessorInformation->Cache.Associativity));
608                                m_sText.AppendFormat(_T("  * Cache.LineSize: %d (0x%X)") _T("\r\n"), pCurrentLogicalProcessorInformation->Cache.LineSize, pCurrentLogicalProcessorInformation->Cache.LineSize);
609                                m_sText.AppendFormat(_T("  * Cache.Size: %d (0x%X)") _T("\r\n"), pCurrentLogicalProcessorInformation->Cache.Size, pCurrentLogicalProcessorInformation->Cache.Size);
610                                m_sText.AppendFormat(_T("  * Cache.Type: %s") _T("\r\n"), FormatEnumerationT(g_pTypeMap, pCurrentLogicalProcessorInformation->Cache.Type));
611                                m_sText += _T("\r\n");
612                                RelationshipMap[RelationCache]++;
613                        }
614                        #pragma endregion
615                        #pragma region RelationProcessorPackage
616                        if(pCurrentLogicalProcessorInformation->Relationship == RelationProcessorPackage)
617                                RelationshipMap[RelationProcessorPackage]++;
618                        #pragma endregion
619                        #pragma region RelationGroup
620                        if(pCurrentLogicalProcessorInformation->Relationship == RelationGroup)
621                                RelationshipMap[RelationGroup]++;
622                        #pragma endregion
623                }
624                #pragma region Summary
625                m_sText.Append(_T("### Record Count per Relationship") _T("\r\n") _T("\r\n"));
626                m_sText.AppendFormat(_T(" *  %s: %d") _T("\r\n"), FormatEnumerationT(g_pLogicalProcessorRelationshipMap, RelationProcessorCore), RelationshipMap[RelationProcessorCore]);
627                m_sText.AppendFormat(_T(" *  %s: %d") _T("\r\n"), FormatEnumerationT(g_pLogicalProcessorRelationshipMap, RelationNumaNode), RelationshipMap[RelationNumaNode]);
628                m_sText.AppendFormat(_T(" *  %s: %d") _T("\r\n"), FormatEnumerationT(g_pLogicalProcessorRelationshipMap, RelationCache), RelationshipMap[RelationCache]);
629                m_sText.AppendFormat(_T(" *  %s: %d") _T("\r\n"), FormatEnumerationT(g_pLogicalProcessorRelationshipMap, RelationProcessorPackage), RelationshipMap[RelationProcessorPackage]);
630                m_sText.AppendFormat(_T(" *  %s: %d") _T("\r\n"), FormatEnumerationT(g_pLogicalProcessorRelationshipMap, RelationGroup), RelationshipMap[RelationGroup]);
631                m_sText += _T("\r\n");
632                #pragma endregion
633        }
634        VOID UpdateControls()
635        {
636        }
637
638// Window Message Handler
639        LRESULT OnInitDialog(HWND, LPARAM)
640        {
641                Initialize();
642                DlgResize_Init(FALSE);
643                SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)), TRUE);
644                SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)), FALSE);
645                CMenuHandle Menu = GetSystemMenu(FALSE);
646                _W(Menu.AppendMenu(MF_SEPARATOR));
647                _W(Menu.AppendMenu(MF_STRING, ID_APP_ABOUT, _T("&About...")));
648                CAboutDialog::UpdateCaption(*this);
649                m_TextEdit = GetDlgItem(IDC_TEXT);
650                m_TextFont = m_DpiAwareness.ScaleFont(m_TextEdit.GetFont(), 11);
651                m_TextEdit.SetFont(m_TextFont);
652                m_TextEdit.SetWindowText(m_sText);
653                m_UpdateButton = GetDlgItem(IDC_UPDATE);
654                m_SubmitButton = GetDlgItem(IDC_SUBMIT);
655                m_SaveAsButton = GetDlgItem(IDC_SAVEAS);
656                m_CloseButton = GetDlgItem(IDOK);
657                m_ButtonFont = m_DpiAwareness.ScaleFont(GetFont(), 9);
658                m_UpdateButton.SetFont(m_ButtonFont);
659                m_SubmitButton.SetFont(m_ButtonFont);
660                m_SaveAsButton.SetFont(m_ButtonFont);
661                m_CloseButton.SetFont(m_ButtonFont);
662                #pragma region Position
663                {
664                        CRect Position;
665                        _W(GetWindowRect(Position));
666                        const HMONITOR hMonitor = MonitorFromPoint(Position.CenterPoint(), MONITOR_DEFAULTTONEAREST);
667                        MONITORINFO Information = { sizeof Information };
668                        if(GetMonitorInfo(hMonitor, &Information))
669                        {
670                                CSize DefaultExtent = reinterpret_cast<const CRect&>(Information.rcWork).Size();
671                                DefaultExtent.cx = DefaultExtent.cx * 6 / 8;
672                                DefaultExtent.cy = DefaultExtent.cy * 6 / 8;
673                                BOOL bUpdate = FALSE;
674                                CSize ExcessExtent(DefaultExtent.cx - Position.Width(), DefaultExtent.cy - Position.Height());
675                                if(ExcessExtent.cx > 0)
676                                {
677                                        Position.left -= ExcessExtent.cx / 2;
678                                        Position.right = Position.left + DefaultExtent.cx;
679                                        bUpdate = TRUE;
680                                }
681                                if(ExcessExtent.cy > 0)
682                                {
683                                        Position.top -= ExcessExtent.cy / 2;
684                                        Position.bottom = Position.top + DefaultExtent.cy;
685                                        bUpdate = TRUE;
686                                }
687                                if(bUpdate)
688                                        _W(MoveWindow(Position, FALSE));
689                        }
690                }
691                _W(CenterWindow());
692                #pragma endregion
693                UpdateControls();
694                return TRUE;
695        }
696        LRESULT OnCommand(UINT, INT nIdentifier, HWND)
697        {
698                _W(EndDialog(nIdentifier));
699                return 0;
700        }
701        LRESULT OnSubmit(UINT, INT nIdentifier, HWND)
702        {
703                CWaitCursor WaitCursor;
704                const CString sFileDescription = _VersionInfoHelper::GetString(_VersionInfoHelper::GetModulePath(), _T("FileDescription"));
705                CWinHttpPostData PostData;
706                PostData.AddValue(_T("subj"), sFileDescription);
707                CStringA sTextA = Utf8StringFromString(m_TextEdit.GetValue());
708                static const UINT g_nFlags = _Base64Helper::FLAG_NOPAD | _Base64Helper::FLAG_NOCRLF;
709                #if TRUE
710                        CStringA sBodyTextA = sTextA;
711                        static const SIZE_T g_nMaximalBodyLength = 24 << 10; // 24 KB
712                        if(sBodyTextA.GetLength() > (INT) g_nMaximalBodyLength)
713                        {
714                                sBodyTextA = sBodyTextA.Left((INT) g_nMaximalBodyLength);
715                                sBodyTextA += "\r\n";
716                                sBodyTextA += AtlFormatStringT<CStringA>("<%d more characters truncated>", sTextA.GetLength() - sBodyTextA.GetLength()) + "\r\n";
717                                PostData.AddValue(_T("body"), CString(_Base64Helper::Encode<CStringA>((const BYTE*) (LPCSTR) sBodyTextA, sBodyTextA.GetLength(), g_nFlags)));
718                                #pragma region Bzip2 Body
719                                //_ATLTRY
720                                //{
721                                //      CLocalObjectPtr<CBzip2Item> pItem;
722                                //      pItem->SetRawData((const BYTE*) (LPCSTR) sTextA, sTextA.GetLength());
723                                //      CComBSTR sDataText;
724                                //      __C(pItem->get_DataText(&sDataText));
725                                //      #if defined(_DEBUG) && FALSE
726                                //              COMPILER_MESSAGE("Debug: Write Base64 Bzip2 Output to File")
727                                //              CPath sPath;
728                                //              sPath.Combine(GetPathDirectory(GetModulePath()), _T("Output.bz2.b64"));
729                                //              CAtlFile File;
730                                //              _V(File.Create(sPath, GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS));
731                                //              _V(File.Write(CStringA(sDataText), sDataText.Length()));
732                                //      #endif // defined(_DEBUG)
733                                //      PostData.AddValue(_T("attachment_0_body"), sDataText);
734                                //      PostData.AddValue(_T("attachment_0_filename"), _T("body.md.bz2"));
735                                //      PostData.AddValue(_T("attachment_count"), _T("1"));
736                                //}
737                                //_ATLCATCHALL()
738                                //{
739                                //      _Z_EXCEPTION();
740                                //}
741                                #pragma endregion
742                        } else
743                                PostData.AddValue(_T("body"), CString(_Base64Helper::Encode<CStringA>((const BYTE*) (LPCSTR) sTextA, sTextA.GetLength(), g_nFlags)));
744                #else
745                        PostData.AddValue(_T("body"), CString(_Base64Helper::Encode<CStringA>((const BYTE*) (LPCSTR) sTextA, sTextA.GetLength(), g_nFlags)));
746                #endif
747                #if defined(_DEBUG)
748                        PostData.AddValue(_T("debug"), _T("1"));
749                #endif // defined(_DEBUG)
750                CWinHttpSessionHandle Session = OpenWinHttpSessionHandle(sFileDescription);
751                __E(Session);
752                CWinHttpConnectionHandle Connection = Session.Connect(CStringW(_T("alax.info")));
753                __E(Connection);
754                CWinHttpRequestHandle Request = Connection.OpenRequest(CStringW(_T("POST")), CStringW(_T("/post.php")));
755                __E(Request);
756                CStringW sPostHeaders = PostData.GetHeaders();
757                CStringA sPostData(PostData.GetValue());
758                __E(Request.Send(sPostHeaders, -1, const_cast<LPSTR>((LPCSTR) sPostData), sPostData.GetLength(), sPostData.GetLength()));
759                __E(Request.ReceiveResponse());
760                DWORD nStatusCode = 0;
761                __E(Request.QueryNumberHeader(WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, nStatusCode));
762                __D(nStatusCode / 100 == HTTP_STATUS_OK / 100, E_UNNAMED);
763                MessageBeep(MB_OK);
764                UpdateControls();
765                return 0;
766        }
767        LRESULT OnSaveAs(UINT, INT nIdentifier, HWND)
768        {
769                CWaitCursor WaitCursor;
770                const CStringA sTextA = Utf8StringFromString(m_TextEdit.GetValue());
771                static const COMDLG_FILTERSPEC g_pFilter[] = 
772                {
773                        { _T("Markdown Files"), _T("*.md") },
774                        //{ _T("Markdown Files, Bzip2 Compressed"), _T("*.md.bz2") },
775                        { _T("All Files"), _T("*.*") },
776                };
777                const CPath sPath = _CommonDialogHelper::QuerySavePath(m_hWnd, g_pFilter, _T("md"), _T("Output.md"));
778                if(!_tcslen(sPath))
779                        return 0;
780                LPCTSTR pszExtension = FindExtension(sPath);
781                CAtlFile File;
782                __C(File.Create(sPath, GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS));
783                _ATLTRY
784                {
785                        //if(_tcsicmp(pszExtension, _T(".bz2")) == 0)
786                        //{
787                        //      CLocalObjectPtr<CBzip2Item> pItem;
788                        //      pItem->SetRawData((const BYTE*) (LPCSTR) sTextA, sTextA.GetLength());
789                        //      CHeapPtr<BYTE> pnData;
790                        //      SIZE_T nDataSize;
791                        //      pItem->GetData(pnData, nDataSize);
792                        //      __C(File.Write(pnData, (DWORD) nDataSize));
793                        //} else
794                        {
795                                __C(File.Write(sTextA, sTextA.GetLength() * sizeof (CHAR)));
796                        }
797                }
798                _ATLCATCHALL()
799                {
800                        File.Close();
801                        DeleteFile(sPath);
802                        _ATLRETHROW;
803                }
804                return 0;
805        }
806};
Note: See TracBrowser for help on using the repository browser.