MCPcopy Create free account
hub / github.com/Kitware/CMake / FindVisualStudioInstances

Function FindVisualStudioInstances

Source/cmCallVisualStudioMacro.cxx:327–361  ·  view source on GitHub ↗

Find instances of Visual Studio with the given solution file open. Pass "ALL" for slnFile to gather all running instances of Visual Studio.

Source from the content-addressed store, hash-verified

325//! open. Pass "ALL" for slnFile to gather all running instances
326//! of Visual Studio.
327HRESULT FindVisualStudioInstances(std::string const& slnFile,
328 std::vector<IDispatchPtr>& instances)
329{
330 std::map<std::string, IUnknownPtr> mrot;
331
332 HRESULT hr = GetRunningInstances(mrot);
333 ReportHRESULT(hr, "GetRunningInstances");
334
335 if (SUCCEEDED(hr)) {
336 std::map<std::string, IUnknownPtr>::iterator it;
337 for (it = mrot.begin(); it != mrot.end(); ++it) {
338 if (cmHasLiteralPrefix(it->first, "!VisualStudio.DTE.")) {
339 IDispatchPtr disp(it->second);
340 if (disp != (IDispatch*)0) {
341 std::string slnName;
342 hr = GetIDESolutionFullName(disp, slnName);
343 ReportHRESULT(hr, "GetIDESolutionFullName");
344
345 if (FilesSameSolution(slnFile, slnName)) {
346 instances.push_back(disp);
347
348 // std::cout << "Found Visual Studio instance." << std::endl;
349 // std::cout << " ROT entry name: " << it->first << std::endl;
350 // std::cout << " ROT entry object: "
351 // << (IUnknown*) it->second << std::endl;
352 // std::cout << " slnFile: " << slnFile << std::endl;
353 // std::cout << " slnName: " << slnName << std::endl;
354 }
355 }
356 }
357 }
358 }
359
360 return hr;
361}
362
363#endif // defined(HAVE_COMDEF_H)
364

Callers 2

CallMacroMethod · 0.85

Calls 7

GetRunningInstancesFunction · 0.85
cmHasLiteralPrefixFunction · 0.85
GetIDESolutionFullNameFunction · 0.85
FilesSameSolutionFunction · 0.85
push_backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…