-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComWorL.cpp
110 lines (99 loc) · 3.43 KB
/
ComWorL.cpp
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <StdIO.h>
#include <IO.h>
#include "ComWorL.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
static String __FileNameLogFile ;
//-------------------------------------------------------------------
void LogException(String File,String Line,Exception &E,String App)
{String ClName(E.ClassName()) ;
// String FName = ExtractFilePath(ParamStr(0)) + _FILENAME_LOGFILE;
String FName = /*ExtractFilePath(ParamStr(0)) + */_FILENAME_LOGFILE;
if(!__FileNameLogFile.IsEmpty()) FName = __FileNameLogFile ;
FILE* fll = fopen(FName.c_str(),"at") ;
if(fll){
if(filelength(fileno(fll)) > 1000000L){
fclose(fll) ;
String FNameNew = ChangeFileExt(FName,Now().FormatString("YYmmnnhhnn")+ ".log") ;
rename(FName.c_str(),FNameNew.c_str()) ;
fll = fopen(FName.c_str(),"at") ;}
}
if(fll){
if(ClName == "Exception") ClName = "**" ;
fprintf(fll,"\n>%s %s %s %s %s %s",
Now().FormatString("YYYY.MM.dd hh:nn:ss").c_str(),
ExtractFileName(File).c_str(),
Line.c_str(),
ClName.c_str(),
E.Message.c_str(),
App.c_str()) ;
fclose(fll) ;}
}
//---------------------------------------------------------------------------
void __fastcall LogFile(char* FName,String Line)
{FILE* fll = fopen(FName,"at") ;
if(fll){
fputs(Line.c_str(),fll) ;
fclose(fll) ;}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
BOOL __fastcall SetWinTransparent(HWND hdr,int color)
{SetWindowLong(hdr,GWL_EXSTYLE,GetWindowLong(hdr,GWL_EXSTYLE) & ~WS_EX_LAYERED) ;
SetWindowLong(hdr,GWL_EXSTYLE,GetWindowLong(hdr,GWL_EXSTYLE) | WS_EX_LAYERED) ;
return ::SetLayeredWindowAttributes(hdr,color,180,LWA_ALPHA) ;}
//---------------------------------------------------------------------------
void GetVersionOfFile (char * pszAppName, // file
char * pszVerBuff, // receives version
int iVerBuffLen, // size of buffer
char * pszLangBuff, // receives language
int iLangBuffLen) // size of buffer
{
DWORD dwScratch;
DWORD * pdwLangChar;
DWORD dwInfSize ;
UINT uSize;
BYTE * pbyInfBuff;
char szVersion [32];
char szResource [80];
char * pszVersion = szVersion;
dwInfSize = GetFileVersionInfoSize (pszAppName, &dwScratch);
if (dwInfSize)
{
pbyInfBuff = new BYTE [dwInfSize];
memset (pbyInfBuff, 0, dwInfSize);
if (pbyInfBuff)
{
if (GetFileVersionInfo (pszAppName, 0, dwInfSize, pbyInfBuff))
{
if (VerQueryValue (pbyInfBuff,
"\\VarFileInfo\\Translation",
(void**)(&pdwLangChar),
&uSize))
{
if (VerLanguageName (LOWORD (*pdwLangChar),
szResource,
sizeof(szResource)))
{
strncpy (pszLangBuff, szResource, iLangBuffLen);
}
wsprintf (szResource, "\\StringFileInfo\\%04X%04X\\FileVersion",
LOWORD (*pdwLangChar), HIWORD (*pdwLangChar));
if (VerQueryValue (pbyInfBuff,
szResource,
(void**)(&pszVersion),
&uSize))
{
strncpy (pszVerBuff, pszVersion, iVerBuffLen-1);
}
}
}
delete [] pbyInfBuff;
}
}
}
//------------------------------------------------------------------------------------