Today some of my fellow MVP’s asked the question if there is an option in Visual Studio to show under which user account the IDE is running.

the need this feature since they do a lot of demonstrations on using the IDE and then use the runas option, to show how you e.g. can work with multiple users on a piece of code using version control etc.

Unfortunately this is something not default possible with the VS IDE.

But after doing some visual Studio Integration work in the past I thought this should not be to hard to build myself.

On the first thought I would just try to create an Visual Studio Add-in and there try to obtain a reference to the main window and there set the caption. Unfortunately that would have been too easy :-D. It is not possible this way , since the property on the main window is read-only and when you try to set it you will get an error message.

But hey, you probably also remember the good old days where we had the Win32 API as our friend. In win32 you can set the windows caption of a window using a wind32 API call called SendMessage as long as you provide the correct parameters. So I thought to give that Idea a shot.

To make that work I did following:

On the Add In connect, get a reference to the Main Window. From the Main window, get the native windows handle (Hwnd)

Then use good old PInvoke to call an imported win32 API SendMessage and send a WM_SETTEXT message to the main window.

Now the last thing to fix, is that each and every time a window is opened or changed, the caption will disappear. To fix this, I just subscribed to two main events, WindowActivated and WindowCreated and there execute the same code again. this way the caption is always updated once a new window is opened or closed.

The following code does the trick:

As you can see, the following is the result when you activate the add-in:



Here you can find the sources as a downloadable Zip(, I did not create an installer for it, just open the zip, compile it and activate the registered Add-in.

voila 🙂



CTO at Xpirit, Microsoft Regional Director, Visual studio ALM MVP, Speaker, Pluralsight Author and IT Architect Consultant