OpenTTD Source  20240919-master-gdf0233f4c2
survey_win.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "../../stdafx.h"
11 
12 #include "../../3rdparty/fmt/format.h"
13 #include "../../survey.h"
14 
15 #include <thread>
16 #include <windows.h>
17 
18 #include "../../safeguards.h"
19 
20 void SurveyOS(nlohmann::json &json)
21 {
22  _OSVERSIONINFOA os;
23  os.dwOSVersionInfoSize = sizeof(os);
24  GetVersionExA(&os);
25 
26  json["os"] = "Windows";
27  json["release"] = fmt::format("{}.{}.{} ({})", os.dwMajorVersion, os.dwMinorVersion, os.dwBuildNumber, os.szCSDVersion);
28 
29  MEMORYSTATUSEX status;
30  status.dwLength = sizeof(status);
31  GlobalMemoryStatusEx(&status);
32 
33  json["memory"] = SurveyMemoryToText(status.ullTotalPhys);
34  json["hardware_concurrency"] = std::thread::hardware_concurrency();
35 }
SurveyMemoryToText
std::string SurveyMemoryToText(uint64_t memory)
Change the bytes of memory into a textual version rounded up to the biggest unit.
Definition: survey.cpp:487