A couple of native API functions to speedup and reduce the size of 64-bit code, rather than using the C++ wstring engine.
QuoteWCHAR drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
WCHAR exepath[MAX_PATH] = {0};
if (GetModuleFileName(0, exepath, sizeof(exepath))) {
_wsplitpath_s(exepath, drive, dir, fname, ext);
}
QuoteWCHAR* TEMPpath() {
static WCHAR buf[MAX_PATH];
DWORD nSize = GetTempPath(GetTempPath(NULL, NULL), &buf[0]);
if (nSize) {
if (!FileExist(buf)) { CreateDirectory(buf, NULL); }
}
return buf;
}
QuoteWCHAR* TIME() {
time_t now = time(0);
tm tstruct;
static WCHAR buf[16] = {0};
if (localtime_s(&tstruct, &now) == 0) {
_wcsftime_l(buf, strSize(buf), L"%X", &tstruct);
buf[5] = 32; buf[6] = 0; buf[7] = 0;
}
return buf;
}
QuoteWCHAR* TODAY() {
time_t now = time(0);
tm tstruct;
static WCHAR buf[32] = {0};
if (localtime_s(&tstruct, &now) == 0) {
_wcsftime_l(buf, strSize(buf), L"%A, %d %B", &tstruct, _wcreate_locale(LC_ALL, L""));
}
return buf;
}
QuoteWCHAR* EXEpath() {
static WCHAR exepath[MAX_PATH] = {0};
if (GetModuleFileName(0, exepath, sizeof(exepath))) {
long nLen = (long)wcslen(exepath);
long nPos = nLen;
for (long K = 1; K <= nLen; K++) {
if (_wcsicmp(&exepath[nPos - K], L"\\") != 0) { exepath[nPos - K] = NULL; }
else { break; }
}
}
return exepath;
}
QuoteWCHAR szResource[MAX_PATH] = { 0 };
PathCombine(szResource, EXEpath(), L"fl04.png");