Revisión | 195 (tree) |
---|---|
Tiempo | 2018-07-23 03:15:21 |
Autor | sebastiandotnet |
- add com shim core logging
@@ -63,7 +63,7 @@ | ||
63 | 63 | if (_parseValue && 0 == wcscmp(_value, L"$LocalTime")) |
64 | 64 | { |
65 | 65 | if(NULL == localtime_s(&buf, &t)) |
66 | - wcsftime(buffer, maxLen, L"%d-%m-%Y %I:%M:%S", &buf); | |
66 | + wcsftime(buffer, maxLen, L"%d-%m-%Y %I:%M:%S %p", &buf); | |
67 | 67 | else |
68 | 68 | StringCchCopy(buffer, maxLen, _value); |
69 | 69 | } |
@@ -77,7 +77,7 @@ | ||
77 | 77 | else if (_parseValue && 0 == wcscmp(_value, L"$LocalTimeDEFormat")) |
78 | 78 | { |
79 | 79 | if (NULL == localtime_s(&buf, &t)) |
80 | - wcsftime(buffer, maxLen, L"%d.%m.%Y %I:%M:%S", &buf); | |
80 | + wcsftime(buffer, maxLen, L"%d.%m.%Y %H:%M:%S", &buf); | |
81 | 81 | else |
82 | 82 | StringCchCopy(buffer, maxLen, _value); |
83 | 83 | } |
@@ -24,7 +24,7 @@ | ||
24 | 24 | |
25 | 25 | HRESULT DllRegister(HINSTANCE module, LPCWSTR officeApplications[], DWORD addinLoadBehavior, DWORD addinCommandLineSafe, WCHAR* progId, WCHAR* classId, WCHAR* friendlyName, WCHAR* description, WCHAR* version, RegisterMode mode, BOOL addinRegistration) |
26 | 26 | { |
27 | - NetOffice_ShimLoader_Analytics::WriteLog(L"Register32On64::DllRegister::Enter"); | |
27 | + NetOffice_ShimLoader_Analytics::WriteRegisterLog(L"Register32On64::DllRegister::Enter"); | |
28 | 28 | |
29 | 29 | HRESULT hr = S_OK; |
30 | 30 |
@@ -34,7 +34,7 @@ | ||
34 | 34 | !version || !version[0]) |
35 | 35 | { |
36 | 36 | hr = E_INVALIDARG; |
37 | - NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllRegister::FailExit", hr); | |
37 | + NetOffice_ShimLoader_Analytics::WriteRegisterError(L"Register32On64::DllRegister::FailExit", hr); | |
38 | 38 | return hr; |
39 | 39 | } |
40 | 40 |
@@ -47,7 +47,7 @@ | ||
47 | 47 | hr = RegisterCOMAddin(officeApplications[i], progId, friendlyName, description, addinLoadBehavior, addinCommandLineSafe, System == mode); |
48 | 48 | if (!SUCCEEDED(hr)) |
49 | 49 | { |
50 | - NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllRegister::Error#RegisterCOMAddin"); | |
50 | + NetOffice_ShimLoader_Analytics::WriteRegisterError(L"Register32On64::DllRegister::Error#RegisterCOMAddin", hr); | |
51 | 51 | break; |
52 | 52 | } |
53 | 53 | } |
@@ -54,13 +54,13 @@ | ||
54 | 54 | } |
55 | 55 | else |
56 | 56 | { |
57 | - NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllRegister::Error#RegisterCOMComponent"); | |
57 | + NetOffice_ShimLoader_Analytics::WriteRegisterError(L"Register32On64::DllRegister::Error#RegisterCOMComponent", hr); | |
58 | 58 | } |
59 | 59 | |
60 | 60 | if (SUCCEEDED(hr)) |
61 | - NetOffice_ShimLoader_Analytics::WriteLog(L"Register32On64::DllRegister::Exit"); | |
61 | + NetOffice_ShimLoader_Analytics::WriteRegisterLog(L"Register32On64::DllRegister::Exit"); | |
62 | 62 | else |
63 | - NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllRegister::FailExit"); | |
63 | + NetOffice_ShimLoader_Analytics::WriteRegisterError(L"Register32On64::DllRegister::FailExit", hr); | |
64 | 64 | |
65 | 65 | return hr; |
66 | 66 | } |
@@ -67,7 +67,7 @@ | ||
67 | 67 | |
68 | 68 | HRESULT DllUnregister(LPCWSTR officeApplications[], WCHAR* progId, WCHAR* classId, WCHAR* version, RegisterMode mode, BOOL addinRegistration) |
69 | 69 | { |
70 | - NetOffice_ShimLoader_Analytics::WriteLog(L"Register32On64::DllUnregister::Enter"); | |
70 | + NetOffice_ShimLoader_Analytics::WriteUnRegisterLog(L"Register32On64::DllUnregister::Enter"); | |
71 | 71 | |
72 | 72 | HRESULT hr = S_OK; |
73 | 73 | HRESULT addin = S_OK; |
@@ -75,7 +75,7 @@ | ||
75 | 75 | if (NULL == officeApplications || !progId || !progId[0] || !classId || !classId[0] || !version || !version[0]) |
76 | 76 | { |
77 | 77 | hr = E_INVALIDARG; |
78 | - NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllUnregister::FailExit", hr); | |
78 | + NetOffice_ShimLoader_Analytics::WriteUnRegisterError(L"Register32On64::DllUnregister::FailExit", hr); | |
79 | 79 | return hr; |
80 | 80 | } |
81 | 81 |
@@ -86,7 +86,7 @@ | ||
86 | 86 | { |
87 | 87 | if (!SUCCEEDED(UnRegisterCOMAddin(officeApplications[i], progId, 0 == mode))) |
88 | 88 | { |
89 | - NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllUnregister::Error#UnRegisterCOMAddin"); | |
89 | + NetOffice_ShimLoader_Analytics::WriteUnRegisterError(L"Register32On64::DllUnregister::Error#UnRegisterCOMAddin", hr); | |
90 | 90 | addin = E_FAIL; |
91 | 91 | } |
92 | 92 | } |
@@ -94,12 +94,12 @@ | ||
94 | 94 | |
95 | 95 | hr = UnregisterCOMComponent(progId, classId, version, mode); |
96 | 96 | if(FAILED(hr)) |
97 | - NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllUnregister::Error#UnregisterCOMComponent"); | |
97 | + NetOffice_ShimLoader_Analytics::WriteUnRegisterError(L"Register32On64::DllUnregister::Error#UnregisterCOMComponent", hr); | |
98 | 98 | |
99 | 99 | if(SUCCEEDED(addin != S_OK ? addin : hr)) |
100 | - NetOffice_ShimLoader_Analytics::WriteLog(L"Register32On64::DllUnregister::Exit"); | |
100 | + NetOffice_ShimLoader_Analytics::WriteRegisterLog(L"Register32On64::DllUnregister::Exit"); | |
101 | 101 | else |
102 | - NetOffice_ShimLoader_Analytics::WriteError(L"Register32On64::DllUnregister::FailExit"); | |
102 | + NetOffice_ShimLoader_Analytics::WriteUnRegisterError(L"Register32On64::DllUnregister::FailExit", (addin != S_OK ? addin : hr)); | |
103 | 103 | |
104 | 104 | return addin != S_OK ? addin : hr; |
105 | 105 | } |
@@ -106,6 +106,8 @@ | ||
106 | 106 | |
107 | 107 | HRESULT RegisterCOMComponent(HINSTANCE module, LPCWSTR progId, LPCWSTR classId, LPCWSTR version, LPCWSTR description, RegisterMode mode) |
108 | 108 | { |
109 | + NetOffice_ShimLoader_Analytics::WriteRegisterLog(L"Register32On64::RegisterCOMComponent::Enter"); | |
110 | + | |
109 | 111 | HRESULT hr = S_OK; |
110 | 112 | BOOL setKeyResult = FALSE; |
111 | 113 |
@@ -170,15 +172,19 @@ | ||
170 | 172 | goto Error; |
171 | 173 | } |
172 | 174 | |
175 | + NetOffice_ShimLoader_Analytics::WriteRegisterLog(L"Register32On64::RegisterCOMComponent::Exit"); | |
173 | 176 | return hr; |
174 | 177 | |
175 | 178 | Error: |
176 | 179 | |
180 | + NetOffice_ShimLoader_Analytics::WriteRegisterError(L"Register32On64::RegisterCOMComponent::FailExit", hr); | |
177 | 181 | return hr; |
178 | 182 | } |
179 | 183 | |
180 | 184 | HRESULT UnregisterCOMComponent(LPCWSTR progId, LPCWSTR classId, LPCWSTR version, RegisterMode mode) |
181 | 185 | { |
186 | + NetOffice_ShimLoader_Analytics::WriteUnRegisterLog(L"Register32On64::UnregisterCOMComponent::Enter"); | |
187 | + | |
182 | 188 | HRESULT hr = S_OK; |
183 | 189 | LONG deleteKeyResult = 0; |
184 | 190 |
@@ -203,15 +209,19 @@ | ||
203 | 209 | deleteKeyResult = RecursiveDeleteKey(hKeyRoot, classIdKey); |
204 | 210 | IfNotZeroGo(deleteKeyResult); |
205 | 211 | |
212 | + NetOffice_ShimLoader_Analytics::WriteUnRegisterLog(L"Register32On64::UnregisterCOMComponent::Exit"); | |
206 | 213 | return hr; |
207 | 214 | |
208 | 215 | Error: |
209 | 216 | |
217 | + NetOffice_ShimLoader_Analytics::WriteUnRegisterError(L"Register32On64::UnregisterCOMComponent::FailExit", hr); | |
210 | 218 | return hr; |
211 | 219 | } |
212 | 220 | |
213 | 221 | HRESULT RegisterCOMAddin(LPCWSTR pszOfficeApp, LPCWSTR pszProgID, LPCWSTR pszFriendlyName, LPCWSTR pszDescription, DWORD dwStartupContext, DWORD dwCommandLineSafe, bool registerPerMachine) |
214 | 222 | { |
223 | + NetOffice_ShimLoader_Analytics::WriteRegisterLog(L"Register32On64::RegisterCOMAddin::Enter"); | |
224 | + | |
215 | 225 | HRESULT hr = S_OK; |
216 | 226 | WCHAR szKeyBuf[1024]; |
217 | 227 | DWORD dwTemp = 0; |
@@ -258,6 +268,7 @@ | ||
258 | 268 | } |
259 | 269 | |
260 | 270 | RegCloseKey(hKey); |
271 | + NetOffice_ShimLoader_Analytics::WriteRegisterLog(L"Register32On64::RegisterCOMAddin::Exit"); | |
261 | 272 | return hr; |
262 | 273 | |
263 | 274 | Error: |
@@ -267,11 +278,14 @@ | ||
267 | 278 | RegCloseKey(hKey); |
268 | 279 | RegDeleteKey(hKey, szKeyBuf); |
269 | 280 | } |
281 | + NetOffice_ShimLoader_Analytics::WriteRegisterError(L"Register32On64::RegisterCOMAddin::FailExit", hr); | |
270 | 282 | return hr; |
271 | 283 | } |
272 | 284 | |
273 | 285 | HRESULT UnRegisterCOMAddin(LPCWSTR pszOfficeApp, LPCWSTR pszProgID, bool registerPerMachine) |
274 | 286 | { |
287 | + NetOffice_ShimLoader_Analytics::WriteUnRegisterLog(L"Register32On64::UnRegisterCOMAddin::Enter"); | |
288 | + | |
275 | 289 | HRESULT hr = S_OK; |
276 | 290 | HRESULT result = S_OK; |
277 | 291 |
@@ -283,6 +297,10 @@ | ||
283 | 297 | StringCchCat(szKeyBuf, 1024, pszProgID); |
284 | 298 | |
285 | 299 | hr = RecursiveDeleteKey(root, szKeyBuf); |
300 | + if(SUCCEEDED(hr)) | |
301 | + NetOffice_ShimLoader_Analytics::WriteUnRegisterLog(L"Register32On64::UnRegisterCOMAddin::Exit"); | |
302 | + else | |
303 | + NetOffice_ShimLoader_Analytics::WriteUnRegisterError(L"Register32On64::UnRegisterCOMAddin::FailExit", hr); | |
286 | 304 | return result; |
287 | 305 | } |
288 | 306 |
@@ -3,6 +3,12 @@ | ||
3 | 3 | |
4 | 4 | using namespace NetOffice_ShimLoader_Register; |
5 | 5 | |
6 | +extern WCHAR* LogFile_Path; | |
7 | +extern WCHAR* LogFile_Register_Path; | |
8 | +extern WCHAR* LogFile_UnRegister_Path; | |
9 | + | |
10 | +extern BOOL Internal_LogError_MessageBoxes_Enabled; | |
11 | + | |
6 | 12 | // |
7 | 13 | // Managed Addin Aggregator |
8 | 14 | // |
@@ -3,6 +3,12 @@ | ||
3 | 3 | |
4 | 4 | using namespace NetOffice_ShimLoader_Register; |
5 | 5 | |
6 | +WCHAR* LogFile_Path; | |
7 | +WCHAR* LogFile_Register_Path; | |
8 | +WCHAR* LogFile_UnRegister_Path; | |
9 | + | |
10 | +BOOL Internal_LogError_MessageBoxes_Enabled; | |
11 | + | |
6 | 12 | // |
7 | 13 | // Managed Addin Aggregator |
8 | 14 | // |
@@ -4,11 +4,36 @@ | ||
4 | 4 | #include <fstream> |
5 | 5 | #include <iosfwd> |
6 | 6 | #include <iostream> |
7 | +#include <ctime> | |
7 | 8 | |
9 | +extern WCHAR* LogFile_Path; | |
10 | +extern WCHAR* LogFile_Register_Path; | |
11 | +extern WCHAR* LogFile_UnRegister_Path; | |
12 | +extern BOOL Internal_LogError_MessageBoxes_Enabled; | |
13 | + | |
8 | 14 | namespace NetOffice_ShimLoader_Analytics |
9 | 15 | { |
10 | - static WCHAR _logFilePath[MAX_PATH + 1]; | |
16 | + static const int _bufferSize = 1024; | |
11 | 17 | |
18 | + static HRESULT GetModuleFileName(WCHAR* szPath, DWORD nPathBufferSize) | |
19 | + { | |
20 | + HMODULE hInstance = _AtlBaseModule.GetModuleInstance(); | |
21 | + if (0 == hInstance) | |
22 | + { | |
23 | + return E_FAIL; | |
24 | + } | |
25 | + | |
26 | + DWORD dwFLen = ::GetModuleFileName(hInstance, szPath, nPathBufferSize); | |
27 | + if (0 != dwFLen) | |
28 | + { | |
29 | + return S_OK; | |
30 | + } | |
31 | + else | |
32 | + { | |
33 | + return E_FAIL; | |
34 | + } | |
35 | + } | |
36 | + | |
12 | 37 | static HRESULT GetDllDirectory(WCHAR* szPath, DWORD nPathBufferSize) |
13 | 38 | { |
14 | 39 | HMODULE hInstance = _AtlBaseModule.GetModuleInstance(); |
@@ -35,72 +60,246 @@ | ||
35 | 60 | return S_OK; |
36 | 61 | } |
37 | 62 | |
38 | - static void InitializeLog() | |
63 | + static HRESULT InitializeLog() | |
39 | 64 | { |
40 | - if (SUCCEEDED(GetDllDirectory(_logFilePath, MAX_PATH)) | |
41 | - && SUCCEEDED(PathAppend(_logFilePath, L"ShimLoader.txt"))) | |
65 | + HRESULT hr = S_OK; | |
66 | + | |
67 | + WCHAR moduleFolderPath[MAX_PATH]; | |
68 | + WCHAR moduleFileName[MAX_PATH]; | |
69 | + WCHAR logFileName[MAX_PATH]; | |
70 | + WCHAR logRegisterFileName[MAX_PATH]; | |
71 | + WCHAR logUnregisterFileName[MAX_PATH]; | |
72 | + | |
73 | + hr = GetDllDirectory(moduleFolderPath, MAX_PATH); | |
74 | + if (FAILED(hr)) | |
75 | + goto Error; | |
76 | + hr = GetModuleFileName(moduleFileName, MAX_PATH); | |
77 | + if (FAILED(hr)) | |
78 | + goto Error; | |
79 | + PathStripPath(moduleFileName); | |
80 | + | |
81 | + StringCchCopy(logFileName, MAX_PATH, moduleFileName); | |
82 | + StringCchCat(logFileName, MAX_PATH, L".log"); | |
83 | + | |
84 | + StringCchCopy(logRegisterFileName, MAX_PATH, moduleFileName); | |
85 | + StringCchCat(logRegisterFileName, MAX_PATH, L".Register"); | |
86 | + StringCchCat(logRegisterFileName, MAX_PATH, L".log"); | |
87 | + | |
88 | + StringCchCopy(logUnregisterFileName, MAX_PATH, moduleFileName); | |
89 | + StringCchCat(logUnregisterFileName, MAX_PATH, L".Unregister"); | |
90 | + StringCchCat(logUnregisterFileName, MAX_PATH, L".log"); | |
91 | + | |
92 | + PathAppend(LogFile_Path, moduleFolderPath); | |
93 | + if (LogFile_Path && SUCCEEDED(PathAppend(LogFile_Path, logFileName))) | |
42 | 94 | { |
43 | - if (PathFileExists(_logFilePath)) | |
95 | + if (PathFileExists(LogFile_Path)) | |
44 | 96 | { |
45 | - DeleteFile(_logFilePath); | |
97 | + DeleteFile(LogFile_Path); | |
46 | 98 | } |
47 | 99 | } |
100 | + | |
101 | + PathAppend(LogFile_Register_Path, moduleFolderPath); | |
102 | + if (LogFile_Register_Path && SUCCEEDED(PathAppend(LogFile_Register_Path, logRegisterFileName))) | |
103 | + { | |
104 | + if (PathFileExists(LogFile_Register_Path)) | |
105 | + { | |
106 | + DeleteFile(LogFile_Register_Path); | |
107 | + } | |
108 | + } | |
109 | + | |
110 | + PathAppend(LogFile_UnRegister_Path, moduleFolderPath); | |
111 | + if (LogFile_UnRegister_Path && SUCCEEDED(PathAppend(LogFile_UnRegister_Path, logUnregisterFileName))) | |
112 | + { | |
113 | + if (PathFileExists(LogFile_UnRegister_Path)) | |
114 | + { | |
115 | + DeleteFile(LogFile_UnRegister_Path); | |
116 | + } | |
117 | + } | |
118 | + | |
119 | + return hr; | |
120 | + | |
121 | + Error: | |
122 | + | |
123 | + return hr; | |
48 | 124 | } |
49 | 125 | |
50 | - static void dump(LPCWSTR text) | |
126 | + static void _Write(LPCWSTR text) | |
51 | 127 | { |
52 | - std::wofstream myfile("C:\\myfile.txt", std::ios::app); | |
53 | - if (myfile.is_open()) | |
128 | + std::wofstream myfile(LogFile_Path, std::ios::app); | |
129 | + if (LogFile_Path && myfile.is_open()) | |
54 | 130 | { |
55 | 131 | myfile << text << std::endl; |
56 | 132 | myfile.close(); |
57 | 133 | } |
134 | + else | |
135 | + { | |
136 | + #ifdef DEBUG | |
137 | + MessageBox(GetDesktopWindow(), LogFile_Path, L"WriteLog::_Write::OpenFileError", 0); | |
138 | + #endif | |
139 | + } | |
58 | 140 | } |
59 | 141 | |
142 | + static void _WriteRegister(LPCWSTR text) | |
143 | + { | |
144 | + std::wofstream myfile(LogFile_Register_Path, std::ios::app); | |
145 | + if (LogFile_Register_Path && myfile.is_open()) | |
146 | + { | |
147 | + myfile << text << std::endl; | |
148 | + myfile.close(); | |
149 | + } | |
150 | + else | |
151 | + { | |
152 | + #ifdef DEBUG | |
153 | + MessageBox(GetDesktopWindow(), LogFile_Register_Path, L"WriteLog::_WriteRegister::OpenFileError", 0); | |
154 | + #endif | |
155 | + } | |
156 | + } | |
157 | + | |
158 | + static void _WriteUnRegister(LPCWSTR text) | |
159 | + { | |
160 | + MessageBox(NULL, LogFile_UnRegister_Path, text, 0); | |
161 | + std::wofstream myfile(LogFile_UnRegister_Path, std::ios::app); | |
162 | + if (LogFile_UnRegister_Path && myfile.is_open()) | |
163 | + { | |
164 | + myfile << text << std::endl; | |
165 | + myfile.close(); | |
166 | + } | |
167 | + else | |
168 | + { | |
169 | + #ifdef DEBUG | |
170 | + MessageBox(GetDesktopWindow(), LogFile_UnRegister_Path, L"WriteLog::_WriteUnRegister::OpenFileError", 0); | |
171 | + #endif | |
172 | + } | |
173 | + } | |
174 | + | |
60 | 175 | static void WriteError(LPCWSTR text, ULONG value) |
61 | 176 | { |
62 | - MessageBox(GetDesktopWindow(), text, L"WriteError", 0); | |
177 | + WCHAR buffer[_bufferSize]; | |
178 | + swprintf_s(buffer, _bufferSize, L"%s(%d)", text, value); | |
179 | + _Write(text); | |
180 | + | |
181 | + #ifdef DEBUG | |
182 | + | |
183 | + if(Internal_LogError_MessageBoxes_Enabled) | |
184 | + MessageBox(GetDesktopWindow(), buffer, L"WriteError", 0); | |
185 | + | |
186 | + #endif | |
63 | 187 | } |
64 | 188 | |
65 | - static void WriteError(LPCWSTR text, HRESULT hr) | |
189 | + static void WriteRegisterError(LPCWSTR text, HRESULT value) | |
66 | 190 | { |
67 | - MessageBox(GetDesktopWindow(), text, L"WriteError", 0); | |
191 | + WCHAR buffer[_bufferSize]; | |
192 | + swprintf_s(buffer, _bufferSize, L"%s(HR:%d)", text, value); | |
193 | + _WriteRegister(text); | |
194 | + | |
195 | + #ifdef DEBUG | |
196 | + | |
197 | + if (Internal_LogError_MessageBoxes_Enabled) | |
198 | + MessageBox(GetDesktopWindow(), buffer, L"WriteError", 0); | |
199 | + | |
200 | + #endif | |
68 | 201 | } |
69 | 202 | |
203 | + static void WriteUnRegisterError(LPCWSTR text, HRESULT value) | |
204 | + { | |
205 | + WCHAR buffer[_bufferSize]; | |
206 | + swprintf_s(buffer, _bufferSize, L"%s(HR:%d)", text, value); | |
207 | + _WriteUnRegister(text); | |
208 | + | |
209 | + #ifdef DEBUG | |
210 | + | |
211 | + if (Internal_LogError_MessageBoxes_Enabled) | |
212 | + MessageBox(GetDesktopWindow(), buffer, L"WriteError", 0); | |
213 | + | |
214 | + #endif | |
215 | + } | |
216 | + | |
217 | + static void WriteError(LPCWSTR text, HRESULT value) | |
218 | + { | |
219 | + WCHAR buffer[_bufferSize]; | |
220 | + swprintf_s(buffer, _bufferSize, L"%s(HR:%d)", text, value); | |
221 | + _Write(text); | |
222 | + | |
223 | + #ifdef DEBUG | |
224 | + | |
225 | + if (Internal_LogError_MessageBoxes_Enabled) | |
226 | + MessageBox(GetDesktopWindow(), buffer, L"WriteError", 0); | |
227 | + | |
228 | + #endif | |
229 | + } | |
230 | + | |
70 | 231 | static void WriteError(LPCWSTR text) |
71 | 232 | { |
72 | - MessageBox(GetDesktopWindow(), text, L"WriteError", 0); | |
233 | + _Write(text); | |
234 | + | |
235 | + #ifdef DEBUG | |
236 | + | |
237 | + if (Internal_LogError_MessageBoxes_Enabled) | |
238 | + MessageBox(GetDesktopWindow(), text, L"WriteError", 0); | |
239 | + | |
240 | + #endif | |
73 | 241 | } |
74 | 242 | |
75 | 243 | static void WriteError(LPCWSTR text, LPCWSTR text2) |
76 | 244 | { |
77 | - //MessageBox(GetDesktopWindow(), text, L"WriteLog", 0); | |
245 | + WCHAR buffer[_bufferSize]; | |
246 | + swprintf_s(buffer, _bufferSize, L"%s(%s)", text, text2); | |
247 | + _Write(text); | |
248 | + | |
249 | + #ifdef DEBUG | |
250 | + | |
251 | + if (Internal_LogError_MessageBoxes_Enabled) | |
252 | + MessageBox(GetDesktopWindow(), buffer, L"WriteError", 0); | |
253 | + | |
254 | + #endif | |
78 | 255 | } |
79 | - static void WriteLog(LPCWSTR text, HRESULT hr) | |
256 | + | |
257 | + static void WriteLog(LPCWSTR text, HRESULT value) | |
80 | 258 | { |
81 | - //MessageBox(GetDesktopWindow(), text, L"WriteLog", 0); | |
259 | + WCHAR buffer[_bufferSize]; | |
260 | + swprintf_s(buffer, _bufferSize, L"%s(HR:%d)", text, value); | |
261 | + _Write(text); | |
82 | 262 | } |
83 | - static void WriteLog(LPCWSTR text) | |
263 | + | |
264 | + static void WriteRegisterLog(LPCWSTR text) | |
84 | 265 | { |
85 | - //MessageBox(GetDesktopWindow(), text, L"WriteLog", 0); | |
266 | + _WriteRegister(text); | |
86 | 267 | } |
87 | - static void WriteLog(LPCWSTR text, LPCWSTR text2) | |
268 | + | |
269 | + static void WriteUnRegisterLog(LPCWSTR text) | |
88 | 270 | { |
89 | - //MessageBox(GetDesktopWindow(), text, L"WriteLog", 0); | |
271 | + _WriteUnRegister(text); | |
90 | 272 | } |
91 | 273 | |
92 | - //static void WriteLog(const char* szString) | |
93 | - //{ | |
94 | - // //MessageBox(GetDesktopWindow(), szString, L"WriteLog", 0); | |
274 | + static void WriteLog(LPCWSTR text) | |
275 | + { | |
276 | + _Write(text); | |
277 | + } | |
95 | 278 | |
96 | - // //ShimDebugMessageBox(L"", L""); | |
279 | + static void WriteLogTimeStamp(LPCWSTR text) | |
280 | + { | |
281 | + time_t t = time(NULL); | |
282 | + struct tm buf; | |
283 | + WCHAR timeBuffer[256]; | |
97 | 284 | |
98 | - // /*FILE* file = nullptr; | |
99 | - // auto result = _wfopen_s(&file, _logFilePath, L"a"); | |
100 | - // if (NULL != result) | |
101 | - // { | |
102 | - // fprintf(file, "%s\n", szString); | |
103 | - // fclose(file); | |
104 | - // }*/ | |
105 | - //} | |
285 | + if (NULL == localtime_s(&buf, &t)) | |
286 | + { | |
287 | + wcsftime(timeBuffer, 256, L"(%d-%m-%Y %I:%M:%S %p)", &buf); | |
288 | + WCHAR buffer[_bufferSize]; | |
289 | + StringCchCopy(buffer, _bufferSize, text); | |
290 | + StringCchCat(buffer, _bufferSize, timeBuffer); | |
291 | + _Write(buffer); | |
292 | + } | |
293 | + else | |
294 | + { | |
295 | + _Write(text); | |
296 | + } | |
297 | + } | |
298 | + | |
299 | + static void WriteLog(LPCWSTR text, LPCWSTR text2) | |
300 | + { | |
301 | + WCHAR buffer[_bufferSize]; | |
302 | + swprintf_s(buffer, _bufferSize, L"%s(%s)", text, text2); | |
303 | + _Write(text); | |
304 | + } | |
106 | 305 | } |
@@ -0,0 +1 @@ | ||
1 | +#pragma once |
@@ -0,0 +1 @@ | ||
1 | +#pragma once |