예제 #1
0
파일: devenv.py 프로젝트: XLTechie/xlnvda
	def _getDTE(self):
		# Retrieve the top level automation object for the IDE
		bctx = objbase.CreateBindCtx()
		ROT = objbase.GetRunningObjectTable()
		for mon in ROT:
			displayName = mon.GetDisplayName(bctx, None)
			if displayName == f"!VisualStudio.DTE.{self.vsMajor}.0:{self.processID}":
				return comtypes.client.dynamic.Dispatch(ROT.GetObject(mon).QueryInterface(IDispatch))
		else:
			# None found.
			log.debugWarning("No top level automation object found", exc_info=True)
			return None
예제 #2
0
    def _getDTE(self):
        # Return the already fetched instance if there is one.
        try:
            if self._DTE:
                return self._DTE
        except AttributeError:
            pass

        # Retrieve and cache the top level automation object for the IDE
        DTEVersion = VsVersion_None
        bctx = objbase.CreateBindCtx()
        ROT = objbase.GetRunningObjectTable()
        for mon in ROT:
            # Test for the strings Visual Studio may have registered with.
            displayName = mon.GetDisplayName(bctx, None)
            if "!VisualStudio.DTE.9.0:%d" % self.processID == displayName:
                DTEVersion = VsVersion_2008
            elif "!VisualStudio.DTE.8.0:%d" % self.processID == displayName:
                DTEVersion = VsVersion_2005
            elif "!VisualStudio.DTE.7.1:%d" % self.processID == displayName:
                DTEVersion = VsVersion_2003
            elif "!VisualStudio.DTE:%d" % self.processID == displayName:
                DTEVersion = VsVersion_2002

            if DTEVersion != VsVersion_None:
                self._DTEVersion = DTEVersion
                self._DTE = comtypes.client.dynamic.Dispatch(
                    ROT.GetObject(mon).QueryInterface(IDispatch))
                break

        else:
            # None found.
            log.debugWarning("No top level automation object found")
            self._DTE = None
            self._DTEVersion = VsVersion_None

        # Loop has completed
        return self._DTE