http://blogs.clariusconsulting.net/pga

Pablo Galiano's Blog

Go Back to
pga′s Latest post

How do I get the Visual Studio command line switches

My eleventh How do I is up.

Scenario

Let’s say that we want to obtain the command line switches for the running Visual Studio instance. In this specific sample we want to know if Visual Studio is running in RANU mode. The focus of this How do I tackles this scenario.

Interfaces and classes needed

Code snippet

    public bool IsInRANUMode(IServiceProvider serviceProvider)

    {

        IVsAppCommandLine cmdLineService = serviceProvider.GetService(typeof(SVsAppCommandLine)) as IVsAppCommandLine;

        int present;

        string value;

 

        ErrorHandler.ThrowOnFailure(cmdLineService.GetOption(“ranu”, out present, out value));

 

        return Convert.ToBoolean(present);

    }

 

Assemblies needed

  • Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

Stay tuned,

Pablo

Comments