As we know Visual Studio depends on the registry. Every VS component is registered in the registry and Visual Studio reads this information to configure and load the components at runtime.
This is also the case for a VS Shell Application. The only difference here is the main registry hive used. And this main hive is “Isolated” from the Visual Studio main hive.
The root hive for VS Shell applications is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\AppEnv\9.0\Apps\
Every VS Shell application has its own main hive and the name of this hive is composed of the stub’s name and GUID.
We can see that name on main cpp file for our stub:
nRetVal = Setup(W2A(lpCmdLine), L”MyVSShellApp_490526d0-3a2e-4a41-8bce-d01f8c1df6b7“, NULL);
This means that for this specific example the main hive for MyVSShellApp is:
Now lets talk about the /Setup switch. For the other available switches please refer to my previous post.
When we do a MyShellApp.exe /Setup a couple of things happens:
- The registry main hive is created
- The menus cache is refreshed
- VS templates are installed
In this post I will go into the details of the registry information created.
The /Setup switch tells appenvstub.dll to create the registry information based on the pkgdef files found under the \PackagesToLoad directory, and these are the steps:
- The VS Shell application hive is created
- All pkgdef files found are parsed and every single line is added to the registry (with support of parameter replacement variables)
- VS Shell application pkgdef file
- Any other VS package pkgdef file
- The %DevEnvDir%\Common7\IDE\AppEnv\AppEnvConfig.pkgdef file is parsed and every single line is added to the registry
- The %DevEnvDir%\Common7\IDE\AppEnv\BaseConfig.pkgdef file is parsed and every single line is added to the registry
- The VS Shell application pkgundef file is parsed and every single line is removed from the registry
Now when we do a MyVSShellApp.exe /Remove, the main registry hive for our VS Shell application is removed from the registry.