質問編集履歴
1
解決した時のコードを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -133,3 +133,123 @@
|
|
133
133
|
|
134
134
|
|
135
135
|
よろしくお願いいたします。
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
追伸:
|
146
|
+
|
147
|
+
解決しましたが解決したときのコードがきれいに貼れなかったのでここに貼っておきます。
|
148
|
+
|
149
|
+
```C++
|
150
|
+
|
151
|
+
#ifndef WIN32_LEAN_AND_MEAN
|
152
|
+
|
153
|
+
#define WIN32_LEAN_AND_MEAN
|
154
|
+
|
155
|
+
#endif
|
156
|
+
|
157
|
+
#ifndef _WIN32_WINNT
|
158
|
+
|
159
|
+
#define _WIN32_WINNT 0x0500
|
160
|
+
|
161
|
+
#endif
|
162
|
+
|
163
|
+
#ifndef OEMRESOURCE
|
164
|
+
|
165
|
+
#define OEMRESOURCE
|
166
|
+
|
167
|
+
#endif
|
168
|
+
|
169
|
+
#ifndef STRICT
|
170
|
+
|
171
|
+
#define STRICT
|
172
|
+
|
173
|
+
#endif
|
174
|
+
|
175
|
+
#include <windows.h>
|
176
|
+
|
177
|
+
#include <ctime>
|
178
|
+
|
179
|
+
#include <iostream>
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
time_t make_time_t(const SYSTEMTIME & st)
|
184
|
+
|
185
|
+
{
|
186
|
+
|
187
|
+
tm time_data;
|
188
|
+
|
189
|
+
ZeroMemory(&time_data, sizeof(time_data));
|
190
|
+
|
191
|
+
time_data.tm_year = st.wYear - 1900;
|
192
|
+
|
193
|
+
time_data.tm_mon = st.wMonth - 1;
|
194
|
+
|
195
|
+
time_data.tm_mday = st.wDay;
|
196
|
+
|
197
|
+
time_data.tm_hour = st.wHour;
|
198
|
+
|
199
|
+
time_data.tm_min = st.wMinute;
|
200
|
+
|
201
|
+
time_data.tm_sec = st.wSecond;
|
202
|
+
|
203
|
+
time_data.tm_isdst = 0;
|
204
|
+
|
205
|
+
return mktime(&time_data);
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
unsigned long long time_to_ms(const SYSTEMTIME & systime)
|
212
|
+
|
213
|
+
{
|
214
|
+
|
215
|
+
FILETIME file_time;
|
216
|
+
|
217
|
+
SystemTimeToFileTime(&systime, &file_time);
|
218
|
+
|
219
|
+
FILETIME local_ft;
|
220
|
+
|
221
|
+
FileTimeToLocalFileTime(&file_time, &local_ft);
|
222
|
+
|
223
|
+
SYSTEMTIME local_time;
|
224
|
+
|
225
|
+
FileTimeToSystemTime(&local_ft, &local_time);
|
226
|
+
|
227
|
+
time_t seconds = make_time_t(local_time);
|
228
|
+
|
229
|
+
return seconds * 1000 + systime.wMilliseconds;
|
230
|
+
|
231
|
+
}
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
int main()
|
236
|
+
|
237
|
+
{
|
238
|
+
|
239
|
+
SYSTEMTIME time;
|
240
|
+
|
241
|
+
GetSystemTime(&time);
|
242
|
+
|
243
|
+
std::cout << time.wYear << "year " << time.wMonth << "month " << time.wDay << "day " << time.wHour << "h " << time.wMinute << "min " << time.wSecond << "sec " << time.wMilliseconds << "ms" << std::endl;
|
244
|
+
|
245
|
+
unsigned long long count = time_to_ms(time);
|
246
|
+
|
247
|
+
std::cout << count << std::endl;
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
return 0;
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
```
|