-
-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathutils.cpp
More file actions
28 lines (22 loc) · 642 Bytes
/
utils.cpp
File metadata and controls
28 lines (22 loc) · 642 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "utils.hpp"
#include <atlsecurity.h>
std::string utils::get_hwid() {
ATL::CAccessToken accessToken;
ATL::CSid currentUserSid;
if (accessToken.GetProcessToken(TOKEN_READ | TOKEN_QUERY) &&
accessToken.GetUser(¤tUserSid))
return std::string(CT2A(currentUserSid.Sid()));
return "none";
}
std::time_t utils::string_to_timet(std::string timestamp) {
char* end = nullptr;
auto cv = strtol(timestamp.c_str(), &end, 10);
if (end == timestamp.c_str())
return 0;
return static_cast<time_t>(cv);
}
std::tm utils::timet_to_tm(time_t timestamp) {
std::tm context;
localtime_s(&context, ×tamp);
return context;
}