MCPcopy Create free account
hub / github.com/WinMerge/winmerge / RegisterShellExtension

Function RegisterShellExtension

Src/PropShell.cpp:87–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87static bool RegisterShellExtension(bool unregister, bool peruser)
88{
89 tchar_t szSystem32[260] = { 0 };
90 tchar_t szSysWow64[260] = { 0 };
91 GetSystemDirectory(szSystem32, sizeof(szSystem32) / sizeof(szSystem32[0]));
92 GetSystemWow64Directory(szSysWow64, sizeof(szSysWow64) / sizeof(szSysWow64[0]));
93
94 String progpath = env::GetProgPath();
95 String regsvr32 = paths::ConcatPath(szSystem32, _T("regsvr32.exe"));
96 String args;
97 String options = (unregister ? _T("/s /u") : _T("/s"));
98 options += peruser ? _T(" /n /i:user") : _T("");
99 SHELLEXECUTEINFO sei = { sizeof(sei) };
100 if (!peruser)
101 sei.lpVerb = _T("runas");
102 if (szSysWow64[0])
103 {
104#if defined _M_ARM64
105 args = options + _T(" \"") + paths::ConcatPath(progpath, _T("ShellExtensionARM64.dll")) + _T("\"");
106
107 sei.lpFile = regsvr32.c_str();
108 sei.lpParameters = args.c_str();
109 return !!ShellExecuteEx(&sei);
110#else
111 args = options + _T(" \"") + paths::ConcatPath(progpath, _T("ShellExtensionX64.dll")) + _T("\"");
112
113 sei.lpFile = regsvr32.c_str();
114 sei.lpParameters = args.c_str();
115 ShellExecuteEx(&sei);
116
117 regsvr32 = paths::ConcatPath(szSysWow64, _T("regsvr32.exe"));
118 args = options + _T(" \"") + paths::ConcatPath(progpath, _T("ShellExtensionU.dll")) + _T("\"");
119 sei.lpFile = regsvr32.c_str();
120 sei.lpParameters = args.c_str();
121 return !!ShellExecuteEx(&sei);
122#endif
123 }
124 else
125 {
126#if defined _M_ARM
127 args = options + _T(" \"") + paths::ConcatPath(progpath, _T("ShellExtensionARM.dll")) + _T("\"");
128#else
129 args = options + _T(" \"") + paths::ConcatPath(progpath, _T("ShellExtensionU.dll")) + _T("\"");
130#endif
131 sei.lpFile = regsvr32.c_str();
132 sei.lpParameters = args.c_str();
133 return !!ShellExecuteEx(&sei);
134 }
135}
136
137static bool RegisterWinMergeContextMenu(bool unregister)
138{

Calls 2

GetProgPathFunction · 0.85
ConcatPathFunction · 0.85

Tested by

no test coverage detected