SYSTEMTIME to wchar_t

I googled: WORD to wchar_t
but found nothing
any ideas?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
wchar_t user[UNLEN + 1];
DWORD size = UNLEN + 1;
GetUserNameW(user, &size);
SYSTEMTIME time; 
wchar_t termname[260];
wchar_t day = time.wDay;
wchar_t hour = time.wHour;
wchar_t minute = time.wMinute;
wcscpy_s(termname, user); //no problem with this one
wcscat_s(termname, L".");
wcscat_s(termname, day);
wcscat_s(termname, L".");
wcscat_s(termname, hour);
wcscat_s(termname, L".");
wcscat_s(termname, minute);
Last edited on
Convert the systemtime to a string.
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <Windows.h>

struct X {};

int main() {
	SYSTEMTIME t;
	GetSystemTime(&t);

	wchar_t time[20];
	GetTimeFormatEx(nullptr, 0, &t, L"hh':'mm':'ss tt\n", time, 20);
	wprintf_s(time);
}

https://msdn.microsoft.com/en-us/library/windows/desktop/dd318131(v=vs.85).aspx
Last edited on
Topic archived. No new replies allowed.