Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8.1, 0.8.2, and 0.8.3

shellext: new function GetRegSZValue

Changeset 6312c431a02c

Parent 324626306cc4

by Adrian Buehlmann

Changes to 2 files · Browse files at 6312c431a02c Showing diff from parent 324626306cc4 Diff from another changeset...

 
1
2
 
 
3
4
5
 
254
255
256
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
 
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
@@ -1,5 +1,7 @@
 #include "stdafx.h"  #include "TortoiseUtils.h" + +#include <vector>  #include <assert.h>    #include <io.h> @@ -254,3 +256,26 @@
  return f;  }   + +// read string value from registry +int GetRegSZValue(HKEY hkey, const char* name, std::string& res) +{ + res = ""; + + if (!hkey) + return 0; + + std::vector<BYTE> Data(300); + DWORD cbData = Data.size(); + + LONG rv = ::RegQueryValueExA(hkey, name, 0, 0, &Data[0], &cbData); + + if (rv == ERROR_SUCCESS) + { + res = reinterpret_cast<char*>(&Data[0]); + return 1; + } + + return 0; +} +
 
23
24
25
 
26
27
 
23
24
25
26
27
28
@@ -23,5 +23,6 @@
 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);    #endif