Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

shellext: extract GetRegistryConfig into new RegistryConfig.cpp

Changeset 3c5afd3c0bbf

Parent 81461256fd3e

by Adrian Buehlmann

Changes to 8 files · Browse files at 3c5afd3c0bbf Showing diff from parent 81461256fd3e Diff from another changeset...

 
8
9
10
 
11
12
13
 
8
9
10
11
12
13
14
@@ -8,6 +8,7 @@
 #include "SysInfo.h"  #include "ShellExt.h"  #include "CShellExtCMenu.h" +#include "RegistryConfig.h"  #include <map>    
 
3
4
5
 
6
7
8
 
3
4
5
6
7
8
9
@@ -3,6 +3,7 @@
 #include "TortoiseUtils.h"  #include "StringUtils.h"  #include "QueryDirstate.h" +#include "RegistryConfig.h"  #include "CShellExtOverlay.h"    #include <shlwapi.h>
 
3
4
5
 
6
7
8
 
21
22
23
24
25
26
27
28
29
30
 
 
31
32
33
 
3
4
5
6
7
8
9
 
22
23
24
 
 
 
 
 
 
 
25
26
27
28
29
@@ -3,6 +3,7 @@
  Direntry.obj \   Directory.obj \   Winstat.obj \ + RegistryConfig.obj \   ThgDebug.obj    OBJECTS_THGSGELL = $(OBJECTS_DIRSTATE) \ @@ -21,13 +22,8 @@
  Thgstatus.obj \   QueryDirstate.obj   -# TODO: Break link dependencies: Thgstatus needs ThgDebug if compiled with -# /DTHG_DEBUG, which in turn depends on TortoiseUtils and then even -# IconBitmapUtils and SysInfo -OBJECTS_TERMINATE = TortoiseUtils.obj \ - SysInfo.obj \ - IconBitmapUtils.obj \ - Thgstatus.obj \ +OBJECTS_TERMINATE = Thgstatus.obj \ + RegistryConfig.obj \   ThgDebug.obj    LIBS = shlwapi.lib gdiplus.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
Change 1 of 1 Show Entire File win32/​shellext/​RegistryConfig.cpp Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
@@ -0,0 +1,30 @@
+#include "stdafx.h" +#include "RegistryConfig.h" + +int GetRegistryConfig(const std::string& name, std::string& res) +{ + const char* const subkey = "Software\\TortoiseHg"; + + HKEY hkey = 0; + LONG rv = RegOpenKeyExA( + HKEY_CURRENT_USER, subkey, 0, KEY_READ, &hkey); + + if (rv != ERROR_SUCCESS || hkey == 0) + return 0; + + BYTE Data[MAX_PATH] = ""; + DWORD cbData = MAX_PATH * sizeof(BYTE); + + rv = RegQueryValueExA( + hkey, name.c_str(), 0, 0, Data, &cbData); + + int ret = 0; + if (rv == ERROR_SUCCESS) + { + res = reinterpret_cast<const char*>(&Data); + ret = 1; + } + + RegCloseKey(hkey); + return ret; +}
Change 1 of 1 Show Entire File win32/​shellext/​RegistryConfig.h Stacked
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
@@ -0,0 +1,8 @@
+#ifndef REGISTRY_CONFIG_H_ +#define REGISTRY_CONFIG_H_ + +#include <string> + +int GetRegistryConfig(const std::string& name, std::string& res); + +#endif
 
7
8
9
10
11
12
 
13
14
15
 
7
8
9
 
 
 
10
11
12
13
@@ -7,9 +7,7 @@
 // (at your option) any later version.    #include "ThgDebug.h" -#include "TortoiseUtils.h" - -#include <string> +#include "RegistryConfig.h"    bool ThgDebug::regDebugShellExt()  {
 
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
 
62
63
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
66
67
@@ -62,35 +62,6 @@
 }     -int GetRegistryConfig(const std::string& name, std::string& res) -{ - const char* const subkey = "Software\\TortoiseHg"; - - HKEY hkey = 0; - LONG rv = RegOpenKeyExA( - HKEY_CURRENT_USER, subkey, 0, KEY_READ, &hkey); - - if (rv != ERROR_SUCCESS || hkey == 0) - return 0; - - BYTE Data[MAX_PATH] = ""; - DWORD cbData = MAX_PATH * sizeof(BYTE); - - rv = RegQueryValueExA( - hkey, name.c_str(), 0, 0, Data, &cbData); - - int ret = 0; - if (rv == ERROR_SUCCESS) - { - res = reinterpret_cast<const char*>(&Data); - ret = 1; - } - - RegCloseKey(hkey); - return ret; -} - -  // Start an external command  // Note: if the command is a batch file and the [full] path to the  // batch contains spaces, the path must be double-quoted.
 
22
23
24
25
26
27
28
 
22
23
24
 
25
26
27
@@ -22,7 +22,6 @@
 HBITMAP GetTortoiseIconBitmap(const std::string& iconname);  std::string GetHgRepoRoot(const std::string& path);  bool IsHgRepo(const std::string& path); -int GetRegistryConfig(const std::string& name, std::string& res);  FILE* fopenReadRenameAllowed(const char* path);  int GetRegSZValue(HKEY hkey, const char* name, std::string& res);  int GetRegSZValueW(HKEY hkey, const wchar_t* name, std::wstring& res);