• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revision29196 (tree)
Time2021-05-04 04:27:38
Authorstefankueng

Log Message

cleanup SubWCRevCom

Change Summary

Incremental Difference

--- trunk/src/SubWCRev/Register.cpp (revision 29195)
+++ trunk/src/SubWCRev/Register.cpp (revision 29196)
@@ -1,6 +1,6 @@
11 // TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2005-2008, 2010-2011, 2014, 2020 - TortoiseSVN
3+// Copyright (C) 2005-2008, 2010-2011, 2014, 2020-2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -22,7 +22,6 @@
2222 #include <atlbase.h>
2323 #include <assert.h>
2424
25-
2625 #include "Register.h"
2726
2827 //
@@ -30,23 +29,21 @@
3029 //
3130
3231 // Set the given key and its value.
33-BOOL setKeyAndValue(const TCHAR* pszPath,
34- const TCHAR* szSubkey,
35- const TCHAR* szValue) ;
32+BOOL setKeyAndValue(const wchar_t* pszPath,
33+ const wchar_t* szSubkey,
34+ const wchar_t* szValue);
3635
36+BOOL setValue(const wchar_t* szKey,
37+ const wchar_t* szEntry,
38+ const wchar_t* szValue);
3739
38-BOOL setValue(const TCHAR* szKey,
39- const TCHAR* szEntry,
40- const TCHAR* szValue);
41-
42-
4340 // Convert a CLSID into a char string.
44-void CLSIDtochar(const CLSID& clsid,
45- TCHAR* szCLSID,
46- int length) ;
41+void CLSIDTochar(const CLSID& clsid,
42+ wchar_t* szCLSID,
43+ int length);
4744
4845 // Delete szKeyChild and all of its descendants.
49-LONG recursiveDeleteKey(HKEY hKeyParent, const TCHAR* szKeyChild) ;
46+LONG recursiveDeleteKey(HKEY hKeyParent, const wchar_t* szKeyChild);
5047
5148 ////////////////////////////////////////////////////////
5249 //
@@ -54,7 +51,7 @@
5451 //
5552
5653 // Size of a CLSID as a string
57-const int CLSID_STRING_SIZE = 39 ;
54+const int CLSID_STRING_SIZE = 39;
5855
5956 /////////////////////////////////////////////////////////
6057 //
@@ -64,178 +61,175 @@
6461 //
6562 // Register the component in the registry.
6663 //
67-HRESULT RegisterServer(HMODULE hModule, // DLL module handle
68- const CLSID& clsid, // Class ID
69- const TCHAR* szFriendlyName, // Friendly Name
70- const TCHAR* szVerIndProgID, // Programmatic
71- const TCHAR* szProgID,
72- const CLSID &libid) // Type lib ID
64+HRESULT RegisterServer(HMODULE hModule, // DLL module handle
65+ const CLSID& clsid, // Class ID
66+ const wchar_t* szFriendlyName, // Friendly Name
67+ const wchar_t* szVerIndProgID, // Programmatic
68+ const wchar_t* szProgID,
69+ const CLSID& libid) // Type lib ID
7370 {
7471 // Get server location.
75- TCHAR szModule[1024] = {0};
72+ wchar_t szModule[1024] = {0};
7673 ::GetModuleFileName(hModule,
7774 szModule,
7875 _countof(szModule) - 1);
7976
8077 wcscat_s(szModule, L" /automation");
81- // Convert the CLSID into a TCHAR.
82- TCHAR szCLSID[CLSID_STRING_SIZE] ;
83- CLSIDtochar(clsid, szCLSID, _countof(szCLSID)) ;
84- TCHAR szLIBID[CLSID_STRING_SIZE] ;
85- CLSIDtochar(libid, szLIBID, _countof(szLIBID)) ;
78+ // Convert the CLSID into a wchar_t.
79+ wchar_t szCLSID[CLSID_STRING_SIZE];
80+ CLSIDTochar(clsid, szCLSID, _countof(szCLSID));
81+ wchar_t szLibid[CLSID_STRING_SIZE];
82+ CLSIDTochar(libid, szLibid, _countof(szLibid));
8683
8784 // Build the key CLSID\\{...}
88- TCHAR szKey[64] ;
85+ wchar_t szKey[64];
8986 wcscpy_s(szKey, L"CLSID\\");
90- wcscat_s(szKey, szCLSID) ;
87+ wcscat_s(szKey, szCLSID);
9188
9289 // Add the CLSID to the registry.
93- setKeyAndValue(szKey, NULL, szFriendlyName) ;
90+ setKeyAndValue(szKey, nullptr, szFriendlyName);
9491
9592 // Add the server filename subkey under the CLSID key.
96- setKeyAndValue(szKey, L"LocalServer32", szModule) ;
93+ setKeyAndValue(szKey, L"LocalServer32", szModule);
9794
9895 // Add the ProgID subkey under the CLSID key.
99- setKeyAndValue(szKey, L"ProgID", szProgID) ;
96+ setKeyAndValue(szKey, L"ProgID", szProgID);
10097
10198 // Add the version-independent ProgID subkey under CLSID key.
102- setKeyAndValue(szKey, L"VersionIndependentProgID", szVerIndProgID) ;
99+ setKeyAndValue(szKey, L"VersionIndependentProgID", szVerIndProgID);
103100
104101 // Add the typelib
105- setKeyAndValue(szKey, L"TypeLib", szLIBID) ;
102+ setKeyAndValue(szKey, L"TypeLib", szLibid);
106103
107-
108104 // Add the version-independent ProgID subkey under HKEY_CLASSES_ROOT.
109- setKeyAndValue(szVerIndProgID, NULL, szFriendlyName) ;
110- setKeyAndValue(szVerIndProgID, L"CLSID", szCLSID) ;
111- setKeyAndValue(szVerIndProgID, L"CurVer", szProgID) ;
105+ setKeyAndValue(szVerIndProgID, nullptr, szFriendlyName);
106+ setKeyAndValue(szVerIndProgID, L"CLSID", szCLSID);
107+ setKeyAndValue(szVerIndProgID, L"CurVer", szProgID);
112108
113109 // Add the versioned ProgID subkey under HKEY_CLASSES_ROOT.
114- setKeyAndValue(szProgID, NULL, szFriendlyName) ;
115- setKeyAndValue(szProgID, L"CLSID", szCLSID) ;
110+ setKeyAndValue(szProgID, nullptr, szFriendlyName);
111+ setKeyAndValue(szProgID, L"CLSID", szCLSID);
116112
117113 // add TypeLib keys
118- wcscpy_s(szKey, L"TypeLib\\") ;
119- wcscat_s(szKey, szLIBID) ;
114+ wcscpy_s(szKey, L"TypeLib\\");
115+ wcscat_s(szKey, szLibid);
120116
121117 // Add the CLSID to the registry.
122- setKeyAndValue(szKey, NULL, NULL) ;
118+ setKeyAndValue(szKey, nullptr, nullptr);
123119 wcscat_s(szKey, L"\\1.0");
124- setKeyAndValue(szKey, NULL, szFriendlyName) ;
120+ setKeyAndValue(szKey, nullptr, szFriendlyName);
125121 wcscat_s(szKey, L"\\0");
126- setKeyAndValue(szKey, NULL, NULL) ;
122+ setKeyAndValue(szKey, nullptr, nullptr);
127123 wcscat_s(szKey, L"\\win32");
128- setKeyAndValue(szKey, NULL, szModule) ;
124+ setKeyAndValue(szKey, nullptr, szModule);
129125
130-
131- return S_OK ;
126+ return S_OK;
132127 }
133128
134-
135-void RegisterInterface(HMODULE hModule, // DLL module handle
136- const CLSID& clsid, // Class ID
137- const TCHAR* szFriendlyName, // Friendly Name
138- const CLSID &libid,
139- const IID &iid)
129+void RegisterInterface(HMODULE hModule, // DLL module handle
130+ const CLSID& clsid, // Class ID
131+ const wchar_t* szFriendlyName, // Friendly Name
132+ const CLSID& libid,
133+ const IID& iid)
140134 {
141135 // Get server location.
142- TCHAR szModule[512] = {0};
136+ wchar_t szModule[512] = {0};
143137 ::GetModuleFileName(hModule,
144138 szModule,
145139 _countof(szModule) - 1);
146140
147- // Convert the CLSID into a TCHAR.
148- TCHAR szCLSID[CLSID_STRING_SIZE] ;
149- CLSIDtochar(clsid, szCLSID, _countof(szCLSID)) ;
150- TCHAR szLIBID[CLSID_STRING_SIZE] ;
151- CLSIDtochar(libid, szLIBID, _countof(szCLSID)) ;
152- TCHAR szIID[CLSID_STRING_SIZE] ;
153- CLSIDtochar(iid, szIID, _countof(szCLSID)) ;
141+ // Convert the CLSID into a wchar_t.
142+ wchar_t szCLSID[CLSID_STRING_SIZE];
143+ CLSIDTochar(clsid, szCLSID, _countof(szCLSID));
144+ wchar_t szLibid[CLSID_STRING_SIZE];
145+ CLSIDTochar(libid, szLibid, _countof(szCLSID));
146+ wchar_t szIid[CLSID_STRING_SIZE];
147+ CLSIDTochar(iid, szIid, _countof(szCLSID));
154148
155149 // Build the key Interface\\{...}
156- TCHAR szKey[64] ;
157- wcscpy_s(szKey, L"Interface\\") ;
158- wcscat_s(szKey, szIID) ;
150+ wchar_t szKey[64];
151+ wcscpy_s(szKey, L"Interface\\");
152+ wcscat_s(szKey, szIid);
159153
160154 // Add the value to the registry.
161- setKeyAndValue(szKey, NULL, szFriendlyName) ;
155+ setKeyAndValue(szKey, nullptr, szFriendlyName);
162156
163- TCHAR szKey2[MAX_PATH] = { 0 };
157+ wchar_t szKey2[MAX_PATH] = {0};
164158 wcscpy_s(szKey2, szKey);
165159 wcscat_s(szKey2, L"\\ProxyStubClsID");
166160 // Add the server filename subkey under the IID key.
167- setKeyAndValue(szKey2, NULL, L"{00020424-0000-0000-C000-000000000046}"); //IUnknown
161+ setKeyAndValue(szKey2, nullptr, L"{00020424-0000-0000-C000-000000000046}"); //IUnknown
168162
169163 wcscpy_s(szKey2, szKey);
170164 wcscat_s(szKey2, L"\\ProxyStubClsID32");
171165 // Add the server filename subkey under the IID key.
172- setKeyAndValue(szKey2, NULL, L"{00020424-0000-0000-C000-000000000046}"); //IUnknown
166+ setKeyAndValue(szKey2, nullptr, L"{00020424-0000-0000-C000-000000000046}"); //IUnknown
173167
174168 wcscpy_s(szKey2, szKey);
175169 wcscat_s(szKey2, L"\\TypeLib");
176170 // Add the server filename subkey under the CLSID key.
177- setKeyAndValue(szKey2, NULL, szLIBID) ;
171+ setKeyAndValue(szKey2, nullptr, szLibid);
178172
179- setValue(szKey2, L"Version", L"1.0") ;
173+ setValue(szKey2, L"Version", L"1.0");
180174 }
181175
182-void UnregisterInterface(const IID &iid)
176+void UnregisterInterface(const IID& iid)
183177 {
184- TCHAR szIID[CLSID_STRING_SIZE] ;
185- CLSIDtochar(iid, szIID, _countof(szIID)) ;
178+ wchar_t szIID[CLSID_STRING_SIZE];
179+ CLSIDTochar(iid, szIID, _countof(szIID));
186180
187181 // Build the key Interface\\{...}
188- TCHAR szKey[64] ;
182+ wchar_t szKey[64];
189183 wcscpy_s(szKey, L"Interface\\");
190- wcscat_s(szKey, szIID) ;
184+ wcscat_s(szKey, szIID);
191185
192- recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
186+ recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey);
193187 }
194188
195189 //
196190 // Remove the component from the registry.
197191 //
198-LONG UnregisterServer(const CLSID& clsid, // Class ID
199- const TCHAR* szVerIndProgID, // Programmatic
200- const TCHAR* szProgID,
201- const CLSID &libid) // Type lib ID
192+LONG UnregisterServer(const CLSID& clsid, // Class ID
193+ const wchar_t* szVerIndProgID, // Programmatic
194+ const wchar_t* szProgID,
195+ const CLSID& libid) // Type lib ID
202196 {
203- // Convert the CLSID into a TCHAR.
204- TCHAR szCLSID[CLSID_STRING_SIZE] ;
205- CLSIDtochar(clsid, szCLSID, _countof(szCLSID)) ;
197+ // Convert the CLSID into a wchar_t.
198+ wchar_t szCLSID[CLSID_STRING_SIZE];
199+ CLSIDTochar(clsid, szCLSID, _countof(szCLSID));
206200
207201 // Build the key CLSID\\{...}
208- TCHAR szKey[64] ;
202+ wchar_t szKey[64];
209203 wcscpy_s(szKey, L"CLSID\\");
210- wcscat_s(szKey, szCLSID) ;
204+ wcscat_s(szKey, szCLSID);
211205
212206 // Delete the CLSID Key - CLSID\{...}
213- LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
207+ LONG lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey);
214208 assert((lResult == ERROR_SUCCESS) ||
215- (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
209+ (lResult == ERROR_FILE_NOT_FOUND)); // Subkey may not exist.
216210
217211 // Delete the version-independent ProgID Key.
218- lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szVerIndProgID) ;
212+ lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szVerIndProgID);
219213 assert((lResult == ERROR_SUCCESS) ||
220- (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
214+ (lResult == ERROR_FILE_NOT_FOUND)); // Subkey may not exist.
221215
222216 // Delete the ProgID key.
223- lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szProgID) ;
217+ lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szProgID);
224218 assert((lResult == ERROR_SUCCESS) ||
225- (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
219+ (lResult == ERROR_FILE_NOT_FOUND)); // Subkey may not exist.
226220
227- TCHAR szLIBID[CLSID_STRING_SIZE] ;
228- CLSIDtochar(libid, szLIBID, _countof(szLIBID)) ;
221+ wchar_t szLibid[CLSID_STRING_SIZE];
222+ CLSIDTochar(libid, szLibid, _countof(szLibid));
229223
230224 wcscpy_s(szKey, L"TypeLib\\");
231- wcscat_s(szKey, szLIBID) ;
225+ wcscat_s(szKey, szLibid);
232226
233227 // Delete the TypeLib Key - LIBID\{...}
234- lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey) ;
228+ lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szKey);
235229 assert((lResult == ERROR_SUCCESS) ||
236- (lResult == ERROR_FILE_NOT_FOUND)) ; // Subkey may not exist.
230+ (lResult == ERROR_FILE_NOT_FOUND)); // Subkey may not exist.
237231
238- return S_OK ;
232+ return S_OK;
239233 }
240234
241235 ///////////////////////////////////////////////////////////
@@ -243,51 +237,51 @@
243237 // Internal helper functions
244238 //
245239
246-// Convert a CLSID to a TCHAR string.
247-void CLSIDtochar(const CLSID& clsid,
248- TCHAR* szCLSID,
249- int length)
240+// Convert a CLSID to a wchar_t string.
241+void CLSIDTochar(const CLSID& clsid,
242+ wchar_t* szCLSID,
243+ int length)
250244 {
251- assert(length >= CLSID_STRING_SIZE) ;
245+ assert(length >= CLSID_STRING_SIZE);
252246 // Get CLSID
253- LPOLESTR wszCLSID = NULL ;
254- StringFromCLSID(clsid, &wszCLSID) ;
247+ LPOLESTR wszCLSID = nullptr;
248+ StringFromCLSID(clsid, &wszCLSID);
255249
256250 // Covert from wide characters to non-wide.
257- wcscpy_s(szCLSID, length, wszCLSID) ;
251+ wcscpy_s(szCLSID, length, wszCLSID);
258252
259253 // Free memory.
260- CoTaskMemFree(wszCLSID) ;
254+ CoTaskMemFree(wszCLSID);
261255 }
262256
263257 //
264258 // Delete a key and all of its descendants.
265259 //
266-LONG recursiveDeleteKey(HKEY hKeyParent, // Parent of key to delete
267- const TCHAR* lpszKeyChild) // Key to delete
260+LONG recursiveDeleteKey(HKEY hKeyParent, // Parent of key to delete
261+ const wchar_t* lpszKeyChild) // Key to delete
268262 {
269263 // Open the child.
270- HKEY hKeyChild ;
264+ HKEY hKeyChild;
271265 LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0,
272- KEY_ALL_ACCESS, &hKeyChild) ;
266+ KEY_ALL_ACCESS, &hKeyChild);
273267 if (lRes != ERROR_SUCCESS)
274268 {
275- return lRes ;
269+ return lRes;
276270 }
277271
278272 // Enumerate all of the descendants of this child.
279- FILETIME time ;
280- TCHAR szBuffer[256] ;
281- DWORD dwSize = _countof(szBuffer);
282- while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL,
283- NULL, NULL, &time) == S_OK)
273+ FILETIME time;
274+ wchar_t szBuffer[256];
275+ DWORD dwSize = _countof(szBuffer);
276+ while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, nullptr,
277+ nullptr, nullptr, &time) == S_OK)
284278 {
285279 // Delete the descendants of this child.
286- lRes = recursiveDeleteKey(hKeyChild, szBuffer) ;
280+ lRes = recursiveDeleteKey(hKeyChild, szBuffer);
287281 if (lRes != ERROR_SUCCESS)
288282 {
289283 // Cleanup before exiting.
290- RegCloseKey(hKeyChild) ;
284+ RegCloseKey(hKeyChild);
291285 return lRes;
292286 }
293287 dwSize = _countof(szBuffer);
@@ -294,10 +288,10 @@
294288 }
295289
296290 // Close the child.
297- RegCloseKey(hKeyChild) ;
291+ RegCloseKey(hKeyChild);
298292
299293 // Delete this child.
300- return RegDeleteKey(hKeyParent, lpszKeyChild) ;
294+ return RegDeleteKey(hKeyParent, lpszKeyChild);
301295 }
302296
303297 //
@@ -305,18 +299,18 @@
305299 // - This helper function was borrowed and modified from
306300 // Kraig Brockschmidt's book Inside OLE.
307301 //
308-BOOL setKeyAndValue(const TCHAR* szKey,
309- const TCHAR* szSubkey,
310- const TCHAR* szValue)
302+BOOL setKeyAndValue(const wchar_t* szKey,
303+ const wchar_t* szSubkey,
304+ const wchar_t* szValue)
311305 {
312- HKEY hKey;
313- TCHAR szKeyBuf[1024] ;
306+ HKEY hKey;
307+ wchar_t szKeyBuf[1024];
314308
315309 // Copy key name into buffer.
316- wcscpy_s(szKeyBuf, szKey) ;
310+ wcscpy_s(szKeyBuf, szKey);
317311
318312 // Add subkey name to buffer.
319- if (szSubkey != NULL)
313+ if (szSubkey != nullptr)
320314 {
321315 wcscat_s(szKeyBuf, L"\\");
322316 wcscat_s(szKeyBuf, szSubkey);
@@ -323,103 +317,98 @@
323317 }
324318
325319 // Create and open key and subkey.
326- long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT ,
320+ long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT,
327321 szKeyBuf,
328- 0, NULL, REG_OPTION_NON_VOLATILE,
329- KEY_ALL_ACCESS, NULL,
330- &hKey, NULL) ;
322+ 0, nullptr, REG_OPTION_NON_VOLATILE,
323+ KEY_ALL_ACCESS, nullptr,
324+ &hKey, nullptr);
331325 if (lResult != ERROR_SUCCESS)
332326 {
333- return FALSE ;
327+ return FALSE;
334328 }
335329
336330 // Set the Value.
337- if (szValue != NULL)
331+ if (szValue != nullptr)
338332 {
339- RegSetValueEx(hKey, NULL, 0, REG_SZ,
340- (BYTE *)szValue,
341- DWORD( (1 + wcslen(szValue))*sizeof(TCHAR) )
342- ) ;
333+ RegSetValueEx(hKey, nullptr, 0, REG_SZ,
334+ reinterpret_cast<BYTE*>(const_cast<wchar_t*>(szValue)),
335+ static_cast<DWORD>((1 + wcslen(szValue)) * sizeof(wchar_t)));
343336 }
344337
345- RegCloseKey(hKey) ;
346- return TRUE ;
338+ RegCloseKey(hKey);
339+ return TRUE;
347340 }
348341
349-
350-BOOL setValue(const TCHAR* szKey,
351- const TCHAR* szEntry,
352- const TCHAR* szValue)
342+BOOL setValue(const wchar_t* szKey,
343+ const wchar_t* szEntry,
344+ const wchar_t* szValue)
353345 {
354346 HKEY hKey;
355347
356348 // Create and open key and subkey.
357- long lResult = RegOpenKeyEx(HKEY_CLASSES_ROOT ,
358- szKey,
359- 0,
360- KEY_ALL_ACCESS,
361- &hKey) ;
349+ long lResult = RegOpenKeyEx(HKEY_CLASSES_ROOT,
350+ szKey,
351+ 0,
352+ KEY_ALL_ACCESS,
353+ &hKey);
362354 if (lResult != ERROR_SUCCESS)
363355 {
364- return FALSE ;
356+ return FALSE;
365357 }
366358
367359 // Set the Value.
368- if (szValue != NULL)
360+ if (szValue != nullptr)
369361 {
370362 RegSetValueEx(hKey, szEntry, 0, REG_SZ,
371- (BYTE *)szValue,
372- DWORD( (1 + wcslen(szValue))*sizeof(TCHAR) )
373- ) ;
363+ reinterpret_cast<BYTE*>(const_cast<wchar_t*>(szValue)),
364+ static_cast<DWORD>((1 + wcslen(szValue)) * sizeof(wchar_t)));
374365 }
375366
376- RegCloseKey(hKey) ;
367+ RegCloseKey(hKey);
377368
378369 return TRUE;
379370 }
380371
381-
382-
383372 /////////////////////////////////////////////////////////////////////////////
384373 // TypeLib registration
385374
386375 HRESULT LoadTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex, BSTR* pbstrPath, ITypeLib** ppTypeLib)
387376 {
388- ATLASSERT(pbstrPath != NULL && ppTypeLib != NULL);
389- if (pbstrPath == NULL || ppTypeLib == NULL)
377+ ATLASSERT(pbstrPath != nullptr && ppTypeLib != nullptr);
378+ if (pbstrPath == nullptr || ppTypeLib == nullptr)
390379 return E_POINTER;
391380
392- *pbstrPath = NULL;
393- *ppTypeLib = NULL;
381+ *pbstrPath = nullptr;
382+ *ppTypeLib = nullptr;
394383
395384 USES_CONVERSION;
396- ATLASSERT(hInstTypeLib != NULL);
397- TCHAR szModule[MAX_PATH+10] = {0};
385+ ATLASSERT(hInstTypeLib != nullptr);
386+ wchar_t szModule[MAX_PATH + 10] = {0};
398387
399388 DWORD dwFLen = ::GetModuleFileName(hInstTypeLib, szModule, MAX_PATH);
400- if( dwFLen == 0 )
389+ if (dwFLen == 0)
401390 return HRESULT_FROM_WIN32(::GetLastError());
402- else if( dwFLen == MAX_PATH )
391+ else if (dwFLen == MAX_PATH)
403392 return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
404393
405394 // get the extension pointer in case of fail
406395 LPWSTR lpszExt = ::PathFindExtension(szModule);
407396
408- if (lpszIndex != NULL)
397+ if (lpszIndex != nullptr)
409398 lstrcat(szModule, OLE2CT(lpszIndex));
410399 LPOLESTR lpszModule = T2OLE(szModule);
411- HRESULT hr = ::LoadTypeLib(lpszModule, ppTypeLib);
400+ HRESULT hr = ::LoadTypeLib(lpszModule, ppTypeLib);
412401 if (FAILED(hr))
413402 {
414403 // typelib not in module, try <module>.tlb instead
415404 lstrcpy(lpszExt, L".tlb");
416405 lpszModule = T2OLE(szModule);
417- hr = ::LoadTypeLib(lpszModule, ppTypeLib);
406+ hr = ::LoadTypeLib(lpszModule, ppTypeLib);
418407 }
419408 if (SUCCEEDED(hr))
420409 {
421410 *pbstrPath = ::SysAllocString(lpszModule);
422- if (*pbstrPath == NULL)
411+ if (*pbstrPath == nullptr)
423412 hr = E_OUTOFMEMORY;
424413 }
425414 return hr;
@@ -427,11 +416,11 @@
427416
428417 static inline UINT WINAPI GetDirLen(LPCOLESTR lpszPathName)
429418 {
430- ATLASSERT(lpszPathName != NULL);
419+ ATLASSERT(lpszPathName != nullptr);
431420
432421 // always capture the complete file name including extension (if present)
433422 LPCOLESTR lpszTemp = lpszPathName;
434- for (LPCOLESTR lpsz = lpszPathName; *lpsz != NULL; )
423+ for (LPCOLESTR lpsz = lpszPathName; *lpsz != NULL;)
435424 {
436425 LPCOLESTR lp = CharNextW(lpsz);
437426 // remember last directory/drive separator
@@ -440,28 +429,28 @@
440429 lpsz = lp;
441430 }
442431
443- return UINT( lpszTemp-lpszPathName );
432+ return static_cast<UINT>(lpszTemp - lpszPathName);
444433 }
445434
446435 HRESULT RegisterTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex)
447436 {
448- CComBSTR bstrPath;
437+ CComBSTR bstrPath;
449438 CComPtr<ITypeLib> pTypeLib;
450- HRESULT hr = LoadTypeLib(hInstTypeLib, lpszIndex, &bstrPath, &pTypeLib);
439+ HRESULT hr = LoadTypeLib(hInstTypeLib, lpszIndex, &bstrPath, &pTypeLib);
451440 if (SUCCEEDED(hr))
452441 {
453- OLECHAR szDir[MAX_PATH] = { 0 };
442+ OLECHAR szDir[MAX_PATH] = {0};
454443 ocscpy_s(szDir, _countof(szDir), bstrPath);
455444 // If index is specified remove it from the path
456- if (lpszIndex != NULL)
445+ if (lpszIndex != nullptr)
457446 {
458- size_t nLenPath = ocslen(szDir);
447+ size_t nLenPath = ocslen(szDir);
459448 size_t nLenIndex = ocslen(lpszIndex);
460449 if (memcmp(szDir + nLenPath - nLenIndex, lpszIndex, nLenIndex) == 0)
461450 szDir[nLenPath - nLenIndex] = 0;
462451 }
463452 szDir[GetDirLen(szDir)] = 0;
464- hr = ::RegisterTypeLib(pTypeLib, bstrPath, szDir);
453+ hr = ::RegisterTypeLib(pTypeLib, bstrPath, szDir);
465454 }
466455 return hr;
467456 }
@@ -468,14 +457,14 @@
468457
469458 HRESULT UnRegisterTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex)
470459 {
471- CComBSTR bstrPath;
460+ CComBSTR bstrPath;
472461 CComPtr<ITypeLib> pTypeLib;
473- HRESULT hr = LoadTypeLib(hInstTypeLib, lpszIndex, &bstrPath, &pTypeLib);
462+ HRESULT hr = LoadTypeLib(hInstTypeLib, lpszIndex, &bstrPath, &pTypeLib);
474463 if (SUCCEEDED(hr))
475464 {
476- TLIBATTR* ptla = 0;
477- hr = pTypeLib->GetLibAttr(&ptla);
478- if ((SUCCEEDED(hr)) && (ptla != 0))
465+ TLIBATTR* ptla = nullptr;
466+ hr = pTypeLib->GetLibAttr(&ptla);
467+ if ((SUCCEEDED(hr)) && (ptla != nullptr))
479468 {
480469 hr = ::UnRegisterTypeLib(ptla->guid, ptla->wMajorVerNum, ptla->wMinorVerNum, ptla->lcid, ptla->syskind);
481470 pTypeLib->ReleaseTLibAttr(ptla);
--- trunk/src/SubWCRev/Register.h (revision 29195)
+++ trunk/src/SubWCRev/Register.h (revision 29196)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2007, 2010, 2012 - TortoiseSVN
3+// Copyright (C) 2007, 2010, 2012, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -25,29 +25,26 @@
2525
2626 // This function will register a component in the Registry.
2727 // The component calls this function from its DllRegisterServer function.
28-HRESULT RegisterServer(HMODULE hModule,
29- const CLSID& clsid,
30- const TCHAR* szFriendlyName,
31- const TCHAR* szVerIndProgID,
32- const TCHAR* szProgID,
33- const CLSID& libid) ;
28+HRESULT RegisterServer(HMODULE hModule,
29+ const CLSID& clsid,
30+ const wchar_t* szFriendlyName,
31+ const wchar_t* szVerIndProgID,
32+ const wchar_t* szProgID,
33+ const CLSID& libid);
3434
3535 // This function will unregister a component. Components
3636 // call this function from their DllUnregisterServer function.
37-HRESULT UnregisterServer(const CLSID& clsid,
38- const TCHAR* szVerIndProgID,
39- const TCHAR* szProgID,
40- const CLSID& libid) ;
37+HRESULT UnregisterServer(const CLSID& clsid,
38+ const wchar_t* szVerIndProgID,
39+ const wchar_t* szProgID,
40+ const CLSID& libid);
4141
42+void RegisterInterface(HMODULE hModule, // DLL module handle
43+ const CLSID& clsid, // Class ID
44+ const wchar_t* szFriendlyName, // Friendly Name
45+ const CLSID& libid,
46+ const IID& iid);
47+void UnregisterInterface(const IID& iid);
4248
43-void RegisterInterface(HMODULE hModule, // DLL module handle
44- const CLSID& clsid, // Class ID
45- const TCHAR* szFriendlyName, // Friendly Name
46- const CLSID &libid,
47- const IID &iid);
48-void UnregisterInterface(const IID &iid);
49-
50-
5149 HRESULT RegisterTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex);
5250 HRESULT UnRegisterTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex);
53-
Show on old repository browser