📄 utility.cpp
字号:
//
// utility.cpp -- general purpose routines
//
// Some utility routines. These should not be a part of a class
// because they will be needed before the application starts up
// or they may be called from routines in various classes.
// Prototype them in PROTO.H
//
#include "stdafx.h"
#include "struct.h"
#include "proto.h"
#include <direct.h>
#include <io.h>
bool exist (char *path, int mode)
{
if (!_access (path, mode))
return (true);
return (false);
}
time_t FileTimeToUnixTime (FILETIME *ft)
{
SYSTEMTIME st;
struct tm NewTime, *DstTime;
time_t theTime;
tzset ();
FileTimeToSystemTime(ft, &st);
NewTime.tm_year = st.wYear % 100;
if (NewTime.tm_year < 70)
NewTime.tm_year += 100;
NewTime.tm_mon = st.wMonth - 1;
NewTime.tm_mday = st.wDay;
NewTime.tm_hour = st.wHour;
NewTime.tm_min = st.wMinute;
NewTime.tm_sec = st.wSecond;
theTime = mktime (&NewTime);
theTime -= _timezone;
DstTime = localtime (&theTime);
if (DstTime->tm_isdst)
theTime += 3600;
return (theTime);
}
bool IsWin95 ()
{
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (!GetVersionEx (&vi))
return (false);
return (vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
}
void FormatNumber (CString& strText, ULONG ulSize)
{
TCHAR szBuf[32];
strText.Empty();
memset (szBuf, '\0', sizeof (szBuf));
sprintf (szBuf + 1, "%ld", ulSize);
TCHAR *psz = szBuf + strlen (szBuf + 1);
for (int i = 1; *(psz - 1); ++i, --psz)
{
if (!(i%3))
InsertChar (psz, ',');
}
strText = (szBuf + 1);
}
void InsertChar (TCHAR *sz, TCHAR ch)
{
char *s = sz + strlen (sz);
while (s > sz)
{
*s = *(s-1);
--s;
}
*s = ch;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -