17 static void Sleep(
const uint& MSecs);
18 static TStr GetExeFNm();
19 static void SetLowPriority();
20 static bool ExeProc(
const TStr& ExeFNm,
TStr& ParamStr);
25 ClassTP(TSysMemStat, PSysMemStat)
27 MEMORYSTATUSEX MemStat;
29 TSysMemStat(){Refresh();}
35 TSysMemStat& operator=(
const TSysMemStat&){
Fail;
return *
this;}
38 MemStat.dwLength=
sizeof(MEMORYSTATUSEX);
39 GlobalMemoryStatusEx(&MemStat);}
42 return uint64(MemStat.dwMemoryLoad);}
44 return uint64(MemStat.ullTotalPhys);}
46 return uint64(MemStat.ullAvailPhys);}
48 return uint64(MemStat.ullTotalPageFile);}
50 return uint64(MemStat.ullAvailPageFile);}
52 return uint64(MemStat.ullTotalVirtual);}
54 return uint64(MemStat.ullAvailVirtual);}
61 static bool Is32Bit(){
return sizeof(
char*)==4;}
62 static bool Is64Bit(){
return sizeof(
char*)==8;}
67 ClassTP(TSysConsole, PSysConsole)
73 static PSysConsole New(){
return PSysConsole(
new TSysConsole());}
76 static PSysConsole Load(
TSIn&){
Fail;
return NULL;}
79 TSysConsole& operator=(
const TSysConsole&){
Fail;
return *
this;}
81 void Put(
const TStr& Str);
82 void PutLn(
const TStr& Str){
83 Put(Str); Put(
"\r\n");}
85 static void OpenFile(
const TStr& FNm){
86 ShellExecute(0,
"open", FNm.
CStr(),
"",
"", SW_SHOWNORMAL);}
91 class TSysConsoleNotify:
public TNotify{
93 PSysConsole SysConsole;
95 TSysConsoleNotify(
const PSysConsole& _SysConsole):
96 SysConsole(_SysConsole){}
97 static PNotify New(
const PSysConsole& _SysConsole){
98 return PNotify(
new TSysConsoleNotify(_SysConsole));}
116 static TTm GetCurUniTm();
117 static TTm GetCurLocTm();
118 static uint64 GetCurUniMSecs();
119 static uint64 GetCurLocMSecs();
120 static uint64 GetMSecsFromTm(
const TTm& Tm);
121 static TTm GetTmFromMSecs(
const uint64& MSecs);
122 static uint GetMSecsFromOsStart();
124 static TTm GetLocTmFromUniTm(
const TTm& Tm);
125 static TTm GetUniTmFromLocTm(
const TTm& Tm);
127 static uint64 GetProcessMSecs();
128 static uint64 GetThreadMSecs();
130 static uint64 GetPerfTimerFq();
131 static uint64 GetPerfTimerTicks();
138 static TStr GetCmLn();
139 static TStr GetMsgStr(
const DWORD& MsgCd);
140 static TStr GetLastMsgStr(){
return GetMsgStr(GetLastError());}
141 static char* GetLastMsgCStr();
143 static BSTR NewBStr(
const TStr& Str){
144 return SysAllocStringByteLen(Str.
CStr(), Str.
Len());}
145 static TStr DelBStr(BSTR& BStr){
146 TStr Str=(
char*)BStr; SysFreeString(BStr); BStr=NULL;
return Str;}
155 void UndefCopyAssgin(TRegKey);
157 TRegKey(): Ok(false), hKey(0){}
158 TRegKey(
const bool& _Ok,
const HKEY& _hKey): Ok(_Ok), hKey(_hKey){}
159 ~TRegKey(){
if (Ok){RegCloseKey(hKey);}}
161 HKEY GetHandle()
const {
return hKey;}
163 static PRegKey GetKey(
const PRegKey& Key,
const TStr& SubKeyNm);
164 static TStr GetVal(
const PRegKey& Key,
const TStr& SubKeyNm,
const TStr& ValNm);
165 static PRegKey GetClassesRootKey(){
return new TRegKey(
true, HKEY_CLASSES_ROOT);}
166 static PRegKey GetCurrentUserKey(){
return new TRegKey(
true, HKEY_CURRENT_USER);}
167 static PRegKey GetLocalMachineKey(){
return new TRegKey(
true, HKEY_LOCAL_MACHINE);}
168 static PRegKey GetUsersKey(){
return new TRegKey(
true, HKEY_USERS);}
170 bool IsOk()
const {
return Ok;}
171 void GetKeyNmV(
TStrV& KeyNmV)
const;
172 void GetValV(
TStrKdV& ValNmStrKdV)
const;
179 HANDLE ChildStdinRd, ChildStdinWrDup;
180 HANDLE ChildStdoutWr, ChildStdoutRdDup;
181 void CreateProc(
const TStr& Cmd);
185 TStdIOPipe(
const TStr& CmdToExe);
188 int Write(
const char* Bf) {
return Write(Bf, (
int) strlen(Bf)); }
189 int Write(
const char* Bf,
const int& BfLen);
190 int Read(
char *Bf,
const int& BfMxLen);
193 #elif defined(GLib_UNIX)
198 int GetModuleFileName(
void *hModule,
char *Bf,
int MxBfL);
199 int GetCurrentDirectory(
const int MxBfL,
char *Bf);
200 int CreateDirectory(
const char *FNm,
void *useless);
201 int RemoveDirectory(
const char *FNm);
202 uint64 Epoch2Ft(time_t Epoch);
203 time_t Ft2Epoch(
uint64 Ft);
209 static int Sleep(
const uint& MSecs);
210 static TStr GetExeFNm();
211 static void SetLowPriority();
212 static bool ExeProc(
const TStr& ExeFNm,
TStr& ParamStr);
227 static TTm GetCurUniTm();
228 static TTm GetCurLocTm();
229 static uint64 GetCurUniMSecs();
230 static uint64 GetCurLocMSecs();
231 static uint64 GetMSecsFromTm(
const TTm& Tm);
232 static TTm GetTmFromMSecs(
const uint64& MSecs);
233 static uint GetMSecsFromOsStart();
235 static TTm GetLocTmFromUniTm(
const TTm& Tm);
236 static TTm GetUniTmFromLocTm(
const TTm& Tm);
238 static uint64 GetProcessMSecs();
239 static uint64 GetThreadMSecs();
241 static uint64 GetPerfTimerFq();
242 static uint64 GetPerfTimerTicks();
250 int ChildStdinRd, ChildStdinWrDup;
251 int ChildStdoutWr, ChildStdoutRdDup;
252 void CreateProc(
const TStr& Cmd);
256 TStdIOPipe(
const TStr& CmdToExe);
259 int Write(
const char* Bf) {
return Write(Bf, (
int) strlen(Bf)); }
260 int Write(
const char* Bf,
const int& BfLen);
261 int Read(
char *Bf,
const int& BfMxLen);
#define UndefDefaultCopyAssign(TNm)
#define ClassTP(TNm, PNm)
unsigned long long uint64
virtual void OnNotify(const TNotifyType &, const TStr &)
enum TNotifyType_ TNotifyType
virtual void OnStatus(const TStr &)