MCPcopy Create free account
hub / github.com/ConEmu/ConEmu / _CreateShellLink

Function _CreateShellLink

src/ConEmu/ConEmuApp.cpp:1208–1404  ·  view source on GitHub ↗

Creates a CLSID_ShellLink to insert into the Tasks section of the Jump List. This type of Jump List item allows the specification of an explicit command line to execute the task. Used only for JumpList creation...

Source from the content-addressed store, hash-verified

1206// List item allows the specification of an explicit command line to execute the task.
1207// Used only for JumpList creation...
1208static HRESULT _CreateShellLink(PCWSTR pszArguments, PCWSTR pszPrefix, PCWSTR pszTitle, IShellLink **ppsl)
1209{
1210 if ((!pszArguments || !*pszArguments) && (!pszTitle || !*pszTitle))
1211 {
1212 return E_INVALIDARG;
1213 }
1214
1215 LPCWSTR pszConfig = gpSetCls->GetConfigName();
1216 if (pszConfig && !*pszConfig)
1217 pszConfig = nullptr;
1218
1219 CEStr lsTempBuf;
1220 LPCWSTR pszConEmuStartArgs = gpConEmu->MakeConEmuStartArgs(lsTempBuf);
1221 _ASSERTE(!pszConEmuStartArgs || pszConEmuStartArgs[_tcslen(pszConEmuStartArgs)-1]==L' ');
1222
1223 wchar_t* pszBuf = nullptr;
1224 if (!pszArguments || !*pszArguments)
1225 {
1226 size_t cchMax = _tcslen(pszTitle)
1227 + (pszPrefix ? _tcslen(pszPrefix) : 0)
1228 + (pszConEmuStartArgs ? _tcslen(pszConEmuStartArgs) : 0)
1229 + 32;
1230
1231 pszBuf = (wchar_t*)malloc(cchMax*sizeof(*pszBuf));
1232 if (!pszBuf)
1233 return E_UNEXPECTED;
1234
1235 pszBuf[0] = 0;
1236 if (pszPrefix && *pszPrefix)
1237 {
1238 _wcscat_c(pszBuf, cchMax, pszPrefix);
1239 _wcscat_c(pszBuf, cchMax, L" ");
1240 }
1241 if (pszConEmuStartArgs && *pszConEmuStartArgs)
1242 {
1243 _wcscat_c(pszBuf, cchMax, pszConEmuStartArgs);
1244 }
1245 _wcscat_c(pszBuf, cchMax, L"-run ");
1246 _wcscat_c(pszBuf, cchMax, pszTitle);
1247 pszArguments = pszBuf;
1248 }
1249 else if (pszPrefix)
1250 {
1251 size_t cchMax = _tcslen(pszArguments)
1252 + _tcslen(pszPrefix)
1253 + (pszConfig ? _tcslen(pszConfig) : 0)
1254 + 32;
1255 pszBuf = (wchar_t*)malloc(cchMax*sizeof(*pszBuf));
1256 if (!pszBuf)
1257 return E_UNEXPECTED;
1258
1259 pszBuf[0] = 0;
1260 _wcscat_c(pszBuf, cchMax, pszPrefix);
1261 _wcscat_c(pszBuf, cchMax, L" ");
1262 if (pszConfig)
1263 {
1264 _wcscat_c(pszBuf, cchMax, L"-config \"");
1265 _wcscat_c(pszBuf, cchMax, pszConfig);

Callers 1

UpdateWin7TaskListFunction · 0.85

Calls 15

lstrdupFunction · 0.85
ExpandEnvStrFunction · 0.85
apiGetFullPathNameFunction · 0.85
FileExistsFunction · 0.85
apiSearchPathFunction · 0.85
GetConfigNameMethod · 0.80
MakeConEmuStartArgsMethod · 0.80
IsSwitchMethod · 0.80
OneOfSwitchesMethod · 0.80
LoadConsoleBatchMethod · 0.80
ProcessNewConArgMethod · 0.80

Tested by

no test coverage detected