MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / Init

Method Init

source/os_version.cpp:91–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89///////////////////////////////////////////////////////////////////////////////
90
91void OS_Version::Init(void)
92{
93 typedef int (WINAPI * GetVersionType)(OSVERSIONINFOW *Info);
94 static GetVersionType _RtlGetVersion = (GetVersionType)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "RtlGetVersion");
95
96 // Get details of the OS we are running on
97 m_OSvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
98 if (_RtlGetVersion)
99 _RtlGetVersion(&m_OSvi);
100 else
101 GetVersionExW(&m_OSvi);
102
103 // Populate Major and Minor version numbers
104 m_dwMajorVersion = m_OSvi.dwMajorVersion;
105 m_dwMinorVersion = m_OSvi.dwMinorVersion;
106 m_dwBuildNumber = m_OSvi.dwBuildNumber;
107
108 // Compose human-readable version number.
109 _sntprintf(m_szVersion, _countof(m_szVersion)-1, _T("%u.%u.%u"), m_dwMajorVersion, m_dwMinorVersion, m_dwBuildNumber);
110 m_szVersion[_countof(m_szVersion)-1] = '\0'; // For the slim chance that it's too long to fit in the buffer (and therefore wasn't null-terminated).
111
112 /* // AutoHotkey: This is disabled because we never use it.
113
114 int i;
115 int nTemp;
116
117 // Get CSD information
118 nTemp = (int)_tcslen(m_OSvi.szCSDVersion);
119
120 if (nTemp > 0)
121 {
122 // strip trailing
123 for (i=nTemp-1; i>0; i--)
124 {
125 if (m_OSvi.szCSDVersion[i] != ' ')
126 break;
127 m_OSvi.szCSDVersion[i] = '\0';
128 }
129
130 // strip leading
131 nTemp = i;
132 for (i=0; i<nTemp; i++)
133 {
134 if (m_OSvi.szCSDVersion[i] != ' ')
135 break;
136 }
137 _tcscpy(m_szCSDVersion, &m_OSvi.szCSDVersion[i]);
138 }
139 else
140 m_szCSDVersion[0] = '\0'; // No CSD info, make it blank to avoid errors
141 */
142
143 // Set all options to false by default
144#ifdef CONFIG_WIN9X
145 m_bWinNT = false;
146 m_bWin9x = false;
147
148 m_bWin95 = false; m_bWin95orLater = false;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected