@@ -91,20 +91,29 @@ class __declspec(uuid(DLL_UUID)) ExplorerCommandHandler final : public RuntimeCl
91
91
public:
92
92
// IExplorerCommand implementation:
93
93
IFACEMETHODIMP GetTitle (IShellItemArray* items, PWSTR* name) {
94
- wchar_t value_w[MAX_PATH];
94
+ const size_t kMaxStringLength = 1024 ;
95
+ wchar_t value_w[kMaxStringLength ];
96
+ wchar_t expanded_value_w[kMaxStringLength ];
95
97
DWORD value_size_w = sizeof (value_w);
96
98
#if defined(INSIDER)
97
- const wchar_t kTitleRegkey [] = L" Software\\ Microsoft \\ VSCodeInsiders \\ ContextMenu " ;
99
+ const wchar_t kTitleRegkey [] = L" Software\\ Classes \\ VSCodeInsidersContextMenu " ;
98
100
#else
99
- const wchar_t kTitleRegkey [] = L" Software\\ Microsoft \\ VSCode \\ ContextMenu " ;
101
+ const wchar_t kTitleRegkey [] = L" Software\\ Classes \\ VSCodeContextMenu " ;
100
102
#endif
101
- LONG result = RegGetValueW (HKEY_LOCAL_MACHINE, kTitleRegkey , L" Title" , RRF_RT_REG_EXPAND_SZ | RRF_NOEXPAND,
102
- NULL , reinterpret_cast <LPBYTE>(&value_w), &value_size_w);
103
- if (result != ERROR_SUCCESS || value_size_w == 0 ) {
104
- RETURN_IF_FAILED (RegGetValueW (HKEY_CURRENT_USER, kTitleRegkey , L" Title" , RRF_RT_REG_EXPAND_SZ | RRF_NOEXPAND,
105
- NULL , reinterpret_cast <LPBYTE>(&value_w), &value_size_w));
103
+ HKEY subhkey = nullptr ;
104
+ LONG result = RegOpenKeyEx (HKEY_LOCAL_MACHINE, kTitleRegkey , 0 , KEY_READ, &subhkey);
105
+ if (result != ERROR_SUCCESS) {
106
+ result = RegOpenKeyEx (HKEY_CURRENT_USER, kTitleRegkey , 0 , KEY_READ, &subhkey);
106
107
}
107
- return SHStrDup (value_w, name);
108
+
109
+ DWORD type = REG_EXPAND_SZ;
110
+ RegQueryValueEx (subhkey, L" Title" , nullptr , &type,
111
+ reinterpret_cast <LPBYTE>(&value_w), &value_size_w);
112
+ RegCloseKey (subhkey);
113
+ value_size_w = ExpandEnvironmentStrings (value_w, expanded_value_w, kMaxStringLength );
114
+ return (value_size_w && value_size_w < kMaxStringLength )
115
+ ? SHStrDup (expanded_value_w, name)
116
+ : SHStrDup (L" UnExpected Title" , name);
108
117
}
109
118
110
119
IFACEMETHODIMP GetIcon (IShellItemArray* items, PWSTR* icon) {
0 commit comments